From fd7fbcb31da52835cd5472cb1e621e7b5a21f420 Mon Sep 17 00:00:00 2001 From: Ian Maia Date: Wed, 28 Aug 2024 18:59:54 +0200 Subject: [PATCH 01/10] Update RuboCop and regenerate .rubocop_todo.yml --- .rubocop_todo.yml | 95 +++++++++++++++++++---- Gemfile.lock | 32 ++++---- fastlane-plugin-wpmreleasetoolkit.gemspec | 5 +- 3 files changed, 97 insertions(+), 35 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 4f2be7855..f23644c6c 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,12 +1,12 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2024-02-07 17:44:01 UTC using RuboCop version 1.60.2. +# on 2024-08-28 16:05:17 UTC using RuboCop version 1.65.1. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. -# Offense count: 11 +# Offense count: 10 # Configuration parameters: EnforcedStyle, AllowedGems, Include. # SupportedStyles: Gemfile, gems.rb, gemspec # Include: **/*.gemspec, **/Gemfile, **/gems.rb @@ -34,7 +34,7 @@ Naming/MethodParameterName: - 'lib/fastlane/plugin/wpmreleasetoolkit/actions/android/an_update_metadata_source_action.rb' - 'lib/fastlane/plugin/wpmreleasetoolkit/actions/common/gp_update_metadata_source.rb' -# Offense count: 110 +# Offense count: 109 # Configuration parameters: NamePrefix, ForbiddenPrefixes, AllowedMethods, MethodDefinitionMacros. # NamePrefix: is_, has_, have_ # ForbiddenPrefixes: is_, has_, have_ @@ -51,8 +51,14 @@ Naming/VariableNumber: Exclude: - 'lib/fastlane/plugin/wpmreleasetoolkit/helper/configure_helper.rb' -# Offense count: 5 -# Configuration parameters: Prefixes. +# Offense count: 6 +# This cop supports unsafe autocorrection (--autocorrect-all). +RSpec/BeEq: + Exclude: + - 'spec/file_reference_spec.rb' + +# Offense count: 6 +# Configuration parameters: Prefixes, AllowedPatterns. # Prefixes: when, with, without RSpec/ContextWording: Exclude: @@ -60,11 +66,20 @@ RSpec/ContextWording: - 'spec/git_helper_spec.rb' - 'spec/ios_lint_localizations_spec.rb' -# Offense count: 62 -# Configuration parameters: Include, CustomTransform, IgnoreMethods, SpecSuffixOnly. -# Include: **/*_spec*rb*, **/spec/**/* -RSpec/FilePath: - Enabled: false +# Offense count: 5 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: CustomTransform, IgnoredWords, DisallowedExamples. +# DisallowedExamples: works +RSpec/ExampleWording: + Exclude: + - 'spec/github_helper_spec.rb' + +# Offense count: 2 +# This cop supports safe autocorrection (--autocorrect). +RSpec/ExcessiveDocstringSpacing: + Exclude: + - 'spec/git_helper_spec.rb' + - 'spec/marketing_version_calculator_spec.rb' # Offense count: 25 # Configuration parameters: AssignmentOnly. @@ -73,14 +88,15 @@ RSpec/InstanceVariable: - 'spec/git_helper_spec.rb' - 'spec/ios_lint_localizations_spec.rb' -# Offense count: 122 +# Offense count: 146 # Configuration parameters: . # SupportedStyles: have_received, receive RSpec/MessageSpies: EnforcedStyle: receive # Offense count: 48 -# Configuration parameters: IgnoreSharedExamples. +# Configuration parameters: EnforcedStyle, IgnoreSharedExamples. +# SupportedStyles: always, named_only RSpec/NamedSubject: Exclude: - 'spec/android_version_helper_spec.rb' @@ -88,21 +104,72 @@ RSpec/NamedSubject: - 'spec/configuration_spec.rb' - 'spec/file_reference_spec.rb' -# Offense count: 14 +# Offense count: 20 +# Configuration parameters: AllowedGroups. RSpec/NestedGroups: Max: 5 -# Offense count: 7 +# Offense count: 54 +# Configuration parameters: AllowedPatterns. +# AllowedPatterns: ^expect_, ^assert_ +RSpec/NoExpectationExample: + Exclude: + - 'spec/android_firebase_test_spec.rb' + - 'spec/android_send_app_size_metrics_spec.rb' + - 'spec/firebase_test_runner_spec.rb' + - 'spec/get_prs_between_tags_spec.rb' + - 'spec/ios_download_strings_files_from_glotpress_spec.rb' + - 'spec/ios_generate_strings_file_from_code_spec.rb' + - 'spec/ios_lint_localizations_spec.rb' + - 'spec/ios_send_app_size_metrics_spec.rb' + - 'spec/release_notes_helper_spec.rb' + +# Offense count: 10 +# This cop supports unsafe autocorrection (--autocorrect-all). +RSpec/ReceiveMessages: + Exclude: + - 'spec/android_firebase_test_spec.rb' + - 'spec/file_reference_spec.rb' + - 'spec/firebase_device_spec.rb' + +# Offense count: 67 +# Configuration parameters: Include, CustomTransform, IgnoreMethods, IgnoreMetadata. +# Include: **/*_spec.rb +RSpec/SpecFilePathFormat: + Enabled: false + +# Offense count: 9 RSpec/StubbedMock: Exclude: - 'spec/encryption_helper_spec.rb' - 'spec/file_reference_spec.rb' + - 'spec/publish_release_spec.rb' + +# Offense count: 2 +RSpec/SubjectDeclaration: + Exclude: + - 'spec/file_reference_spec.rb' # Offense count: 6 RSpec/SubjectStub: Exclude: - 'spec/file_reference_spec.rb' +# Offense count: 18 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: constant, string +RSpec/VerifiedDoubleReference: + Exclude: + - 'spec/copy_branch_protection_action_spec.rb' + - 'spec/create_release_backmerge_pull_request_spec.rb' + - 'spec/get_prs_between_tags_spec.rb' + - 'spec/github_helper_spec.rb' + - 'spec/remove_branch_protection_action_spec.rb' + - 'spec/set_branch_protection_action_spec.rb' + - 'spec/set_milestone_frozen_marker_action_spec.rb' + - 'spec/update_assigned_milestone_spec.rb' + # Offense count: 4 # Configuration parameters: IgnoreNameless, IgnoreSymbolicNames. RSpec/VerifiedDoubles: diff --git a/Gemfile.lock b/Gemfile.lock index f36943927..736ff8abd 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -26,7 +26,7 @@ GEM base64 nkf rexml - activesupport (7.2.0) + activesupport (7.2.1) base64 bigdecimal concurrent-ruby (~> 1.0, >= 1.3.1) @@ -46,16 +46,16 @@ GEM ast (2.4.2) atomos (0.1.3) aws-eventstream (1.3.0) - aws-partitions (1.963.0) - aws-sdk-core (3.201.4) + aws-partitions (1.968.0) + aws-sdk-core (3.202.0) aws-eventstream (~> 1, >= 1.3.0) aws-partitions (~> 1, >= 1.651.0) - aws-sigv4 (~> 1.8) + aws-sigv4 (~> 1.9) jmespath (~> 1, >= 1.6.1) aws-sdk-kms (1.88.0) aws-sdk-core (~> 3, >= 3.201.0) aws-sigv4 (~> 1.5) - aws-sdk-s3 (1.157.0) + aws-sdk-s3 (1.159.0) aws-sdk-core (~> 3, >= 3.201.0) aws-sdk-kms (~> 1) aws-sigv4 (~> 1.5) @@ -277,7 +277,7 @@ GEM signet (>= 0.16, < 2.a) hashdiff (1.1.1) highline (2.0.3) - http-cookie (1.0.6) + http-cookie (1.0.7) domain_name (~> 0.5) httpclient (2.8.3) i18n (1.14.5) @@ -297,7 +297,7 @@ GEM mini_magick (4.13.2) mini_mime (1.1.5) mini_portile2 (2.8.7) - minitest (5.24.1) + minitest (5.25.1) molinillo (0.8.0) multi_json (1.15.0) multipart-post (2.4.1) @@ -317,7 +317,7 @@ GEM options (2.3.2) optparse (0.5.0) os (1.1.4) - parallel (1.26.2) + parallel (1.26.3) parser (3.3.4.2) ast (~> 2.4.1) racc @@ -354,7 +354,7 @@ GEM rspec-mocks (~> 3.13.0) rspec-core (3.13.0) rspec-support (~> 3.13.0) - rspec-expectations (3.13.1) + rspec-expectations (3.13.2) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.13.0) rspec-mocks (3.13.1) @@ -374,13 +374,10 @@ GEM rubocop-ast (>= 1.31.1, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 2.4.0, < 3.0) - rubocop-ast (1.32.0) + rubocop-ast (1.32.1) parser (>= 3.3.1.0) - rubocop-require_tools (0.1.2) - rubocop (>= 0.49.1) - rubocop-rspec (2.3.0) - rubocop (~> 1.0) - rubocop-ast (>= 1.1.0) + rubocop-rspec (3.0.0) + rubocop (~> 1.40) ruby-macho (2.5.1) ruby-progressbar (1.13.0) ruby2_keywords (0.0.5) @@ -451,9 +448,8 @@ DEPENDENCIES rmagick (~> 5.3) rspec (~> 3.8) rspec_junit_formatter (~> 0.4.1) - rubocop (~> 1.0) - rubocop-require_tools (~> 0.1.2) - rubocop-rspec (= 2.3.0) + rubocop (~> 1.65) + rubocop-rspec (= 3.0) simplecov (~> 0.16.1) webmock yard diff --git a/fastlane-plugin-wpmreleasetoolkit.gemspec b/fastlane-plugin-wpmreleasetoolkit.gemspec index 73549df9b..9ab97fc9a 100644 --- a/fastlane-plugin-wpmreleasetoolkit.gemspec +++ b/fastlane-plugin-wpmreleasetoolkit.gemspec @@ -52,8 +52,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency 'rmagick', '~> 5.3' spec.add_development_dependency 'rspec', '~> 3.8' spec.add_development_dependency 'rspec_junit_formatter', '~> 0.4.1' - spec.add_development_dependency 'rubocop', '~> 1.0' - spec.add_development_dependency 'rubocop-require_tools', '~> 0.1.2' - spec.add_development_dependency 'rubocop-rspec', '2.3.0' + spec.add_development_dependency 'rubocop', '~> 1.65' + spec.add_development_dependency 'rubocop-rspec', '3.0' spec.add_development_dependency 'simplecov', '~> 0.16.1' end From 05d24815791b171187548946855b10a98aa9862c Mon Sep 17 00:00:00 2001 From: Ian Maia Date: Wed, 28 Aug 2024 19:00:10 +0200 Subject: [PATCH 02/10] Add `publish_release` action --- .../actions/common/publish_release_action.rb | 63 +++++++++++++++++++ .../wpmreleasetoolkit/helper/github_helper.rb | 27 +++++++- spec/publish_release_spec.rb | 62 ++++++++++++++++++ 3 files changed, 151 insertions(+), 1 deletion(-) create mode 100644 lib/fastlane/plugin/wpmreleasetoolkit/actions/common/publish_release_action.rb create mode 100644 spec/publish_release_spec.rb diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/publish_release_action.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/publish_release_action.rb new file mode 100644 index 000000000..6ed0572c6 --- /dev/null +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/publish_release_action.rb @@ -0,0 +1,63 @@ +require 'fastlane/action' +require_relative '../../helper/github_helper' + +module Fastlane + module Actions + class PublishReleaseAction < Action + def self.run(params) + repository = params[:repository] + name = params[:name] + prerelease = params[:prerelease] + + github_helper = Fastlane::Helper::GithubHelper.new(github_token: params[:github_token]) + + url = github_helper.publish_release( + repository: repository, + name: name, + prerelease: prerelease + ) + UI.success("Successfully published GitHub Release #{name}. You can see it at '#{url}'") + url + end + + def self.description + 'Publishes an existing GitHub Release still in draft mode' + end + + def self.authors + ['Automattic'] + end + + def self.return_value + 'The URL of the published GitHub Release' + end + + def self.details + 'Publishes an existing GitHub Release still in draft mode' + end + + def self.available_options + [ + FastlaneCore::ConfigItem.new(key: :repository, + description: 'The slug (`/`) of the GitHub repository we want to create the release on', + optional: false, + type: String), + FastlaneCore::ConfigItem.new(key: :name, + description: 'The name of the release', + optional: false, + type: String), + FastlaneCore::ConfigItem.new(key: :prerelease, + description: 'True if this is a pre-release', + optional: true, + default_value: false, + type: Boolean), + Fastlane::Helper::GithubHelper.github_token_config_item, + ] + end + + def self.is_supported?(platform) + true + end + end + end +end diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/helper/github_helper.rb b/lib/fastlane/plugin/wpmreleasetoolkit/helper/github_helper.rb index c52e6c9e3..1fbebbdf0 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/helper/github_helper.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/helper/github_helper.rb @@ -186,7 +186,7 @@ def generate_release_notes(repository:, tag_name:, previous_tag:, target_commiti res.body end - # Returns the URL of the GitHub release pointing at a given tag + # Returns the URL of the published GitHub release pointing at a given tag # @param [String] repository The repository to create the GitHub release on. Typically a repo slug (/). # @param [String] tag_name The name of the git tag to get the associated release of # @@ -198,6 +198,31 @@ def get_release_url(repository:, tag_name:) nil end + # Publishes an existing GitHub Release still in draft mode. Note that this will search only within the first page of releases, as returned by the GitHub API. + # + # @param [String] repository The repository name, including the organization (e.g. `wordpress-mobile/wordpress-ios`) + # @param [String] name The name of the release to publish. + # @param [Boolean] prerelease Indicates if this should be created as a pre-release (i.e. for alpha/beta) + # + # @return [String] URL of the corresponding GitHub Release + # + def publish_release(repository:, name:, prerelease: false) + releases = client.releases(repository) + release = releases.find { |r| r.name == name } + + UI.user_error!("No release found with version #{name}") unless release + + client.update_release( + release.url, + { + draft: false, + prerelease: prerelease + } + ) + + release.html_url + end + # Downloads a file from the given GitHub tag # # @param [String] repository The repository name (including the organization) diff --git a/spec/publish_release_spec.rb b/spec/publish_release_spec.rb new file mode 100644 index 000000000..174fe6f92 --- /dev/null +++ b/spec/publish_release_spec.rb @@ -0,0 +1,62 @@ +require 'spec_helper' + +describe Fastlane::Actions::PublishReleaseAction do + let(:test_token) { 'ghp_fake_token' } + let(:test_repo) { 'repo-test/project-test' } + let(:test_name) { '1.0.0' } + let(:github_helper) { instance_double(Fastlane::Helper::GithubHelper) } + + before do + allow(Fastlane::Helper::GithubHelper).to receive(:new).and_return(github_helper) + end + + context 'when providing valid parameters' do + it 'publishes the release and returns the URL' do + expect(github_helper).to receive(:publish_release).with( + repository: test_repo, + name: test_name, + prerelease: false + ).and_return('https://github.com/repo-test/project-test/releases/tag/1.0.0') + + result = run_described_fastlane_action( + github_token: test_token, + repository: test_repo, + name: test_name + ) + + expect(result).to eq('https://github.com/repo-test/project-test/releases/tag/1.0.0') + end + + it 'publishes a prerelease when specified' do + expect(github_helper).to receive(:publish_release).with( + repository: test_repo, + name: test_name, + prerelease: true + ).and_return('https://github.com/repo-test/project-test/releases/tag/1.0.0-beta') + + result = run_described_fastlane_action( + github_token: test_token, + repository: test_repo, + name: test_name, + prerelease: true + ) + + expect(result).to eq('https://github.com/repo-test/project-test/releases/tag/1.0.0-beta') + end + end + + context 'when successful' do + it 'prints a success message' do + allow(github_helper).to receive(:publish_release).and_return('https://github.com/repo-test/project-test/releases/tag/1.0.0') + + allow(Fastlane::UI).to receive(:success).with(anything).at_least(:once) + expect(Fastlane::UI).to receive(:success).with("Successfully published GitHub Release 1.0.0. You can see it at 'https://github.com/repo-test/project-test/releases/tag/1.0.0'") + + run_described_fastlane_action( + github_token: test_token, + repository: test_repo, + name: test_name + ) + end + end +end From 5f5284b813a0d554c1240aa711dbd1ea88913c6e Mon Sep 17 00:00:00 2001 From: Ian Maia Date: Wed, 28 Aug 2024 19:34:08 +0200 Subject: [PATCH 03/10] Update CHANGELOG --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e88771261..aebc88d2d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,7 @@ ### New Features -_None_ +- Added the action `publish_release` to facilitate publishing of GitHub draft releases [#585] ### Bug Fixes From 27a9f8d3b1feec210a4b2ff26ecd5cf927973f7a Mon Sep 17 00:00:00 2001 From: Ian Guedes Maia Date: Thu, 29 Aug 2024 11:34:57 +0200 Subject: [PATCH 04/10] Update error message --- lib/fastlane/plugin/wpmreleasetoolkit/helper/github_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/helper/github_helper.rb b/lib/fastlane/plugin/wpmreleasetoolkit/helper/github_helper.rb index 1fbebbdf0..dfb0be6dd 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/helper/github_helper.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/helper/github_helper.rb @@ -210,7 +210,7 @@ def publish_release(repository:, name:, prerelease: false) releases = client.releases(repository) release = releases.find { |r| r.name == name } - UI.user_error!("No release found with version #{name}") unless release + UI.user_error!("No release found with name #{name}") unless release client.update_release( release.url, From ebbd05b9a59a7683477ff5c65c214fdb74407a8e Mon Sep 17 00:00:00 2001 From: Ian Guedes Maia Date: Fri, 30 Aug 2024 20:17:03 +0200 Subject: [PATCH 05/10] Apply suggestions from code review Co-authored-by: Olivier Halligon --- CHANGELOG.md | 2 +- .../actions/common/publish_release_action.rb | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aebc88d2d..801db7d21 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,7 @@ ### New Features -- Added the action `publish_release` to facilitate publishing of GitHub draft releases [#585] +- Added the `publish_release` action to publish existing GitHub draft releases [#585] ### Bug Fixes diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/publish_release_action.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/publish_release_action.rb index 6ed0572c6..ef472a245 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/publish_release_action.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/publish_release_action.rb @@ -21,7 +21,7 @@ def self.run(params) end def self.description - 'Publishes an existing GitHub Release still in draft mode' + 'Publish an existing GitHub Release still in draft mode' end def self.authors @@ -33,7 +33,7 @@ def self.return_value end def self.details - 'Publishes an existing GitHub Release still in draft mode' + 'Publish an existing GitHub Release still in draft mode' end def self.available_options @@ -43,11 +43,11 @@ def self.available_options optional: false, type: String), FastlaneCore::ConfigItem.new(key: :name, - description: 'The name of the release', + description: 'The name (aka title) of the draft release to publish', optional: false, type: String), FastlaneCore::ConfigItem.new(key: :prerelease, - description: 'True if this is a pre-release', + description: 'True if this should be published as a pre-release', optional: true, default_value: false, type: Boolean), From d9c348eb42a5772b805d819fd27fb95dac767596 Mon Sep 17 00:00:00 2001 From: Ian Guedes Maia Date: Fri, 30 Aug 2024 20:22:23 +0200 Subject: [PATCH 06/10] Update comment to not mention pagination --- lib/fastlane/plugin/wpmreleasetoolkit/helper/github_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/helper/github_helper.rb b/lib/fastlane/plugin/wpmreleasetoolkit/helper/github_helper.rb index dfb0be6dd..1a3b88f37 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/helper/github_helper.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/helper/github_helper.rb @@ -198,7 +198,7 @@ def get_release_url(repository:, tag_name:) nil end - # Publishes an existing GitHub Release still in draft mode. Note that this will search only within the first page of releases, as returned by the GitHub API. + # Publishes an existing GitHub Release still in draft mode. # # @param [String] repository The repository name, including the organization (e.g. `wordpress-mobile/wordpress-ios`) # @param [String] name The name of the release to publish. From eb321aab9ef2a7e5c2116d5a1d4355fb625938ad Mon Sep 17 00:00:00 2001 From: Ian Maia Date: Mon, 2 Sep 2024 17:05:20 +0200 Subject: [PATCH 07/10] Rename `publish_release` and `create_release` to `publish_github_release` and `create_github_release` --- CHANGELOG.md | 4 ++-- ...se_action.rb => create_github_release_action.rb} | 13 ++++++++++++- ...e_action.rb => publish_github_release_action.rb} | 2 +- ...lease_spec.rb => publish_github_release_spec.rb} | 6 +++--- 4 files changed, 18 insertions(+), 7 deletions(-) rename lib/fastlane/plugin/wpmreleasetoolkit/actions/common/{create_release_action.rb => create_github_release_action.rb} (93%) rename lib/fastlane/plugin/wpmreleasetoolkit/actions/common/{publish_release_action.rb => publish_github_release_action.rb} (97%) rename spec/{publish_release_spec.rb => publish_github_release_spec.rb} (91%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 801db7d21..058c75323 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,11 +10,11 @@ ### New Features -- Added the `publish_release` action to publish existing GitHub draft releases [#585] +- Added the `publish_github_release` action to publish existing GitHub draft releases [#585] ### Bug Fixes -_None_ +- Deprecated the `create_release` action, now renamed to `create_github_release` for consistency [#585] ### Internal Changes diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/create_release_action.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/create_github_release_action.rb similarity index 93% rename from lib/fastlane/plugin/wpmreleasetoolkit/actions/common/create_release_action.rb rename to lib/fastlane/plugin/wpmreleasetoolkit/actions/common/create_github_release_action.rb index f294a362b..5672ea5ec 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/create_release_action.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/create_github_release_action.rb @@ -5,7 +5,7 @@ require_relative '../../helper/android/android_version_helper' module Fastlane module Actions - class CreateReleaseAction < Action + class CreateGithubReleaseAction < Action def self.run(params) repository = params[:repository] version = params[:version] @@ -100,5 +100,16 @@ def self.is_supported?(platform) true end end + + # For backwards compatibility + class CreateReleaseAction < CreateGithubReleaseAction + def self.category + :deprecated + end + + def self.deprecated_notes + "This action has been renamed `#{superclass.action_name}`" + end + end end end diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/publish_release_action.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/publish_github_release_action.rb similarity index 97% rename from lib/fastlane/plugin/wpmreleasetoolkit/actions/common/publish_release_action.rb rename to lib/fastlane/plugin/wpmreleasetoolkit/actions/common/publish_github_release_action.rb index ef472a245..144f06b40 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/publish_release_action.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/publish_github_release_action.rb @@ -3,7 +3,7 @@ module Fastlane module Actions - class PublishReleaseAction < Action + class PublishGithubReleaseAction < Action def self.run(params) repository = params[:repository] name = params[:name] diff --git a/spec/publish_release_spec.rb b/spec/publish_github_release_spec.rb similarity index 91% rename from spec/publish_release_spec.rb rename to spec/publish_github_release_spec.rb index 174fe6f92..5cedddd13 100644 --- a/spec/publish_release_spec.rb +++ b/spec/publish_github_release_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe Fastlane::Actions::PublishReleaseAction do +describe Fastlane::Actions::PublishGithubReleaseAction do let(:test_token) { 'ghp_fake_token' } let(:test_repo) { 'repo-test/project-test' } let(:test_name) { '1.0.0' } @@ -12,7 +12,7 @@ context 'when providing valid parameters' do it 'publishes the release and returns the URL' do - expect(github_helper).to receive(:publish_release).with( + allow(github_helper).to receive(:publish_release).with( repository: test_repo, name: test_name, prerelease: false @@ -28,7 +28,7 @@ end it 'publishes a prerelease when specified' do - expect(github_helper).to receive(:publish_release).with( + allow(github_helper).to receive(:publish_release).with( repository: test_repo, name: test_name, prerelease: true From f9fa87c2e3ba199b560ee25ba153a90cfe2e9013 Mon Sep 17 00:00:00 2001 From: Ian Maia Date: Mon, 2 Sep 2024 17:33:17 +0200 Subject: [PATCH 08/10] Update `prerelease` parameter handling so that it doesn't change the pre-release property of the milestone if not specified --- .../actions/common/publish_github_release_action.rb | 4 ++-- lib/fastlane/plugin/wpmreleasetoolkit/helper/github_helper.rb | 4 ++-- spec/publish_github_release_spec.rb | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/publish_github_release_action.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/publish_github_release_action.rb index 144f06b40..d331812dc 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/publish_github_release_action.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/publish_github_release_action.rb @@ -14,7 +14,7 @@ def self.run(params) url = github_helper.publish_release( repository: repository, name: name, - prerelease: prerelease + prerelease: prerelease == :unchanged ? nil : prerelease ) UI.success("Successfully published GitHub Release #{name}. You can see it at '#{url}'") url @@ -49,7 +49,7 @@ def self.available_options FastlaneCore::ConfigItem.new(key: :prerelease, description: 'True if this should be published as a pre-release', optional: true, - default_value: false, + default_value: :unchanged, type: Boolean), Fastlane::Helper::GithubHelper.github_token_config_item, ] diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/helper/github_helper.rb b/lib/fastlane/plugin/wpmreleasetoolkit/helper/github_helper.rb index 1a3b88f37..733b2a678 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/helper/github_helper.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/helper/github_helper.rb @@ -206,7 +206,7 @@ def get_release_url(repository:, tag_name:) # # @return [String] URL of the corresponding GitHub Release # - def publish_release(repository:, name:, prerelease: false) + def publish_release(repository:, name:, prerelease: nil) releases = client.releases(repository) release = releases.find { |r| r.name == name } @@ -217,7 +217,7 @@ def publish_release(repository:, name:, prerelease: false) { draft: false, prerelease: prerelease - } + }.compact ) release.html_url diff --git a/spec/publish_github_release_spec.rb b/spec/publish_github_release_spec.rb index 5cedddd13..0aa629542 100644 --- a/spec/publish_github_release_spec.rb +++ b/spec/publish_github_release_spec.rb @@ -15,7 +15,7 @@ allow(github_helper).to receive(:publish_release).with( repository: test_repo, name: test_name, - prerelease: false + prerelease: nil ).and_return('https://github.com/repo-test/project-test/releases/tag/1.0.0') result = run_described_fastlane_action( From 18e63b17b949565a88664d25188d1fd8ff42edfd Mon Sep 17 00:00:00 2001 From: Ian Guedes Maia Date: Mon, 2 Sep 2024 17:40:14 +0200 Subject: [PATCH 09/10] Update prerelease action parameter description Co-authored-by: Olivier Halligon --- .../actions/common/publish_github_release_action.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/publish_github_release_action.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/publish_github_release_action.rb index d331812dc..5a3d281be 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/publish_github_release_action.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/publish_github_release_action.rb @@ -47,7 +47,7 @@ def self.available_options optional: false, type: String), FastlaneCore::ConfigItem.new(key: :prerelease, - description: 'True if this should be published as a pre-release', + description: 'True if this should be published as a pre-release. False if this should be published as final. Don\'t provide a value keep the same (non-)prerelease status as the one used in the Draft', optional: true, default_value: :unchanged, type: Boolean), From 87558259f73620db9641488767cc631ab8ec2106 Mon Sep 17 00:00:00 2001 From: Ian Guedes Maia Date: Mon, 2 Sep 2024 18:43:24 +0200 Subject: [PATCH 10/10] Update prerelease action parameter description Co-authored-by: Olivier Halligon --- .../actions/common/publish_github_release_action.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/publish_github_release_action.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/publish_github_release_action.rb index 5a3d281be..8629012db 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/publish_github_release_action.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/publish_github_release_action.rb @@ -47,7 +47,7 @@ def self.available_options optional: false, type: String), FastlaneCore::ConfigItem.new(key: :prerelease, - description: 'True if this should be published as a pre-release. False if this should be published as final. Don\'t provide a value keep the same (non-)prerelease status as the one used in the Draft', + description: 'True to publish as a pre-release. False to published as final. Don\'t provide a value to keep the same (non-)prerelease status as the one used in the Draft', optional: true, default_value: :unchanged, type: Boolean),