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

[Tooling] Add Release Publishing automation #12450

Merged
merged 11 commits into from
Sep 5, 2024

Conversation

iangmaia
Copy link
Contributor

This PR automates the release publishing, which means to:

  • Publish the existing draft release on GitHub (which will also have GitHub create the associated git tag, pointing to the tip of the branch)
  • If the release branch for the next version already exists, backmerge the current release into it
  • Delete the current release branch

This PR will be followed by updates to the Releases V2 tool.

@iangmaia iangmaia added the category: tooling Anything that involves building & maintaining the project, including scripts, `Fastfile`, etc. label Aug 29, 2024
@iangmaia iangmaia requested a review from a team August 29, 2024 18:59
@iangmaia iangmaia self-assigned this Aug 29, 2024
@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Aug 29, 2024

📲 You can test the changes from this Pull Request in WooCommerce-Wear Android by scanning the QR code below to install the corresponding build.
App Name WooCommerce-Wear Android
Platform⌚️ Wear OS
FlavorJalapeno
Build TypeDebug
Commitf2a438e
Direct Downloadwoocommerce-wear-prototype-build-pr12450-f2a438e.apk

@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Aug 29, 2024

📲 You can test the changes from this Pull Request in WooCommerce Android by scanning the QR code below to install the corresponding build.

App Name WooCommerce Android
Platform📱 Mobile
FlavorJalapeno
Build TypeDebug
Commitf2a438e
Direct Downloadwoocommerce-prototype-build-pr12450-f2a438e.apk

@iangmaia iangmaia added this to the 20.3 milestone Aug 30, 2024
Copy link
Contributor

@AliSoftware AliSoftware left a comment

Choose a reason for hiding this comment

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

Apart from the rename suggestion, LGTM.

Important

🎗️ We obviously need to wait for wordpress-mobile/release-toolkit#585 to land first and update this PR's Gemfile to the new version before we can land this PR

# @example Running the lane
# bundle exec fastlane publish_release_and_cleanup skip_confirm:true
#
lane :publish_release_and_cleanup do |skip_confirm: 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 on the fence with the naming here.

On one hand I like the extra explicitness.
On the other hand, I like consistency, and our other apps (e.g. Tumblr iOS/Android and others) just call those lanes publish_release instead. And other lanes are not as descriptive in their names either (code_freeze, not code_freeze_then_trigger_new_beta 😅 )

So I'd say just call it publish_release instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I started with publish_release, but realized this would clash with release-toolkit's publish_release.

Another option is to rename the action on release-toolkit -- perhaps something like publish_gh_release (but then we'd lose some consistency points with the action create_release 🤷 )?

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh I see. Interesting.

Given some apps already use the name publish_release for their lanes, I'd have for us having to rename the lanes (and thus potentially update the ReleaseV2 scenarios accordingly for some of those?) when we adopt the new release-toolkit just because of the name clash.

So despite the inconsistency it'd introduce with create_release, I think I'd prefer for us to go with the action being renamed publish_gh_release in release-toolkit.

And actually, we could then take the occasion to rename create_release to create_gh_release (and potentially making create_release a deprecated alias for it, similar to how we did it when we renamed setbranchprotection to set_branch_protection in 9.4.0 before removing those backwards-compatibility-aliases in 10.0)?

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.

And actually, we could then take the occasion to rename create_release to create_gh_release (and potentially making create_release a deprecated alias for it)

Great idea! Implemented on eb321aab9ef2a7e5c2116d5a1d4355fb625938ad

Copy link
Contributor

Choose a reason for hiding this comment

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

Great idea! Implemented on eb321aab9ef2a7e5c2116d5a1d4355fb625938ad

Glad to see this eventually became _github_ over _gh_. Clarity++ 👨‍🍳 💋

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@AliSoftware @mokagio I've updated the PR after the release of release-toolkit 12.0.0.

Copy link
Contributor

@mokagio mokagio left a comment

Choose a reason for hiding this comment

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

Looking good. Only nitpicks. Approving to unblock.

.buildkite/release-pipelines/publish-release.yml Outdated Show resolved Hide resolved
- If the release branch for the next version `#{next_release_branch}` already exists, backmerge `#{current_branch}` into it
- If needed, backmerge `#{current_branch}` back into `#{DEFAULT_BRANCH}`
- Delete the `#{current_branch}` branch
PROMPT
Copy link
Contributor

Choose a reason for hiding this comment

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

I like PROMPT as the heredoc demarkation here 😄

fastlane/Fastfile Show resolved Hide resolved

create_backmerge_pr

# Now that an eventual backmerge PR has created an intermediate branch, we can delete the `release/*` branch
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 not sure I understand the "eventual" adjective here. It makes me think that the backmerge PR may or may not have been opened depending some factors, but looking at the code it seems that we'll always attempt it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, the comment is referring to a hotfix/new version backmerge (which indeed might not happen if those don't exist), but indeed maybe it's better to clarify it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Our create_release_backmerge_pull_request action skips creating a backmerge PR if the diff is empty (or more precisely if the HEAD and BASE are pointing to the same commit). So in theory it could happen that there's no backmerge PR created when you call create_release_backmerge_pull_request

