diff --git a/.buildkite/code-freeze.yml b/.buildkite/code-freeze.yml index 64ffda7c178a..f6b1f5469b64 100644 --- a/.buildkite/code-freeze.yml +++ b/.buildkite/code-freeze.yml @@ -1,7 +1,6 @@ # yaml-language-server: $schema=https://raw.githubusercontent.com/buildkite/pipeline-schema/main/schema.json --- - steps: - label: "Code Freeze" plugins: [$CI_TOOLKIT] diff --git a/.buildkite/commands/checkout-release-branch.sh b/.buildkite/commands/checkout-release-branch.sh index 2f6fb8302590..7b6881194cf7 100755 --- a/.buildkite/commands/checkout-release-branch.sh +++ b/.buildkite/commands/checkout-release-branch.sh @@ -1,7 +1,6 @@ #!/bin/bash -eu -# RELEASE_VERSION is passed as an environment variable from fastlane to Buildkite -# +# RELEASE_VERSION is passed as an environment variable passed to Buildkite by ReleasesV2. if [[ -z "${RELEASE_VERSION}" ]]; then echo "RELEASE_VERSION is not set." exit 1 diff --git a/.buildkite/complete-code-freeze.yml b/.buildkite/complete-code-freeze.yml index 977955def01f..aea9b8822055 100644 --- a/.buildkite/complete-code-freeze.yml +++ b/.buildkite/complete-code-freeze.yml @@ -1,7 +1,6 @@ # yaml-language-server: $schema=https://raw.githubusercontent.com/buildkite/pipeline-schema/main/schema.json --- - steps: - label: "Complete Code Freeze" plugins: [$CI_TOOLKIT] diff --git a/.buildkite/finalize-release.yml b/.buildkite/finalize-release.yml index b1674fe5176c..4253bd97c27f 100644 --- a/.buildkite/finalize-release.yml +++ b/.buildkite/finalize-release.yml @@ -1,7 +1,6 @@ # yaml-language-server: $schema=https://raw.githubusercontent.com/buildkite/pipeline-schema/main/schema.json --- - steps: - label: "Finalize release" plugins: [$CI_TOOLKIT] diff --git a/.buildkite/new-beta-release.yml b/.buildkite/new-beta-release.yml index dbc272ed3c20..6e8513f57f53 100644 --- a/.buildkite/new-beta-release.yml +++ b/.buildkite/new-beta-release.yml @@ -1,7 +1,6 @@ # yaml-language-server: $schema=https://raw.githubusercontent.com/buildkite/pipeline-schema/main/schema.json --- - steps: - label: "New Beta Release" plugins: [$CI_TOOLKIT] diff --git a/.buildkite/publish-release.yml b/.buildkite/publish-release.yml new file mode 100644 index 000000000000..72b96d7ff4a1 --- /dev/null +++ b/.buildkite/publish-release.yml @@ -0,0 +1,24 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/buildkite/pipeline-schema/main/schema.json +--- + +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 diff --git a/fastlane/lanes/release.rb b/fastlane/lanes/release.rb index a1ed889e999d..080ee57d20ec 100644 --- a/fastlane/lanes/release.rb +++ b/fastlane/lanes/release.rb @@ -331,6 +331,47 @@ end end + # This lane publishes a release on GitHub and creates a PR to backmerge 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(branch: '^release/') + + version_number = current_release_version + + current_branch = "release/#{version_number}" + next_release_branch = "release/#{next_release_version}" + + 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_translations_coverage do |options| UI.message('Checking WordPress app strings translation status...') check_translation_progress( @@ -559,6 +600,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}