-
Notifications
You must be signed in to change notification settings - Fork 9
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
Conversation
598682b
to
f29e52f
Compare
@@ -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' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 🧹
lib/fastlane/plugin/wpmreleasetoolkit/actions/common/publish_release_action.rb
Outdated
Show resolved
Hide resolved
lib/fastlane/plugin/wpmreleasetoolkit/actions/common/publish_release_action.rb
Outdated
Show resolved
Hide resolved
lib/fastlane/plugin/wpmreleasetoolkit/actions/common/publish_release_action.rb
Outdated
Show resolved
Hide resolved
lib/fastlane/plugin/wpmreleasetoolkit/actions/common/publish_release_action.rb
Outdated
Show resolved
Hide resolved
optional: true, | ||
default_value: false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❓ I'm wondering if we would want to provide a way to keep that value unchanged?
Especially because with this having a default_value
and the prerelease
being explicitly passed to the API call in the helper, that means that if we ask to publish_release("12.3-rc-2")
of a beta GitHub Release draft (which had "This is a pre-release" checkbox checked at the time), without explicitly passing prerelease: true
to that call site, this will change the GitHub Release from initially being marked as a pre-release when it was created as Draft to being a final release when published.
Sadly, even if we set to optional: true
but with default_value: nil
, fastlane will make options[:prerelease]
return false
(and not nil
) if we call the action without the parameter. But I just checked and if we set default_value: :unchanged
, then fastlane
is happy to have options[:prerelease]
return that :unchanged
symbol (despite type: Boolean
—it doesn't seem to doo any type-check when using the default value). So that means that we could use that to our advantage here, and in self.run
do something like:
url = github_helper.publish_release(
repository: repository,
name: name,
prerelease: (prerelease == :unchanged) ? nil : prerelease
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea 👍 updated on f9fa87c
{ | ||
draft: false, | ||
prerelease: prerelease | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you end up going with my suggestion of supporting :unchanged
in the action's parameter, and thus nil
for the prerelease
parameter of this helper, you might need to call .compact
on this hash to remove the potential prerelease: nil
value from it when calling the API
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Updated on f9fa87c
dbe928e
to
d9c348e
Compare
…ase` and `create_github_release`
…pre-release property of the milestone if not specified
c283c5e
to
f9fa87c
Compare
lib/fastlane/plugin/wpmreleasetoolkit/actions/common/publish_github_release_action.rb
Outdated
Show resolved
Hide resolved
lib/fastlane/plugin/wpmreleasetoolkit/actions/common/publish_github_release_action.rb
Outdated
Show resolved
Hide resolved
lib/fastlane/plugin/wpmreleasetoolkit/actions/common/publish_github_release_action.rb
Outdated
Show resolved
Hide resolved
lib/fastlane/plugin/wpmreleasetoolkit/actions/common/publish_github_release_action.rb
Outdated
Show resolved
Hide resolved
Co-authored-by: Olivier Halligon <[email protected]>
6e552e0
to
18e63b1
Compare
lib/fastlane/plugin/wpmreleasetoolkit/actions/common/publish_github_release_action.rb
Outdated
Show resolved
Hide resolved
Co-authored-by: Olivier Halligon <[email protected]>
@@ -100,5 +100,16 @@ def self.is_supported?(platform) | |||
true | |||
end | |||
end | |||
|
|||
# For backwards compatibility | |||
class CreateReleaseAction < CreateGithubReleaseAction |
There was a problem hiding this comment.
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 🤔
There was a problem hiding this comment.
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?
default_value: :unchanged, | ||
type: Boolean), |
There was a problem hiding this comment.
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... 😅
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you considered adding a test for the path where GitHub returns an error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mokagio for the Action level, my first thought was just let the error to propagate in these cases.
Build on top of #585. Those changes were merged just recently but their context was that of a minor update, unaware that `trunk` already included a breaking change. Since we are breaking things, I'd say we might as well remove backward compatibility by forcing users that upgrade to 12.0.0 to rename `create_release` to `create_github_release`.
What does it do?
This PR adds a
publish_release
action, intended for publishing an already existing GitHub release draft.Context: in some apps' release process, we first create a prototype to let the release manager to download and test the build prior to the final publishing and store submission. Only when the release is ready to start the rollout, we ask them publish it.
This action will automate this process, finding and publishing the release on GitHub.
Checklist before requesting a review
bundle exec rubocop
to test for code style violations and recommendationsspecs/*_spec.rb
) if applicablebundle exec rspec
to run the whole test suite and ensure all your tests passCHANGELOG.md
file to describe your changes under the appropriate existing###
subsection of the existing## Trunk
section.MIGRATION.md
file to describe how the changes will affect the migration from the previous major version and what the clients will need to change and consider.