From 8929d21be1c32094d4e937abe4eb816297d7d7f3 Mon Sep 17 00:00:00 2001 From: Tyler Beebe Date: Tue, 17 Nov 2026 15:55:10 +0000 Subject: [PATCH] ci(release): promote to latest only when asked (TRUNK-23152) Promote Release gets a promote-latest checkbox, off by default. Off, only channel-.json moves, and the GitHub release is marked released but not latest, so analytics-uploader v2.1.7 and older, which follow channel.json or GitHub's latest, stay on the previous release. On is the old behaviour. set-latest-in-s3.sh still moves channel.json when PROMOTE_LATEST is unset, which Mirror Releases to S3 relies on. Co-Authored-By: Claude Opus 5.5 --- .github/scripts/set-latest-in-s3.sh | 9 ++++++++- .github/workflows/promote_release.yml | 16 ++++++++++++---- CONTRIBUTING.md | 2 +- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/.github/scripts/set-latest-in-s3.sh b/.github/scripts/set-latest-in-s3.sh index e7e66d3f..82642ae3 100755 --- a/.github/scripts/set-latest-in-s3.sh +++ b/.github/scripts/set-latest-in-s3.sh @@ -2,6 +2,7 @@ # Point releases/analytics-cli/prod/channel.json and channel-.json at an already-published # version. These are the only mutable objects in the prefix. Each pointer only moves forward # (unless ALLOW_DOWNGRADE=true), so a 0.x backport after 1.0.0 moves channel-0.json alone. +# PROMOTE_LATEST=false leaves channel.json alone too. # # Usage: set-latest-in-s3.sh set -euo pipefail @@ -10,6 +11,7 @@ shopt -s inherit_errexit bucket="${BUCKET:-trunk-releases}" prefix="${PREFIX:-releases/analytics-cli/prod}" allow_downgrade="${ALLOW_DOWNGRADE:-false}" +promote_latest="${PROMOTE_LATEST:-true}" version="${1:?usage: set-latest-in-s3.sh }" if [[ ! ${version} =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$ ]]; then @@ -63,7 +65,12 @@ move_pointer() { } major_result="$(move_pointer "channel-${major}.json")" -global_result="$(move_pointer "channel.json")" +if [[ ${promote_latest} == "true" ]]; then + global_result="$(move_pointer "channel.json")" +else + echo "https://trunk.io/${prefix}/channel.json stays put: not promoting latest" >&2 + global_result=kept +fi if [[ ${major_result} == kept && ${global_result} == kept ]]; then echo "::warning::${version} moved no pointer; both already point at a newer version" diff --git a/.github/workflows/promote_release.yml b/.github/workflows/promote_release.yml index e1818c79..ee53aec0 100644 --- a/.github/workflows/promote_release.yml +++ b/.github/workflows/promote_release.yml @@ -1,13 +1,19 @@ name: Promote Release -run-name: Promote ${{ inputs.version }} to latest +run-name: Promote ${{ inputs.version }}${{ inputs.promote-latest && ' to latest' || ' for its major' }} on: workflow_dispatch: inputs: # trunk-ignore(checkov/CKV_GHA_7) version: type: string - description: Already-released version to make latest for its major (channel-.json), and overall (channel.json and GitHub) when it is the newest + description: Already-released version to make latest for its major (channel-.json) required: true + # Off: channel.json and GitHub's latest stay put, so analytics-uploader v2.1.7 and older, + # which follow one of them, keep the previous release. + promote-latest: + type: boolean + description: Promote latest — also point channel.json and GitHub's latest release at this version, when it is the newest + default: false allow-downgrade: type: boolean description: Move the pointers even to an older version (a rollback) @@ -27,6 +33,7 @@ jobs: env: VERSION: ${{ inputs.version }} ALLOW_DOWNGRADE: ${{ inputs.allow-downgrade }} + PROMOTE_LATEST: ${{ inputs.promote-latest }} GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} steps: - uses: actions/checkout@v4 @@ -69,7 +76,7 @@ jobs: # S3 moves first: its preconditions (the role, a complete manifest) are the ones that fail in # practice, and when they do GitHub has not moved either. Both steps are idempotent, so if the # GitHub edit fails afterwards, re-running this workflow converges the two. - - name: Point channel.json and channel-.json at ${{ inputs.version }} + - name: Point channel-.json, and channel.json if promoting latest, at ${{ inputs.version }} id: s3 run: .github/scripts/set-latest-in-s3.sh "${VERSION}" @@ -77,7 +84,8 @@ jobs: if: steps.s3.outputs.global_moved == 'true' run: gh release edit "${VERSION}" --prerelease=false --latest - # A backport of an older major is published but must not take GitHub's latest from the newer one. + # A backport of an older major, or a release not promoted to latest, is published but must not + # take GitHub's latest. - name: Mark ${{ inputs.version }} released on GitHub if: steps.s3.outputs.global_moved != 'true' run: gh release edit "${VERSION}" --prerelease=false --latest=false diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 05472bf4..537b2394 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -147,7 +147,7 @@ The pattern is: Releases are published in two places: GitHub releases, and `https://trunk.io/releases/analytics-cli/prod/` (the `trunk-releases` S3 bucket). Trunk's own consumers (the `analytics-uploader` action and the `trunk` CLI's `flakytests` command) read the S3 copy. GitHub releases stay, because the frozen legacy `trunk` launcher and customers' own scripts download from them. 1. **Cut**: run the `Release` workflow with the version. It builds, smoke-tests, creates a GitHub **prerelease**, and uploads the same assets to `releases/analytics-cli/prod//`. A version is immutable once published. -2. **Promote**: run the `Promote Release` workflow with the version. It points `channel-.json` at it. If it is the newest release overall, it also points `channel.json` at it and marks it latest on GitHub. So promoting a 0.x backport after 1.x moves only `channel-0.json`. A pointer never moves back unless you tick `allow-downgrade`, for a rollback. Do **not** mark a release latest in the GitHub UI, since that leaves the pointers behind. +2. **Promote**: run the `Promote Release` workflow with the version. It points `channel-.json` at it. With **`promote-latest`** ticked (off by default), and when the version is the newest release overall, it also points `channel.json` at it and marks it latest on GitHub. Leave it off to hold `channel.json` and GitHub's latest back: analytics-uploader v2.1.7 and older follow one of them, and many orgs pin those versions. With it off, the `trunk` CLI's `flakytests` also keeps resolving `latest` to the previous release, unless the caller sets `TRUNK_ANALYTICS_CLI_VERSION`. Promoting a 0.x backport after 1.x moves only `channel-0.json` either way. A pointer never moves back unless you tick `allow-downgrade`, for a rollback. Do **not** mark a release latest in the GitHub UI, since that leaves the pointers behind. 3. **Backfill**: run `Mirror Releases to S3` to copy releases that predate the S3 lane (or that a failed run left incomplete). Pass space-separated tags or `all`. Re-running it is safe because complete versions are skipped. Each download is first checked against the sha256 digest GitHub recorded for it; releases from before June 2025 have no digest and are copied unchecked. Layout under `releases/analytics-cli/prod/`: