diff --git a/.buildkite/commands/build-trunk-internal.sh b/.buildkite/commands/build-trunk-internal.sh new file mode 100755 index 000000000000..3c149a1da8f8 --- /dev/null +++ b/.buildkite/commands/build-trunk-internal.sh @@ -0,0 +1,10 @@ +#!/bin/bash -eu + +echo "--- :rubygems: Setting up Gems" +install_gems + +echo "--- :closed_lock_with_key: Installing Secrets" +bundle exec fastlane run configure_apply + +echo "--- :hammer_and_wrench: Build WordPress & Jetpack and upload to the Play internal track" +bundle exec fastlane build_and_upload_trunk_internal skip_confirm:true skip_prechecks:true diff --git a/.buildkite/schedules/build-trunk-internal.yml b/.buildkite/schedules/build-trunk-internal.yml new file mode 100644 index 000000000000..1a03c4452eab --- /dev/null +++ b/.buildkite/schedules/build-trunk-internal.yml @@ -0,0 +1,16 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/buildkite/pipeline-schema/main/schema.json +--- + +# Builds WordPress & Jetpack from `trunk` and uploads them to the Play Store `internal` testing +# track, to validate the "release from trunk" model. Runs on a schedule (configured in the +# Buildkite UI); also triggerable manually via the `PIPELINE` env var for testing. + +agents: + queue: "android" + +steps: + - label: ":android: Build trunk → Play internal" + command: .buildkite/commands/build-trunk-internal.sh + plugins: [$CI_TOOLKIT] + notify: + - slack: "#build-and-ship" diff --git a/fastlane/lanes/build.rb b/fastlane/lanes/build.rb index ac11e2872ce0..bf1d7ba6bcae 100644 --- a/fastlane/lanes/build.rb +++ b/fastlane/lanes/build.rb @@ -111,6 +111,59 @@ create_gh_release(app: app, version_name: version_name, prerelease: true) if options[:create_release] end + ##################################################################################### + # build_and_upload_trunk_internal + # ----------------------------------------------------------------------------------- + # Builds WordPress & Jetpack from the current commit and uploads them to the Play Store + # `internal` testing track. Intended to run from `trunk` (manually or on a schedule) to + # validate the "release from trunk" model. + # + # The version is computed on the fly and written to `version.properties` for the build + # only — it is NOT committed: + # - versionName: the planned release version (without the `-rc-N` suffix) + # - versionCode: via release-toolkit's `ContinuousBuildCodeFormatter`, + # i.e. `(major * 10 + minor) * 1_000_000 + BUILDKITE_BUILD_NUMBER` + # ----------------------------------------------------------------------------------- + # Usage: + # bundle exec fastlane build_and_upload_trunk_internal [skip_confirm:] [skip_prechecks:] + ##################################################################################### + desc 'Build WordPress & Jetpack from trunk and upload them to the Play Store internal track' + lane :build_and_upload_trunk_internal do |options| + version_name = current_release_version + + unless options[:skip_prechecks] + ensure_git_branch(branch: DEFAULT_BRANCH) unless is_ci + + ensure_git_status_clean unless is_ci + + UI.important("Building #{version_name} for upload to the Play Store internal track") + + UI.user_error!('Aborted by user request') unless options[:skip_confirm] || UI.confirm('Do you want to continue?') + + android_build_preflight + end + + version = VERSION_FORMATTER.parse(version_name) + build_code = Fastlane::Wpmreleasetoolkit::Versioning::ContinuousBuildCodeFormatter.new.build_code( + major: version.major, + minor: version.minor, + build_number: Integer(ENV.fetch('BUILDKITE_BUILD_NUMBER')) + ) + + UI.important("Building trunk internal build: #{version_name} (#{build_code})") + + # Set the version for this build only. We deliberately do not commit this change. + VERSION_FILE.write_version(version_name: version_name, version_code: build_code) + + %i[wordpress jetpack].each do |app| + build_bundle(app: app, version_name: version_name, build_code: build_code, buildType: 'Release') + upload_build_to_play_store(app: app, version_name: version_name, track: 'internal') + # `upload_gutenberg_sourcemaps` builds a file path from the app name, so it needs a String + # (a Symbol can't be passed to `File.join`). + upload_gutenberg_sourcemaps(app: app.to_s, release_version: version_name) + end + end + ##################################################################################### # upload_build_to_play_store # -----------------------------------------------------------------------------------