From f34ed3687becc250a01951f79f3ffed62ef57b3b Mon Sep 17 00:00:00 2001 From: Oguz Kocer Date: Thu, 4 May 2023 22:59:53 -0400 Subject: [PATCH 01/16] Adds release management Buildkite pipelines --- .buildkite/beta-builds.yml | 2 +- .buildkite/code-freeze.yml | 15 +++++++++++++ .../commands/checkout-editorial-branch.sh | 22 +++++++++++++++++++ .../commands/checkout-release-branch.sh | 14 ++++++++++++ .../configure-git-for-release-management.sh | 7 ++++++ .buildkite/complete-code-freeze.yml | 16 ++++++++++++++ .buildkite/finalize-release.yml | 16 ++++++++++++++ .buildkite/new-beta-release.yml | 15 +++++++++++++ .buildkite/pipeline.yml | 2 +- .buildkite/release-builds.yml | 2 +- .buildkite/update-release-notes.yml | 16 ++++++++++++++ 11 files changed, 124 insertions(+), 3 deletions(-) create mode 100644 .buildkite/code-freeze.yml create mode 100755 .buildkite/commands/checkout-editorial-branch.sh create mode 100755 .buildkite/commands/checkout-release-branch.sh create mode 100755 .buildkite/commands/configure-git-for-release-management.sh create mode 100644 .buildkite/complete-code-freeze.yml create mode 100644 .buildkite/finalize-release.yml create mode 100644 .buildkite/new-beta-release.yml create mode 100644 .buildkite/update-release-notes.yml diff --git a/.buildkite/beta-builds.yml b/.buildkite/beta-builds.yml index 556fb4dfb1bc..b58ecc63269e 100644 --- a/.buildkite/beta-builds.yml +++ b/.buildkite/beta-builds.yml @@ -5,7 +5,7 @@ common_params: # Common plugin settings to use with the `plugins` key. - &common_plugins - - automattic/a8c-ci-toolkit#2.15.0 + - automattic/a8c-ci-toolkit#2.15.1 steps: ################# diff --git a/.buildkite/code-freeze.yml b/.buildkite/code-freeze.yml new file mode 100644 index 000000000000..004369d3b578 --- /dev/null +++ b/.buildkite/code-freeze.yml @@ -0,0 +1,15 @@ +# Nodes with values to reuse in the pipeline. +common_params: + # Common plugin settings to use with the `plugins` key. + - &common_plugins + - automattic/a8c-ci-toolkit#2.15.1 + +steps: + - label: "Code Freeze" + plugins: *common_plugins + command: | + .buildkite/commands/configure-git-for-release-management.sh + + install_gems + + bundle exec fastlane code_freeze skip_confirm:true diff --git a/.buildkite/commands/checkout-editorial-branch.sh b/.buildkite/commands/checkout-editorial-branch.sh new file mode 100755 index 000000000000..f495193ae32f --- /dev/null +++ b/.buildkite/commands/checkout-editorial-branch.sh @@ -0,0 +1,22 @@ +#!/bin/bash -eu + +# EDITORIAL_BRANCH is passed as an environment variable from fastlane to Buildkite +# +if [[ -z "${EDITORIAL_BRANCH}" ]]; then + echo "EDITORIAL_BRANCH is not set." + exit 1 +fi + +# RELEASE_VERSION is passed as an environment variable from fastlane to Buildkite +# Even though RELEASE_VERSION is not directly used in this script, it's necessary to update +# the app store strings. Having this check here keeps the buildkite pipeline cleaner. Later on, +# if we don't want it here, we can move it to a separate script file. +if [[ -z "${RELEASE_VERSION}" ]]; then + echo "RELEASE_VERSION is not set." + exit 1 +fi + +# Buildkite, by default, checks out a specific commit. When we update the app store strings, we open +# a PR from the current branch. So, we need to checkout the `EDITORIAL_BRANCH`. +git fetch origin "$EDITORIAL_BRANCH" +git checkout "$EDITORIAL_BRANCH" diff --git a/.buildkite/commands/checkout-release-branch.sh b/.buildkite/commands/checkout-release-branch.sh new file mode 100755 index 000000000000..2f6fb8302590 --- /dev/null +++ b/.buildkite/commands/checkout-release-branch.sh @@ -0,0 +1,14 @@ +#!/bin/bash -eu + +# RELEASE_VERSION is passed as an environment variable from fastlane to Buildkite +# +if [[ -z "${RELEASE_VERSION}" ]]; then + echo "RELEASE_VERSION is not set." + exit 1 +fi + +# Buildkite, by default, checks out a specific commit. For many release actions, we need to be +# on a release branch instead. +BRANCH_NAME="release/${RELEASE_VERSION}" +git fetch origin "$BRANCH_NAME" +git checkout "$BRANCH_NAME" diff --git a/.buildkite/commands/configure-git-for-release-management.sh b/.buildkite/commands/configure-git-for-release-management.sh new file mode 100755 index 000000000000..9e07a6100b67 --- /dev/null +++ b/.buildkite/commands/configure-git-for-release-management.sh @@ -0,0 +1,7 @@ +#!/bin/bash -eu + +# Git command line client is not configured in Buildkite. Temporarily, we configure it in each step. +# Later on, we should be able to configure the agent instead. +curl -L https://api.github.com/meta | jq -r '.ssh_keys | .[]' | sed -e 's/^/github.com /' >> ~/.ssh/known_hosts +git config --global user.email "mobile+wpmobilebot@automattic.com" +git config --global user.name "Buildkite" diff --git a/.buildkite/complete-code-freeze.yml b/.buildkite/complete-code-freeze.yml new file mode 100644 index 000000000000..6c913fd783ad --- /dev/null +++ b/.buildkite/complete-code-freeze.yml @@ -0,0 +1,16 @@ +# Nodes with values to reuse in the pipeline. +common_params: + # Common plugin settings to use with the `plugins` key. + - &common_plugins + - automattic/a8c-ci-toolkit#2.15.1 + +steps: + - label: "Complete Code Freeze" + plugins: *common_plugins + command: | + .buildkite/commands/configure-git-for-release-management.sh + .buildkite/commands/checkout-release-branch.sh + + install_gems + + bundle exec fastlane complete_code_freeze skip_confirm:true diff --git a/.buildkite/finalize-release.yml b/.buildkite/finalize-release.yml new file mode 100644 index 000000000000..049580502b3c --- /dev/null +++ b/.buildkite/finalize-release.yml @@ -0,0 +1,16 @@ +# Nodes with values to reuse in the pipeline. +common_params: + # Common plugin settings to use with the `plugins` key. + - &common_plugins + - automattic/a8c-ci-toolkit#2.15.1 + +steps: + - label: "Finalize release" + plugins: *common_plugins + command: | + .buildkite/commands/configure-git-for-release-management.sh + .buildkite/commands/checkout-release-branch.sh + + install_gems + + bundle exec fastlane finalize_release skip_confirm:true diff --git a/.buildkite/new-beta-release.yml b/.buildkite/new-beta-release.yml new file mode 100644 index 000000000000..55cd764b2c7a --- /dev/null +++ b/.buildkite/new-beta-release.yml @@ -0,0 +1,15 @@ +# Nodes with values to reuse in the pipeline. +common_params: + # Common plugin settings to use with the `plugins` key. + - &common_plugins + - automattic/a8c-ci-toolkit#2.15.1 + +steps: + - label: "New Beta Release" + plugins: *common_plugins + command: | + .buildkite/commands/configure-git-for-release-management.sh + + install_gems + + bundle exec fastlane new_beta_release skip_confirm:true diff --git a/.buildkite/pipeline.yml b/.buildkite/pipeline.yml index 1aa998530d8b..043759063514 100644 --- a/.buildkite/pipeline.yml +++ b/.buildkite/pipeline.yml @@ -2,7 +2,7 @@ common_params: # Common plugin settings to use with the `plugins` key. - &common_plugins - - automattic/a8c-ci-toolkit#2.14.0 + - automattic/a8c-ci-toolkit#2.15.1 steps: ################# diff --git a/.buildkite/release-builds.yml b/.buildkite/release-builds.yml index a19960ace524..762426dd12f1 100644 --- a/.buildkite/release-builds.yml +++ b/.buildkite/release-builds.yml @@ -5,7 +5,7 @@ common_params: # Common plugin settings to use with the `plugins` key. - &common_plugins - - automattic/a8c-ci-toolkit#2.14.0 + - automattic/a8c-ci-toolkit#2.15.1 steps: ################# diff --git a/.buildkite/update-release-notes.yml b/.buildkite/update-release-notes.yml new file mode 100644 index 000000000000..b26efbc24886 --- /dev/null +++ b/.buildkite/update-release-notes.yml @@ -0,0 +1,16 @@ +# Nodes with values to reuse in the pipeline. +common_params: + # Common plugin settings to use with the `plugins` key. + - &common_plugins + - automattic/a8c-ci-toolkit#2.15.1 + +steps: + - label: "Update release notes" + plugins: *common_plugins + command: | + .buildkite/commands/configure-git-for-release-management.sh + .buildkite/commands/checkout-editorial-branch.sh + + install_gems + + bundle exec fastlane update_appstore_strings version:${RELEASE_VERSION} From b656d9f1549b17614c67b98096d2ad318879b8a7 Mon Sep 17 00:00:00 2001 From: Oguz Kocer Date: Thu, 4 May 2023 23:31:04 -0400 Subject: [PATCH 02/16] Adds Buildkite triggers to release_management_in_ci lanes --- fastlane/lanes/release_management_in_ci.rb | 64 ++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 fastlane/lanes/release_management_in_ci.rb diff --git a/fastlane/lanes/release_management_in_ci.rb b/fastlane/lanes/release_management_in_ci.rb new file mode 100644 index 000000000000..60228785b572 --- /dev/null +++ b/fastlane/lanes/release_management_in_ci.rb @@ -0,0 +1,64 @@ +BUILDKITE_ORGANIZATION = 'automattic'.freeze +BUILDKITE_PIPELINE = 'wordpress-android'.freeze +platform :android do + ##################################################################################### + # Triggers for Buildkite + ##################################################################################### + lane :trigger_code_freeze_in_ci do |options| + buildkite_trigger_build( + buildkite_organization: BUILDKITE_ORGANIZATION, + buildkite_pipeline: BUILDKITE_PIPELINE, + branch: 'trunk', + pipeline_file: 'code-freeze.yml', + message: 'Code Freeze in CI' + ) + end + + lane :trigger_complete_code_freeze_in_ci do |options| + release_version = options[:release_version] + buildkite_trigger_build( + buildkite_organization: BUILDKITE_ORGANIZATION, + buildkite_pipeline: BUILDKITE_PIPELINE, + branch: "release/#{release_version}", + pipeline_file: 'complete-code-freeze.yml', + message: 'Complete Code Freeze in CI', + environment: { RELEASE_VERSION: release_version } + ) + end + + lane :trigger_finalize_release_in_ci do |options| + release_version = options[:release_version] + buildkite_trigger_build( + buildkite_organization: BUILDKITE_ORGANIZATION, + buildkite_pipeline: BUILDKITE_PIPELINE, + branch: "release/#{release_version}", + pipeline_file: 'finalize-release.yml', + message: 'Finalize release', + environment: { RELEASE_VERSION: release_version } + ) + end + + lane :trigger_new_beta_release_in_ci do |options| + release_version = options[:release_version] + buildkite_trigger_build( + buildkite_organization: BUILDKITE_ORGANIZATION, + buildkite_pipeline: BUILDKITE_PIPELINE, + branch: "release/#{release_version}", + pipeline_file: 'new-beta-release.yml', + message: 'New beta release', + environment: { RELEASE_VERSION: release_version } + ) + end + + lane :trigger_update_appstore_strings_in_ci do |options| + release_version = options[:release_version] + editorial_branch = options[:editorial_branch] + buildkite_trigger_build( + buildkite_organization: BUILDKITE_ORGANIZATION, + buildkite_pipeline: BUILDKITE_PIPELINE, + branch: "#{editorial_branch}", + pipeline_file: 'update-release-notes.yml', + message: 'Update release notes', + environment: { RELEASE_VERSION: release_version, EDITORIAL_BRANCH: editorial_branch } + ) +end From 0e6a276b13bd1a959dc98d0c73c269646a4ff4d6 Mon Sep 17 00:00:00 2001 From: Oguz Kocer Date: Thu, 4 May 2023 23:34:33 -0400 Subject: [PATCH 03/16] Create pull request after complete code freeze --- fastlane/lanes/release.rb | 2 ++ fastlane/lanes/release_management_in_ci.rb | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/fastlane/lanes/release.rb b/fastlane/lanes/release.rb index 0c436955b952..a42575b478ca 100644 --- a/fastlane/lanes/release.rb +++ b/fastlane/lanes/release.rb @@ -64,6 +64,8 @@ new_version = android_get_app_version() trigger_beta_build(branch_to_build: "release/#{new_version}") + + create_release_management_pull_request('trunk', "Merge #{new_version} code freeze to trunk") end ##################################################################################### diff --git a/fastlane/lanes/release_management_in_ci.rb b/fastlane/lanes/release_management_in_ci.rb index 60228785b572..e5fb6ed4d1ae 100644 --- a/fastlane/lanes/release_management_in_ci.rb +++ b/fastlane/lanes/release_management_in_ci.rb @@ -61,4 +61,18 @@ message: 'Update release notes', environment: { RELEASE_VERSION: release_version, EDITORIAL_BRANCH: editorial_branch } ) + + ##################################################################################### + # Release Management Utils + ##################################################################################### + def create_release_management_pull_request(base_branch, title) + create_pull_request( + api_token: ENV['GITHUB_TOKEN'], + repo: GHHELPER_REPO, + title: title, + head: Fastlane::Helper::GitHelper.current_git_branch, + base: base_branch, + labels: 'Releases' + ) + end end From 1fad391a9a6aad721c9d4be208d5282b5414fbec Mon Sep 17 00:00:00 2001 From: Oguz Kocer Date: Thu, 4 May 2023 23:39:12 -0400 Subject: [PATCH 04/16] Adds support for handling new_beta_release in CI --- fastlane/lanes/release.rb | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/fastlane/lanes/release.rb b/fastlane/lanes/release.rb index a42575b478ca..f137aaff0434 100644 --- a/fastlane/lanes/release.rb +++ b/fastlane/lanes/release.rb @@ -90,10 +90,17 @@ update_frozen_strings_for_translation download_translations() android_bump_version_beta() - next unless UI.confirm('Ready for CI build') - new_version = android_get_app_version() - trigger_beta_build(branch_to_build: "release/#{new_version}") + app_version = android_get_app_version() + release_branch = "release/#{app_version}" + release_version = android_get_release_version()["name"] + + # Create an intermediate branch + new_beta_branch_name = "new_beta/#{release_version}" + Fastlane::Helper::GitHelper.create_branch(new_beta_branch_name) + trigger_beta_build(branch_to_build: intermediate_branch_name) + + create_release_management_pull_request(release_branch, "Merge #{release_version} to #{release_branch}") end ##################################################################################### From 904842ea0b42adf62006b57ea92d57d7054d800c Mon Sep 17 00:00:00 2001 From: Oguz Kocer Date: Mon, 8 May 2023 21:12:21 -0400 Subject: [PATCH 05/16] Adds support for handling finalize_release in CI --- fastlane/lanes/release.rb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/fastlane/lanes/release.rb b/fastlane/lanes/release.rb index f137aaff0434..f81585ff68ed 100644 --- a/fastlane/lanes/release.rb +++ b/fastlane/lanes/release.rb @@ -157,6 +157,12 @@ android_finalize_prechecks(skip_confirm: options[:skip_confirm]) configure_apply(force: is_ci) + app_version = android_get_app_version() + release_branch = "release/#{app_version}" + + # Remove branch protection first, so that we can push the final commits directly to the release branch + removebranchprotection(repository: GHHELPER_REPO, branch: release_branch) + check_translations_coverage() download_translations() @@ -164,14 +170,17 @@ version = android_get_release_version() download_metadata_strings(version: version['name'], build_number: version['code']) + push_to_git_remote(tags: false) + # Wrap up - removebranchprotection(repository: GHHELPER_REPO, branch: "release/#{version['name']}") setfrozentag(repository: GHHELPER_REPO, milestone: version['name'], freeze: false) create_new_milestone(repository: GHHELPER_REPO) close_milestone(repository: GHHELPER_REPO, milestone: version['name']) # Trigger release build trigger_release_build(branch_to_build: "release/#{version['name']}") + + create_release_management_pull_request('trunk', "Merge #{app_version} final to trunk") end lane :check_translations_coverage do |options| From 647d6ff0c51ca5b95ee552f5b6c88603f723feae Mon Sep 17 00:00:00 2001 From: Oguz Kocer Date: Wed, 10 May 2023 15:11:07 -0400 Subject: [PATCH 06/16] Use remove/git-push-actions release-toolkit branch --- Gemfile | 4 +-- Gemfile.lock | 72 ++++++++++++++++++++++++++++------------------------ 2 files changed, 41 insertions(+), 35 deletions(-) diff --git a/Gemfile b/Gemfile index c9787fdbf99b..220ed57adab6 100644 --- a/Gemfile +++ b/Gemfile @@ -7,9 +7,9 @@ gem 'nokogiri' ### Fastlane Plugins -gem 'fastlane-plugin-wpmreleasetoolkit', '~> 7.0' +#gem 'fastlane-plugin-wpmreleasetoolkit', '~> 7.0' # gem 'fastlane-plugin-wpmreleasetoolkit', path: '../../release-toolkit' -# gem 'fastlane-plugin-wpmreleasetoolkit', git: 'https://github.com/wordpress-mobile/release-toolkit', branch: 'trunk' +gem 'fastlane-plugin-wpmreleasetoolkit', git: 'https://github.com/wordpress-mobile/release-toolkit', branch: 'remove/git-push-actions' ### Gems needed only for generating Promo Screenshots diff --git a/Gemfile.lock b/Gemfile.lock index 06201cb383f9..9a5623ef5b67 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,28 +1,49 @@ +GIT + remote: https://github.com/wordpress-mobile/release-toolkit + revision: e26197f430a919e4d33bce7c69778870ca9e45af + branch: remove/git-push-actions + specs: + fastlane-plugin-wpmreleasetoolkit (7.0.0) + activesupport (>= 6.1.7.1) + bigdecimal (~> 1.4) + buildkit (~> 1.5) + chroma (= 0.2.0) + diffy (~> 3.3) + git (~> 1.3) + google-cloud-storage (~> 1.31) + nokogiri (~> 1.11) + octokit (~> 5.6) + parallel (~> 1.14) + plist (~> 3.1) + progress_bar (~> 1.3) + rake (>= 12.3, < 14.0) + rake-compiler (~> 1.0) + GEM remote: https://rubygems.org/ specs: CFPropertyList (3.0.6) rexml - activesupport (7.0.4.2) + activesupport (7.0.4.3) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) tzinfo (~> 2.0) - addressable (2.8.1) + addressable (2.8.4) public_suffix (>= 2.0.2, < 6.0) artifactory (3.0.15) atomos (0.1.3) aws-eventstream (1.2.0) - aws-partitions (1.721.0) - aws-sdk-core (3.170.0) + aws-partitions (1.762.0) + aws-sdk-core (3.172.0) aws-eventstream (~> 1, >= 1.0.2) aws-partitions (~> 1, >= 1.651.0) aws-sigv4 (~> 1.5) jmespath (~> 1, >= 1.6.1) - aws-sdk-kms (1.63.0) + aws-sdk-kms (1.64.0) aws-sdk-core (~> 3, >= 3.165.0) aws-sigv4 (~> 1.1) - aws-sdk-s3 (1.119.1) + aws-sdk-s3 (1.122.0) aws-sdk-core (~> 3, >= 3.165.0) aws-sdk-kms (~> 1) aws-sigv4 (~> 1.4) @@ -38,7 +59,7 @@ GEM colored2 (3.1.2) commander (4.6.0) highline (~> 2.0.0) - concurrent-ruby (1.2.0) + concurrent-ruby (1.2.2) declarative (0.0.20) diffy (3.4.2) digest-crc (0.6.4) @@ -77,7 +98,7 @@ GEM faraday_middleware (1.2.0) faraday (~> 1.0) fastimage (2.2.6) - fastlane (2.212.1) + fastlane (2.212.2) CFPropertyList (>= 2.3, < 4.0.0) addressable (>= 2.8, < 3.0.0) artifactory (~> 3.0) @@ -116,26 +137,11 @@ GEM xcodeproj (>= 1.13.0, < 2.0.0) xcpretty (~> 0.3.0) xcpretty-travis-formatter (>= 0.0.3) - fastlane-plugin-wpmreleasetoolkit (7.0.0) - activesupport (>= 6.1.7.1) - bigdecimal (~> 1.4) - buildkit (~> 1.5) - chroma (= 0.2.0) - diffy (~> 3.3) - git (~> 1.3) - google-cloud-storage (~> 1.31) - nokogiri (~> 1.11) - octokit (~> 4.18) - parallel (~> 1.14) - plist (~> 3.1) - progress_bar (~> 1.3) - rake (>= 12.3, < 14.0) - rake-compiler (~> 1.0) gh_inspector (1.1.3) - git (1.13.2) + git (1.18.0) addressable (~> 2.8) rchardet (~> 1.8) - google-apis-androidpublisher_v3 (0.35.0) + google-apis-androidpublisher_v3 (0.41.0) google-apis-core (>= 0.11.0, < 2.a) google-apis-core (0.11.0) addressable (~> 2.5, >= 2.5.1) @@ -166,7 +172,7 @@ GEM google-cloud-core (~> 1.6) googleauth (>= 0.16.2, < 2.a) mini_mime (~> 1.0) - googleauth (1.3.0) + googleauth (1.5.2) faraday (>= 0.17.3, < 3.a) jwt (>= 1.4, < 3.0) memoist (~> 0.16) @@ -177,7 +183,7 @@ GEM http-cookie (1.0.5) domain_name (~> 0.5) httpclient (2.8.3) - i18n (1.12.0) + i18n (1.13.0) concurrent-ruby (~> 1.0) jmespath (1.6.2) json (2.6.3) @@ -185,22 +191,22 @@ GEM memoist (0.16.2) mini_magick (4.12.0) mini_mime (1.1.2) - mini_portile2 (2.8.1) - minitest (5.17.0) + mini_portile2 (2.8.2) + minitest (5.18.0) multi_json (1.15.0) multipart-post (2.0.0) nanaimo (0.3.0) naturally (2.2.1) - nokogiri (1.14.2) + nokogiri (1.14.3) mini_portile2 (~> 2.8.0) racc (~> 1.4) - octokit (4.25.1) + octokit (5.6.1) faraday (>= 1, < 3) sawyer (~> 0.9) options (2.3.2) optparse (0.1.1) os (1.1.4) - parallel (1.22.1) + parallel (1.23.0) plist (3.7.0) progress_bar (1.3.3) highline (>= 1.6, < 3) @@ -267,7 +273,7 @@ PLATFORMS DEPENDENCIES fastlane (~> 2) - fastlane-plugin-wpmreleasetoolkit (~> 7.0) + fastlane-plugin-wpmreleasetoolkit! nokogiri rmagick (~> 4.1) From ba8c70b304f0ecfb21f8b6baa5040ed9aca9c60e Mon Sep 17 00:00:00 2001 From: Oguz Kocer Date: Wed, 10 May 2023 15:19:01 -0400 Subject: [PATCH 07/16] Adds push_to_git_remote to release lanes --- fastlane/lanes/release.rb | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/fastlane/lanes/release.rb b/fastlane/lanes/release.rb index f81585ff68ed..d091621f221d 100644 --- a/fastlane/lanes/release.rb +++ b/fastlane/lanes/release.rb @@ -32,12 +32,14 @@ sh('git', 'commit', '-m', "Update draft release notes for Jetpack #{new_version}.") end cleanup_release_files(files: release_notes_short_paths) - android_update_release_notes(new_version: new_version) # Adds empty section for next version - setbranchprotection(repository: GHHELPER_REPO, branch: "release/#{new_version}") - setfrozentag(repository: GHHELPER_REPO, milestone: new_version) UI.message("Jetpack release notes were based on the same ones as WordPress. Don't forget to check #{release_notes_path('jetpack')} and amend them as necessary if any item does not apply for Jetpack before sending them to Editorial.") + + push_to_git_remote(tags: false) + + setbranchprotection(repository: GHHELPER_REPO, branch: "release/#{new_version}") + setfrozentag(repository: GHHELPER_REPO, milestone: new_version) end ##################################################################################### @@ -60,7 +62,7 @@ update_frozen_strings_for_translation ensure_git_status_clean - push_to_git_remote + push_to_git_remote(tags: false) new_version = android_get_app_version() trigger_beta_build(branch_to_build: "release/#{new_version}") @@ -98,7 +100,10 @@ # Create an intermediate branch new_beta_branch_name = "new_beta/#{release_version}" Fastlane::Helper::GitHelper.create_branch(new_beta_branch_name) - trigger_beta_build(branch_to_build: intermediate_branch_name) + + push_to_git_remote(tags: false) + + trigger_beta_build(branch_to_build: new_beta_branch_name) create_release_management_pull_request(release_branch, "Merge #{release_version} to #{release_branch}") end @@ -119,6 +124,7 @@ hotfix_version = options[:version_name] || UI.input('Version number for the new hotfix?') previous_tag = android_hotfix_prechecks(version_name: hotfix_version, skip_confirm: options[:skip_confirm]) android_bump_version_hotfix(previous_version_name: previous_tag, version_name: hotfix_version, version_code: options[:version_code]) + push_to_git_remote(tags: false) end ##################################################################################### From 686f0f6fd27a1384e919b75164fd4f4f09c82071 Mon Sep 17 00:00:00 2001 From: Oguz Kocer Date: Wed, 10 May 2023 16:43:29 -0400 Subject: [PATCH 08/16] Push changes to remote and open a pr after updating app store strings --- fastlane/lanes/localization.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fastlane/lanes/localization.rb b/fastlane/lanes/localization.rb index 71bd81738093..b321a07a3cc6 100644 --- a/fastlane/lanes/localization.rb +++ b/fastlane/lanes/localization.rb @@ -126,6 +126,11 @@ commit_message: "Update #{app_values[:display_name]} `PlayStoreStrings.po` for version #{version}" ) end + + push_to_git_remote(tags: false) + + release_branch = "release/#{version}" + create_release_management_pull_request(release_branch, "Merge #{version} editorialized release notes to #{release_branch}") end # Updates the metadata in the Play Store (Main store listing) from the content of `fastlane/{metadata|jetpack_metadata}/android/*/*.txt` files From 8ebf9818d77d65535d05f3494718fe43d54d2a4a Mon Sep 17 00:00:00 2001 From: Oguz Kocer Date: Wed, 10 May 2023 17:02:44 -0400 Subject: [PATCH 09/16] Adds the missing 'end' trigger_update_appstore_strings_in_ci lane --- fastlane/lanes/release_management_in_ci.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/fastlane/lanes/release_management_in_ci.rb b/fastlane/lanes/release_management_in_ci.rb index e5fb6ed4d1ae..2cd1b1bc1dec 100644 --- a/fastlane/lanes/release_management_in_ci.rb +++ b/fastlane/lanes/release_management_in_ci.rb @@ -61,6 +61,7 @@ message: 'Update release notes', environment: { RELEASE_VERSION: release_version, EDITORIAL_BRANCH: editorial_branch } ) + end ##################################################################################### # Release Management Utils From 08b6070df41ed892d933a23f60cd53047aed2e9f Mon Sep 17 00:00:00 2001 From: Oguz Kocer Date: Wed, 10 May 2023 17:16:22 -0400 Subject: [PATCH 10/16] Move create_release_management_pull_request to a new helper file --- fastlane/Fastfile | 1 + fastlane/helpers/github.rb | 10 ++++++++++ fastlane/lanes/release_management_in_ci.rb | 14 -------------- 3 files changed, 11 insertions(+), 14 deletions(-) create mode 100644 fastlane/helpers/github.rb diff --git a/fastlane/Fastfile b/fastlane/Fastfile index c887a763e4c4..6844347fbfbb 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -48,6 +48,7 @@ REPOSITORY_NAME = 'WordPress-Android' ######################################################################## # Import domain-specific lanes ######################################################################## +import 'helpers/github.rb' import 'lanes/build.rb' import 'lanes/localization.rb' import 'lanes/release.rb' diff --git a/fastlane/helpers/github.rb b/fastlane/helpers/github.rb new file mode 100644 index 000000000000..df5bc2fe175e --- /dev/null +++ b/fastlane/helpers/github.rb @@ -0,0 +1,10 @@ +def create_release_management_pull_request(base_branch, title) + create_pull_request( + api_token: ENV['GITHUB_TOKEN'], + repo: GHHELPER_REPO, + title: title, + head: Fastlane::Helper::GitHelper.current_git_branch, + base: base_branch, + labels: 'Releases' + ) +end diff --git a/fastlane/lanes/release_management_in_ci.rb b/fastlane/lanes/release_management_in_ci.rb index 2cd1b1bc1dec..0464346d63f5 100644 --- a/fastlane/lanes/release_management_in_ci.rb +++ b/fastlane/lanes/release_management_in_ci.rb @@ -62,18 +62,4 @@ environment: { RELEASE_VERSION: release_version, EDITORIAL_BRANCH: editorial_branch } ) end - - ##################################################################################### - # Release Management Utils - ##################################################################################### - def create_release_management_pull_request(base_branch, title) - create_pull_request( - api_token: ENV['GITHUB_TOKEN'], - repo: GHHELPER_REPO, - title: title, - head: Fastlane::Helper::GitHelper.current_git_branch, - base: base_branch, - labels: 'Releases' - ) - end end From 9d27c999bf51cf572d0c25bf834da13e70c91509 Mon Sep 17 00:00:00 2001 From: Oguz Kocer Date: Wed, 10 May 2023 17:19:01 -0400 Subject: [PATCH 11/16] Change where we set the version variable in update_appstore_strings --- fastlane/lanes/localization.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fastlane/lanes/localization.rb b/fastlane/lanes/localization.rb index b321a07a3cc6..f2f026e8bfe4 100644 --- a/fastlane/lanes/localization.rb +++ b/fastlane/lanes/localization.rb @@ -98,12 +98,12 @@ lane :update_appstore_strings do |options| # If no `app:` is specified, call this for both WordPress and Jetpack apps = options[:app].nil? ? %i[wordpress jetpack] : Array(options[:app]&.downcase&.to_sym) + version = options.fetch(:version, android_get_app_version) apps.each do |app| app_values = APP_SPECIFIC_VALUES[app] metadata_folder = File.join(PROJECT_ROOT_FOLDER, 'WordPress', app_values[:metadata_dir]) - version = options.fetch(:version, android_get_app_version) # => files = { @@ -178,7 +178,7 @@ skip_commit = options.fetch(:skip_commit, false) skip_git_push = options.fetch(:skip_git_push, false) - + # If no `app:` is specified, call this for both WordPress and Jetpack apps = options[:app].nil? ? %i[wordpress jetpack] : Array(options[:app]&.to_s&.downcase&.to_sym) @@ -218,7 +218,7 @@ source_file = key.to_s.start_with?('release_note_') ? 'release_notes.txt' : h[:desc] FileUtils.cp(File.join(metadata_source_dir, source_file), File.join(download_path, 'en-US', h[:desc])) end - + unless skip_commit git_add(path: download_path) message = "Update #{app_values[:display_name]} metadata translations" From 64da4d296676f7594051818e5e56e2c83c013fa9 Mon Sep 17 00:00:00 2001 From: Oguz Kocer Date: Wed, 10 May 2023 17:27:46 -0400 Subject: [PATCH 12/16] Adds release_management_in_ci lanes to Fastfile --- fastlane/Fastfile | 1 + 1 file changed, 1 insertion(+) diff --git a/fastlane/Fastfile b/fastlane/Fastfile index 6844347fbfbb..e02d7602621f 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -54,6 +54,7 @@ import 'lanes/localization.rb' import 'lanes/release.rb' import 'lanes/screenshots.rb' import 'lanes/test.rb' +import 'lanes/release_management_in_ci.rb' default_platform(:android) From 7f19187b940fe731d56b06e21f6d37e28b81311d Mon Sep 17 00:00:00 2001 From: Oguz Kocer Date: Wed, 10 May 2023 17:36:29 -0400 Subject: [PATCH 13/16] Set remote url in configure-git-for-release-management.sh --- .buildkite/commands/configure-git-for-release-management.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.buildkite/commands/configure-git-for-release-management.sh b/.buildkite/commands/configure-git-for-release-management.sh index 9e07a6100b67..dfeea6d8da6b 100755 --- a/.buildkite/commands/configure-git-for-release-management.sh +++ b/.buildkite/commands/configure-git-for-release-management.sh @@ -5,3 +5,6 @@ curl -L https://api.github.com/meta | jq -r '.ssh_keys | .[]' | sed -e 's/^/github.com /' >> ~/.ssh/known_hosts git config --global user.email "mobile+wpmobilebot@automattic.com" git config --global user.name "Buildkite" + +# Buildkite is currently using the https url to checkout. We need to override it to be able to use the deploy key. +git remote set-url origin git@github.com:wordpress-mobile/WordPress-Android.git From 7db6ef3dd99d0cb282b21366bb6ce42531c4ba41 Mon Sep 17 00:00:00 2001 From: Oguz Kocer Date: Thu, 11 May 2023 21:51:44 -0400 Subject: [PATCH 14/16] Update release toolkit to 8.0.0 --- Gemfile | 4 ++-- Gemfile.lock | 42 ++++++++++++++++++------------------------ 2 files changed, 20 insertions(+), 26 deletions(-) diff --git a/Gemfile b/Gemfile index 220ed57adab6..5374b220ade2 100644 --- a/Gemfile +++ b/Gemfile @@ -7,9 +7,9 @@ gem 'nokogiri' ### Fastlane Plugins -#gem 'fastlane-plugin-wpmreleasetoolkit', '~> 7.0' +gem 'fastlane-plugin-wpmreleasetoolkit', '~> 8.0' # gem 'fastlane-plugin-wpmreleasetoolkit', path: '../../release-toolkit' -gem 'fastlane-plugin-wpmreleasetoolkit', git: 'https://github.com/wordpress-mobile/release-toolkit', branch: 'remove/git-push-actions' +# gem 'fastlane-plugin-wpmreleasetoolkit', git: 'https://github.com/wordpress-mobile/release-toolkit', branch: 'trunk' ### Gems needed only for generating Promo Screenshots diff --git a/Gemfile.lock b/Gemfile.lock index 9a5623ef5b67..df906a58810f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,24 +1,3 @@ -GIT - remote: https://github.com/wordpress-mobile/release-toolkit - revision: e26197f430a919e4d33bce7c69778870ca9e45af - branch: remove/git-push-actions - specs: - fastlane-plugin-wpmreleasetoolkit (7.0.0) - activesupport (>= 6.1.7.1) - bigdecimal (~> 1.4) - buildkit (~> 1.5) - chroma (= 0.2.0) - diffy (~> 3.3) - git (~> 1.3) - google-cloud-storage (~> 1.31) - nokogiri (~> 1.11) - octokit (~> 5.6) - parallel (~> 1.14) - plist (~> 3.1) - progress_bar (~> 1.3) - rake (>= 12.3, < 14.0) - rake-compiler (~> 1.0) - GEM remote: https://rubygems.org/ specs: @@ -34,7 +13,7 @@ GEM artifactory (3.0.15) atomos (0.1.3) aws-eventstream (1.2.0) - aws-partitions (1.762.0) + aws-partitions (1.763.0) aws-sdk-core (3.172.0) aws-eventstream (~> 1, >= 1.0.2) aws-partitions (~> 1, >= 1.651.0) @@ -137,6 +116,21 @@ GEM xcodeproj (>= 1.13.0, < 2.0.0) xcpretty (~> 0.3.0) xcpretty-travis-formatter (>= 0.0.3) + fastlane-plugin-wpmreleasetoolkit (8.0.0) + activesupport (>= 6.1.7.1) + bigdecimal (~> 1.4) + buildkit (~> 1.5) + chroma (= 0.2.0) + diffy (~> 3.3) + git (~> 1.3) + google-cloud-storage (~> 1.31) + nokogiri (~> 1.11) + octokit (~> 5.6) + parallel (~> 1.14) + plist (~> 3.1) + progress_bar (~> 1.3) + rake (>= 12.3, < 14.0) + rake-compiler (~> 1.0) gh_inspector (1.1.3) git (1.18.0) addressable (~> 2.8) @@ -197,7 +191,7 @@ GEM multipart-post (2.0.0) nanaimo (0.3.0) naturally (2.2.1) - nokogiri (1.14.3) + nokogiri (1.14.4) mini_portile2 (~> 2.8.0) racc (~> 1.4) octokit (5.6.1) @@ -273,7 +267,7 @@ PLATFORMS DEPENDENCIES fastlane (~> 2) - fastlane-plugin-wpmreleasetoolkit! + fastlane-plugin-wpmreleasetoolkit (~> 8.0) nokogiri rmagick (~> 4.1) From 221a64dddd09227ffdfbac0a5091ecc19670daa4 Mon Sep 17 00:00:00 2001 From: Oguz Kocer Date: Thu, 11 May 2023 23:14:03 -0400 Subject: [PATCH 15/16] Update Buildkite trigger messages for release management Co-authored-by: Gio Lodi --- fastlane/lanes/release_management_in_ci.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/fastlane/lanes/release_management_in_ci.rb b/fastlane/lanes/release_management_in_ci.rb index 0464346d63f5..b8186c13ab2f 100644 --- a/fastlane/lanes/release_management_in_ci.rb +++ b/fastlane/lanes/release_management_in_ci.rb @@ -10,7 +10,7 @@ buildkite_pipeline: BUILDKITE_PIPELINE, branch: 'trunk', pipeline_file: 'code-freeze.yml', - message: 'Code Freeze in CI' + message: 'Code Freeze' ) end @@ -21,7 +21,7 @@ buildkite_pipeline: BUILDKITE_PIPELINE, branch: "release/#{release_version}", pipeline_file: 'complete-code-freeze.yml', - message: 'Complete Code Freeze in CI', + message: 'Complete Code Freeze', environment: { RELEASE_VERSION: release_version } ) end @@ -33,7 +33,7 @@ buildkite_pipeline: BUILDKITE_PIPELINE, branch: "release/#{release_version}", pipeline_file: 'finalize-release.yml', - message: 'Finalize release', + message: 'Finalize Release', environment: { RELEASE_VERSION: release_version } ) end @@ -45,7 +45,7 @@ buildkite_pipeline: BUILDKITE_PIPELINE, branch: "release/#{release_version}", pipeline_file: 'new-beta-release.yml', - message: 'New beta release', + message: 'New Beta Release', environment: { RELEASE_VERSION: release_version } ) end @@ -58,7 +58,7 @@ buildkite_pipeline: BUILDKITE_PIPELINE, branch: "#{editorial_branch}", pipeline_file: 'update-release-notes.yml', - message: 'Update release notes', + message: 'Update Release Notes', environment: { RELEASE_VERSION: release_version, EDITORIAL_BRANCH: editorial_branch } ) end From 0af7b9709715abf9278e0e31142c34a024a4ac95 Mon Sep 17 00:00:00 2001 From: Oguz Kocer Date: Thu, 11 May 2023 23:14:39 -0400 Subject: [PATCH 16/16] Change Buildkite git user name to 'Automattic Release Bot' Co-authored-by: Gio Lodi --- .buildkite/commands/configure-git-for-release-management.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.buildkite/commands/configure-git-for-release-management.sh b/.buildkite/commands/configure-git-for-release-management.sh index dfeea6d8da6b..eb39be490f66 100755 --- a/.buildkite/commands/configure-git-for-release-management.sh +++ b/.buildkite/commands/configure-git-for-release-management.sh @@ -4,7 +4,7 @@ # Later on, we should be able to configure the agent instead. curl -L https://api.github.com/meta | jq -r '.ssh_keys | .[]' | sed -e 's/^/github.com /' >> ~/.ssh/known_hosts git config --global user.email "mobile+wpmobilebot@automattic.com" -git config --global user.name "Buildkite" +git config --global user.name "Automattic Release Bot" # Buildkite is currently using the https url to checkout. We need to override it to be able to use the deploy key. git remote set-url origin git@github.com:wordpress-mobile/WordPress-Android.git