Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publish Release Action #585

Merged
merged 10 commits into from
Sep 3, 2024
95 changes: 81 additions & 14 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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_
Expand All @@ -51,20 +51,35 @@ 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:
- 'spec/ci_helper_spec.rb'
- '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.
Expand All @@ -73,36 +88,88 @@ 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'
- 'spec/ci_helper_spec.rb'
- '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:
Expand Down
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@

### New Features

_None_
- 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

Expand Down
32 changes: 14 additions & 18 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions fastlane-plugin-wpmreleasetoolkit.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 🧹

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
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -100,5 +100,16 @@ def self.is_supported?(platform)
true
end
end

# For backwards compatibility
class CreateReleaseAction < CreateGithubReleaseAction
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if it makes more sense to document this in the MIGRATION.md for the upcoming major version (in which it'll still be available… but deprecated), or only mention it in the major version after that, the one in which we'd ultimately delete that backwards-compatibility shim…

I think in the past we went with the latter, but I'm open to debate it if some you think it makes more sense to go with the former 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm yeah I think it makes sense to document it there only when the migration is actually needed, so I'd just mention it in the version where we actually remove it, breaking the compatibility 🤔 I think the changelog update should be enough heads up that this is going to change?

def self.category
:deprecated
end

def self.deprecated_notes
"This action has been renamed `#{superclass.action_name}`"
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
require 'fastlane/action'
require_relative '../../helper/github_helper'

module Fastlane
module Actions
class PublishGithubReleaseAction < 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 == :unchanged ? nil : prerelease
)
UI.success("Successfully published GitHub Release #{name}. You can see it at '#{url}'")
url
end

def self.description
'Publish 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
'Publish an existing GitHub Release still in draft mode'
end

def self.available_options
[
FastlaneCore::ConfigItem.new(key: :repository,
description: 'The slug (`<org>/<repo>`) of the GitHub repository we want to create the release on',
optional: false,
type: String),
FastlaneCore::ConfigItem.new(key: :name,
description: 'The name (aka title) of the draft release to publish',
optional: false,
type: String),
FastlaneCore::ConfigItem.new(key: :prerelease,
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),
Comment on lines +52 to +53
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love it how in Ruby we can pass a symbol as default value and then declare the type as Boolean... 😅

Fastlane::Helper::GithubHelper.github_token_config_item,
]
end

def self.is_supported?(platform)
true
end
end
end
end
Loading