-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Release management in CI #18398
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
Release management in CI #18398
Changes from 13 commits
f34ed36
b656d9f
0e6a276
1fad391
904842e
647d6ff
ba8c70b
686f0f6
8ebf981
08b6070
9d27c99
64da4d2
7f19187
7db6ef3
221a64d
0af7b97
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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`. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the difference that we wouldn't be able to open the PR if we were on a commit (detached HEAD?)? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can't add a new commit in a detached HEAD. When we update the app store strings, we need to create new commits and push it to remote. |
||
git fetch origin "$EDITORIAL_BRANCH" | ||
git checkout "$EDITORIAL_BRANCH" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We intend to bring this configuration to our agents, so that we don't have to do it in every pipeline. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/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" | ||
oguzkocer marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
# 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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 I wonder if it would be better to make this a bit more generic, like: REPO_NO_TRAILING=${BUILDKITE_REPO%/}
git remote set-url origin ${REPO_NO_TRAILING/#https:\/\/github.com\//git@github:} Or alternatively (inspired by this): REPO_SLUG=$(basename $(dirname "$BUILDKITE_REPO"))/$(basename "$BUILDKITE_REPO%.git")
git remote set-url origin git@github.com:${REPO_SLUG}.git There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If this was in a toolkit repo, it'd make sense to go with a generic version. However, since this is part of WordPress-Android, I think this just makes it harder to understand the code. Furthermore, it looks like I forgot to mention that this is a temporary issue specific to WordPress-Android. We should not be using the For example, we don't need this bit in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Aaah.. and I think I might have found the culprit. All this time I've been checking the Buildkite settings' Having said that, I hope my previous logic also made sense in terms of keeping the specific url. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
🤦♂️ I've reviewed so many PRs in the past few days that I think I lost track of which repo each PR was about, and since I reviewed a PR about There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No worries at all 🤗
I noticed ❤️ - thank you for doing that! 🙇♂️ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll do a proper release before we merge this PR in. |
||
|
||
|
||
### Gems needed only for generating Promo Screenshots | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not sure where the best place for this helper is. I've asked @jkmassel's opinion and he agreed that this approach made sense. However, if you have a suggestion, I'd be happy to apply it. Note that I initially had this in the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems like a good start – long-term, might be good to see if we can turn it into a release toolkit action – I find that helpers generally end up there! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree. To provide some context; I initially intended to do this and created an internal discussion where Olivier pointed out that there is already a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1. It makes sense to start local and extract/abstract later. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
def create_release_management_pull_request(base_branch, title) | ||
create_pull_request( | ||
api_token: ENV['GITHUB_TOKEN'], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fastlane uses There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sound 👍 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a good way to go. The reason we use that environment variable is that it's what OctoKit expects FWIW. |
||
repo: GHHELPER_REPO, | ||
title: title, | ||
head: Fastlane::Helper::GitHelper.current_git_branch, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fastlane defaults to the current branch. However, it does so by using the |
||
base: base_branch, | ||
labels: 'Releases' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can add |
||
) | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The version value is not application specific, in fact it's fetched from |
||
|
||
# <key in po file> => <path to txt file to read the content from> | ||
files = { | ||
|
@@ -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 | ||
|
@@ -173,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) | ||
|
||
|
@@ -213,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" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TIL about this approach to avoid the
set -u
from the shebang to fail the script at this point because of an unbound access. Neat 👏