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
Merged

Publish Release Action #585

merged 10 commits into from
Sep 3, 2024

Conversation

iangmaia
Copy link
Contributor

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

  • Run bundle exec rubocop to test for code style violations and recommendations
  • Add Unit Tests (aka specs/*_spec.rb) if applicable
  • Run bundle exec rspec to run the whole test suite and ensure all your tests pass
  • Make sure you added an entry in the CHANGELOG.md file to describe your changes under the appropriate existing ### subsection of the existing ## Trunk section.
  • If applicable, add an entry in the 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.

@iangmaia iangmaia added the enhancement New feature or request label Aug 28, 2024
@iangmaia iangmaia self-assigned this Aug 28, 2024
@iangmaia iangmaia force-pushed the iangmaia/publish-release branch 2 times, most recently from 598682b to f29e52f Compare August 28, 2024 17:32
@iangmaia iangmaia marked this pull request as ready for review August 28, 2024 17:35
@iangmaia iangmaia requested a review from a team August 28, 2024 17:35
CHANGELOG.md Outdated Show resolved Hide resolved
@@ -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.

👍 🧹

Comment on lines 51 to 52
optional: true,
default_value: false,
Copy link
Contributor

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
        )

Copy link
Contributor Author

@iangmaia iangmaia Sep 2, 2024

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

Comment on lines 217 to 220
{
draft: false,
prerelease: prerelease
}
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍
Updated on f9fa87c

@@ -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?

Comment on lines +52 to +53
default_value: :unchanged,
type: Boolean),
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... 😅

Comment on lines +48 to +61
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
Copy link
Contributor

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?

Copy link
Contributor Author

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.

@mokagio mokagio merged commit 671af15 into trunk Sep 3, 2024
5 checks passed
@mokagio mokagio deleted the iangmaia/publish-release branch September 3, 2024 01:35
@mokagio
Copy link
Contributor

mokagio commented Sep 3, 2024

@iangmaia I'll take over merging this already approved PR so that I can update the changelog etc. of my removal PR #580 on top of this.

mokagio added a commit that referenced this pull request Sep 3, 2024
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`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants