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 #13791

Merged
merged 7 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .buildkite/release-pipelines/publish-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
steps:
- label: "Publish Release"
plugins:
- $CI_TOOLKIT
command: |
echo '--- :robot_face: Use bot for git operations'
source use-bot-for-git

echo '--- :git: Checkout Release Branch'
.buildkite/commands/checkout-release-branch.sh

echo '--- :ruby: Setup Ruby Tools'
install_gems

echo '--- :package: Publish Release'
bundle exec fastlane publish_release skip_confirm:true
agents:
queue: "tumblr-metal"
retry:
manual:
# If those jobs fail, one should always prefer re-triggering a new build from ReleaseV2 rather than retrying the individual job from Buildkite
allowed: false
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ gem 'fastlane-plugin-sentry', '~> 1.0'
# This comment avoids typing to switch to a development version for testing.
#
# gem 'fastlane-plugin-wpmreleasetoolkit', git: '[email protected]:wordpress-mobile/release-toolkit', branch: ''
gem 'fastlane-plugin-wpmreleasetoolkit', '~> 11.0'
gem 'fastlane-plugin-wpmreleasetoolkit', '~> 12.0'
gem 'rake', '~> 12.3'
gem 'rubocop', '~> 1.60'
gem 'rubocop', '~> 1.65'
gem 'rubocop-rake', '~> 0.6'
gem 'xcode-install'
gem 'xcpretty-travis-formatter'
Expand Down
8 changes: 4 additions & 4 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ GEM
fastlane-plugin-appcenter (2.1.2)
fastlane-plugin-sentry (1.24.0)
os (~> 1.1, >= 1.1.4)
fastlane-plugin-wpmreleasetoolkit (11.1.0)
fastlane-plugin-wpmreleasetoolkit (12.0.0)
activesupport (>= 6.1.7.1)
buildkit (~> 1.5)
chroma (= 0.2.0)
Expand All @@ -216,7 +216,7 @@ GEM
git (~> 1.3)
google-cloud-storage (~> 1.31)
java-properties (~> 0.3.0)
nokogiri (~> 1.11, < 1.17)
nokogiri (~> 1.11)
octokit (~> 6.1)
parallel (~> 1.14)
plist (~> 3.1)
Expand Down Expand Up @@ -410,10 +410,10 @@ DEPENDENCIES
fastlane (~> 2.217)
fastlane-plugin-appcenter (~> 2.0)
fastlane-plugin-sentry (~> 1.0)
fastlane-plugin-wpmreleasetoolkit (~> 11.0)
fastlane-plugin-wpmreleasetoolkit (~> 12.0)
rake (~> 12.3)
rmagick (~> 4.1)
rubocop (~> 1.60)
rubocop (~> 1.65)
rubocop-rake (~> 0.6)
xcode-install
xcpretty-travis-formatter
Expand Down
56 changes: 55 additions & 1 deletion fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,47 @@ platform :ios do
end
end

# This lane publishes a release on GitHub, tagging it on git, and backmerges the current release branch into the next release/ branch
#
# @param [Boolean] skip_confirm (default: false) If set, will skip the confirmation prompt before running the rest of the lane
#
# @example Running the lane
# bundle exec fastlane publish_release skip_confirm:true
#
lane :publish_release do |skip_confirm: false|
ensure_git_status_clean
ensure_git_branch_is_release_branch

version_number = release_version_current

current_branch = "release/#{version_number}"
next_release_branch = "release/#{release_version_next}"

UI.important <<~PROMPT
Publish the #{version_number} release. This will:
- Publish the existing draft `#{version_number}` 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 `#{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
UI.user_error!("Terminating as requested. Don't forget to run the remainder of this automation manually.") unless skip_confirm || UI.confirm('Do you want to continue?')

UI.important "Publishing release #{version_number} on GitHub"

publish_github_release(
repository: GITHUB_REPO,
name: version_number
)

create_backmerge_pr

# At this point, an intermediate branch has been created by creating a backmerge PR to a hotfix or the next version release branch.
# This allows us to safely delete the `release/*` branch.
# Note that if a hotfix or new release branches haven't been created, the backmerge PR won't be created as well.
delete_remote_git_branch!(current_branch)
end

lane :check_translation_progress_all do
check_translation_progress_strings
check_translation_progress_release_notes
Expand Down Expand Up @@ -1451,7 +1492,12 @@ def create_backmerge_pr
)
rescue StandardError => e
error_message = <<-MESSAGE
Error creating backmerge pull request: #{e.message}
Error creating backmerge pull request:

```
#{e.message}
```

If this is not the first time you are running the release task, the backmerge PR for the version `#{version}` might have already been previously created.
Please close any previous backmerge PR for `#{version}`, delete the previous merge branch, then run the release task again.
MESSAGE
Expand All @@ -1477,6 +1523,14 @@ def ensure_branch_does_not_exist!(branch_name)
UI.user_error!(error_message)
end

# Delete a branch remotely, after having removed any GitHub branch protection
#
def delete_remote_git_branch!(branch_name)
remove_branch_protection(repository: GITHUB_REPO, branch: branch_name)

Git.open(Dir.pwd).push('origin', branch_name, delete: true)
end

def report_milestone_error(error_title:)
error_message = <<-MESSAGE
#{error_title}
Expand Down