In practice, we mostly call this action after having at least bumped the version file, which means there will always be a diff in those cases and thus a PR being created.

The only case I could think where this is not necessarily true is when we call create_release_backmerge_pull_request during publish_release (after the build has been approved by Google and we start rollout)

  • In most cases, at the time we publish_release on Mondays, there's nothing to backmerge again. The release/N branch has already been backmerged into trunk during finalize_release on Friday (after having done the final version bump and triggered the final build that was submitted for review) before the code freeze creating release/N+1. So at the time of publish_release, there's nothing new to backmerge and no PR to create
  • But in the rare case when we made new commits to release/N after code-freeze happened—e.g. the build was rejected by Google and we needed to do a fix in release/N on Monday and submit a new build for version N to address it—then we need to make sure that last-minute fix from release/N is propagated to release/N+1, and in such case the backmerge PR won't be empty and calling create_release_backmerge_pull_request at that state will create a PR.

So, yes, in 95% of cases create_release_backmerge_pull_request will create a backmerge PR. But in cases when we call it during publish_release on Monday while there hasn't been any new commit on release/N since finalize_release the Friday before, it should be smart enough to detect that the PR would be empty (as backmerge from Friday was already done and merged) and not create one at all in that case.

To be completely honest I'm not 100% sure our logic with point_to_same_commit? works as expected for the use case I mentioned above (because the commit from release/N would not be the same as the head commit from the target branch as the merge commit from previous backmerge PR would have happened in-between and that one would have a different SHA…?). But at least that was the initial intent (and even if it doesn't detect those cases as initially intended, if we manage to make create_release_backmerge_pull_request smarter in the future, it might avoid those unnecessary backmerge PRs when one has already happened and no new commit has landed in the source branch since)

@dangermattic
Copy link
Collaborator

dangermattic commented Sep 4, 2024

1 Warning
⚠️ This PR is assigned to the milestone 20.3. This milestone is due in less than 2 days.
Please make sure to get it merged by then or assign it to a milestone with a later deadline.

Generated by 🚫 Danger

fastlane/Fastfile Outdated Show resolved Hide resolved
fastlane/Fastfile Outdated Show resolved Hide resolved
fastlane/Fastfile Outdated Show resolved Hide resolved
@iangmaia iangmaia force-pushed the iangmaia/automate-release-publishing branch from b05b0ba to 1a148b2 Compare September 4, 2024 12:33
@iangmaia
Copy link
Contributor Author

iangmaia commented Sep 4, 2024

Note: I've added the commit dd12a80 using the new action name for creating a release, create_github_release.

@mokagio mokagio added status: do not merge Dependent on another PR, ready for review but not ready for merge. and removed status: do not merge Dependent on another PR, ready for review but not ready for merge. labels Sep 5, 2024
@mokagio
Copy link
Contributor

mokagio commented Sep 5, 2024

For the record, I toggled status: do not merge to verify the related Danger integration work and close a related request pdnsEh-1fv-p2

Copy link
Contributor

@mokagio mokagio left a comment

Choose a reason for hiding this comment

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

Only a nitpick on the wording of the header doc

fastlane/Fastfile Outdated Show resolved Hide resolved
fastlane/Fastfile Outdated Show resolved Hide resolved
fastlane/Fastfile Outdated Show resolved Hide resolved
@iangmaia iangmaia force-pushed the iangmaia/automate-release-publishing branch from 2c35992 to 8b9c160 Compare September 5, 2024 14:34
@iangmaia iangmaia merged commit a915400 into trunk Sep 5, 2024
14 checks passed
@iangmaia iangmaia deleted the iangmaia/automate-release-publishing branch September 5, 2024 19:21
mokagio added a commit to Automattic/simplenote-android that referenced this pull request Sep 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: tooling Anything that involves building & maintaining the project, including scripts, `Fastfile`, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants