Skip to content
Merged
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
9 changes: 8 additions & 1 deletion .github/scripts/set-latest-in-s3.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# Point releases/analytics-cli/prod/channel.json and channel-<major>.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 <version>
set -euo pipefail
Expand All @@ -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 <version>}"

if [[ ! ${version} =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$ ]]; then
Expand Down Expand Up @@ -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"
Expand Down
16 changes: 12 additions & 4 deletions .github/workflows/promote_release.yml
Original file line number Diff line number Diff line change
@@ -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-<major>.json), and overall (channel.json and GitHub) when it is the newest
description: Already-released version to make latest for its major (channel-<major>.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)
Expand All @@ -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
Expand Down Expand Up @@ -69,15 +76,16 @@ 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-<major>.json at ${{ inputs.version }}
- name: Point channel-<major>.json, and channel.json if promoting latest, at ${{ inputs.version }}
id: s3
run: .github/scripts/set-latest-in-s3.sh "${VERSION}"

- name: Mark ${{ inputs.version }} latest on GitHub
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
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/<version>/`. A version is immutable once published.
2. **Promote**: run the `Promote Release` workflow with the version. It points `channel-<major>.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-<major>.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/`:
Expand Down
Loading