Skip to content
Draft
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
2 changes: 2 additions & 0 deletions .buildkite/code-freeze.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ steps:

echo '--- :snowflake: Start Code Freeze'
bundle exec fastlane code_freeze version:"${RELEASE_VERSION}" skip_confirm:true
# Runs on `mac-metal` so it can use the bot git identity from `use-bot-for-git` (only available
# on these agents) for its git write operations (commit/push/PR).
agents:
queue: "mac-metal"
retry:
Expand Down
10 changes: 10 additions & 0 deletions .buildkite/commands/download-translations.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash -eu

echo "--- :robot_face: Use bot for git operations"
source use-bot-for-git

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

echo "--- :globe_with_meridians: Download translations and open/update the PR"
bundle exec fastlane update_translations
2 changes: 2 additions & 0 deletions .buildkite/complete-code-freeze.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ steps:

echo '--- :snowflake: Complete Code Freeze'
bundle exec fastlane complete_code_freeze skip_confirm:true
# Runs on `mac-metal` so it can use the bot git identity from `use-bot-for-git` (only available
# on these agents) for its git write operations (commit/push/PR).
agents:
queue: "mac-metal"
retry:
Expand Down
2 changes: 2 additions & 0 deletions .buildkite/finalize-hotfix-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ steps:

echo '--- :shipit: Finalize hotfix'
bundle exec fastlane finalize_hotfix_release skip_confirm:true
# Runs on `mac-metal` so it can use the bot git identity from `use-bot-for-git` (only available
# on these agents) for its git write operations (commit/push/PR).
agents:
queue: mac-metal
retry:
Expand Down
2 changes: 2 additions & 0 deletions .buildkite/finalize-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ steps:

echo '--- :shipit: Finalize Release'
bundle exec fastlane finalize_release skip_confirm:true
# Runs on `mac-metal` so it can use the bot git identity from `use-bot-for-git` (only available
# on these agents) for its git write operations (commit/push/PR).
agents:
queue: "mac-metal"
retry:
Expand Down
2 changes: 2 additions & 0 deletions .buildkite/new-beta-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ steps:

echo '--- :shipit: New Beta Release'
bundle exec fastlane new_beta_release skip_confirm:true
# Runs on `mac-metal` so it can use the bot git identity from `use-bot-for-git` (only available
# on these agents) for its git write operations (commit/push/PR).
agents:
queue: "mac-metal"
retry:
Expand Down
2 changes: 2 additions & 0 deletions .buildkite/new-hotfix-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ steps:

echo '--- :shipit: Start new hotfix'
bundle exec fastlane new_hotfix_release version_name:"$RELEASE_VERSION" build_code:"$BUILD_CODE" skip_confirm:true
# Runs on `mac-metal` so it can use the bot git identity from `use-bot-for-git` (only available
# on these agents) for its git write operations (commit/push/PR).
agents:
queue: mac-metal
retry:
Expand Down
2 changes: 2 additions & 0 deletions .buildkite/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ steps:

echo '--- :package: Publish Release'
bundle exec fastlane publish_release skip_confirm:true
# Runs on `mac-metal` so it can use the bot git identity from `use-bot-for-git` (only available
# on these agents) for its git write operations (commit/push/PR).
agents:
queue: mac-metal
retry:
Expand Down
25 changes: 25 additions & 0 deletions .buildkite/schedules/download-translations.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/buildkite/pipeline-schema/main/schema.json
---

# Runs on a daily schedule (configured in the Buildkite UI, ~06:00 UTC) to sync the latest
# translations from GlotPress into a single rolling `translations/daily-update` PR.
#
# Runs on `mac-metal` (like the release code-freeze/finalize lanes) because this job commits,
# pushes and opens a PR, which needs the bot git identity from `use-bot-for-git` — that command
# is only available on those agents.

agents:
queue: "mac-metal"

steps:
- label: ":globe_with_meridians: Download Translations"
command: .buildkite/commands/download-translations.sh
plugins: [$CI_TOOLKIT]

# Failure notifications are disabled for now. If re-enabled, they go to #wpmobile.
# notify:
# - slack:
# channels:
# - "#wpmobile"
# message: "Failed to sync translations from GlotPress."
# if: build.state == "failed"
2 changes: 2 additions & 0 deletions .buildkite/update-release-notes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ steps:

echo '--- :memo: Update Release Notes'
bundle exec fastlane update_appstore_strings version:${RELEASE_VERSION}
# Runs on `mac-metal` so it can use the bot git identity from `use-bot-for-git` (only available
# on these agents) for its git write operations (commit/push/PR).
agents:
queue: "mac-metal"
retry:
Expand Down
6 changes: 4 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ gem 'fastlane', '~> 2'

gem 'fastlane-plugin-firebase_app_distribution', '~> 1.0'
gem 'fastlane-plugin-sentry'
gem 'fastlane-plugin-wpmreleasetoolkit', '~> 14.7'
# TEMPORARY: point at the release-toolkit branch to validate the new `find_or_create_pull_request`
# action used by the `update_translations` lane. Revert to `~> 14.7` once it ships in a tagged release.
# gem 'fastlane-plugin-wpmreleasetoolkit', '~> 14.7'
gem 'fastlane-plugin-wpmreleasetoolkit', git: 'https://github.com/wordpress-mobile/release-toolkit', branch: 'add/find-or-create-pull-request'
# gem 'fastlane-plugin-wpmreleasetoolkit', path: '../../release-toolkit'
# gem 'fastlane-plugin-wpmreleasetoolkit', git: 'https://github.com/wordpress-mobile/release-toolkit', branch: ''

### Gems needed only for generating Promo Screenshots
group :screenshots, optional: true do
Expand Down
44 changes: 25 additions & 19 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
GIT
remote: https://github.com/wordpress-mobile/release-toolkit
revision: 77cdeac5098b460ac6faba189f7e6a4f3d642c25
branch: add/find-or-create-pull-request
specs:
fastlane-plugin-wpmreleasetoolkit (14.7.0)
buildkit (~> 1.5)
chroma (= 0.2.0)
diffy (~> 3.3)
dotenv (~> 2.8)
fastlane (~> 2.235)
gettext (~> 3.5)
git (~> 1.3)
google-cloud-storage (~> 1.31)
java-properties (~> 0.3.0)
nokogiri (~> 1.19, >= 1.19.3)
octokit (~> 6.1)
parallel (~> 1.14)
plist (~> 3.1)
progress_bar (~> 1.3)
rake (>= 12.3, < 14.0)
rake-compiler (~> 1.0)
xcodeproj (~> 1.22)

GEM
remote: https://rubygems.org/
specs:
Expand Down Expand Up @@ -167,24 +191,6 @@ GEM
google-apis-firebaseappdistribution_v1alpha (>= 0.12.0)
fastlane-plugin-sentry (1.29.0)
os (~> 1.1, >= 1.1.4)
fastlane-plugin-wpmreleasetoolkit (14.7.0)
buildkit (~> 1.5)
chroma (= 0.2.0)
diffy (~> 3.3)
dotenv (~> 2.8)
fastlane (~> 2.235)
gettext (~> 3.5)
git (~> 1.3)
google-cloud-storage (~> 1.31)
java-properties (~> 0.3.0)
nokogiri (~> 1.19, >= 1.19.3)
octokit (~> 6.1)
parallel (~> 1.14)
plist (~> 3.1)
progress_bar (~> 1.3)
rake (>= 12.3, < 14.0)
rake-compiler (~> 1.0)
xcodeproj (~> 1.22)
fastlane-sirp (1.1.0)
fiddle (1.1.8)
forwardable (1.4.0)
Expand Down Expand Up @@ -378,7 +384,7 @@ DEPENDENCIES
fastlane (~> 2)
fastlane-plugin-firebase_app_distribution (~> 1.0)
fastlane-plugin-sentry
fastlane-plugin-wpmreleasetoolkit (~> 14.7)
fastlane-plugin-wpmreleasetoolkit!
rmagick (~> 7.0)

BUNDLED WITH
Expand Down
59 changes: 59 additions & 0 deletions fastlane/lanes/localization.rb
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,65 @@
)
end

TRANSLATIONS_SYNC_BRANCH = 'translations/daily-update'

#####################################################################################
# update_translations
# -----------------------------------------------------------------------------------
# Downloads the latest WordPress & Jetpack translations from GlotPress and opens (or
# refreshes) a single rolling Pull Request, so `trunk` stays continuously localized.
# Intended to run on a daily schedule.
#
# Each run resets `translations/daily-update` to `trunk` and re-downloads, so the PR
# always shows the complete current translation delta against `trunk` (no accumulation).
# If GlotPress has nothing new, no commit is made and the lane exits without a PR.
# -----------------------------------------------------------------------------------
# Usage:
# bundle exec fastlane update_translations
#####################################################################################
lane :update_translations do
Fastlane::Helper::GitHelper.checkout_and_pull(DEFAULT_BRANCH)

# Reset the rolling branch to the tip of `trunk` so each run produces a clean delta against it.
Fastlane::Helper::GitHelper.delete_local_branch_if_exists!(TRANSLATIONS_SYNC_BRANCH)
Fastlane::Helper::GitHelper.create_branch(TRANSLATIONS_SYNC_BRANCH, from: DEFAULT_BRANCH)

download_translations

# `download_translations` commits when GlotPress has updates; if nothing changed, HEAD still
# points at `trunk` and there is nothing to open a PR for.
if Fastlane::Helper::GitHelper.point_to_same_commit?(DEFAULT_BRANCH, 'HEAD')
UI.important('No new translations from GlotPress today; nothing to sync.')
next
end

# Prune translations whose key is no longer in the source strings (GlotPress can still serve them),
# which would otherwise fail Lint's `ExtraTranslation` check. Done as a separate commit on top of the
# download so the PR shows exactly what was pruned vs. what was downloaded.
main_res = File.join('WordPress', 'src', 'main', 'res')
jetpack_res = File.join('WordPress', 'src', 'jetpack', 'res')
android_prune_orphaned_translations(res_dir: main_res)
android_prune_orphaned_translations(
res_dir: jetpack_res,
additional_source_strings_paths: [File.join(main_res, 'values', 'strings.xml')]
)
Fastlane::Helper::GitHelper.commit(message: 'Prune orphaned translations', files: :all)

push_to_git_remote(remote_branch: TRANSLATIONS_SYNC_BRANCH, tags: false, force: true, set_upstream: true)

# `find_or_create_pull_request` resolves the GitHub token the standard way (GITHUB_TOKEN) and only
# opens a PR when none is already open; the force-push above already refreshed any existing one.
pr_url = find_or_create_pull_request(
repository: GITHUB_REPO,
title: 'Update translations',
body: 'Automated daily translation sync from GlotPress. Opened by the `download-translations` scheduled pipeline.',
head: TRANSLATIONS_SYNC_BRANCH,
base: DEFAULT_BRANCH,
labels: ['Localization']
)
UI.success("Translations PR: #{pr_url}")
end

# Updates the `.po` file at the given `po_path` using the content of the `sources` files,
# interpolating `release_version` where appropriate.
# Internally, this calls the `gp_update_metadata_source` release toolkit action and adds Git management to it.
Expand Down
Loading