GitHub grants package write access to a whole repository, not to a workflow, branch or environment. Today `ghcr.io/coder/coder`, `coder-base` and the OCI charts list coder/coder with Write, so any workflow on any branch here can request `packages: write` and overwrite a release tag with this repository's `GITHUB_TOKEN`. The `release` environment and the tag rulesets don't stop that. GHCR accepts neither App tokens nor OIDC, so the repository boundary is the only way to separate who publishes. With this change, releases push to `*-staging` packages and trigger **coder/ghcr-publisher**, a locked repository that will be the only one with Write on the public packages. Before copying a digest, it verifies three things: - this `release.yaml` attested it, - on `release/X.Y` (or `main` for an RC), with the signer being `release.yaml` at that same ref, - built from the commit the `vX.Y.Z` tag points to. It copies by digest and never moves an existing version tag. It moves `latest` only to the highest stable version. ### Changes - **release.yaml** - Images, the base image and the OCI charts are pushed to `coder-staging`, `coder-base-staging` and `chart-staging/*`. - The charts get attestations for their OCI manifest digests. The existing `.tgz` attestations don't cover those digests. - The base and image attestations no longer `continue-on-error`, because promotion depends on them. - The final image is built on the fresh base image **by digest**. - A `repository_dispatch` is sent with a `coder-ghcr-dispatch` token (`contents: write` on `ghcr-publisher` only). - The job waits until every public tag serves the expected digest, before the GitHub release is published. - `latest` is no longer built here. The separate latest SBOM asset is dropped; it described the same image. - **docker-base.yaml** - Only checks, on PRs that touch them, that `Dockerfile.base` builds for every platform. It no longer publishes, and no longer needs `packages: write`. - Non-release and local builds keep using `ghcr.io/coder/coder-base:latest`. coder/ghcr-publisher moves it to the base of each new highest stable release (roughly weekly for 2.39), instead of the Monday/Wednesday/Friday rebuild. So preview images and the `coder-preview:main` scan see Alpine updates about weekly, and a `Dockerfile.base` change reaches preview images at the next stable release. Release images always build a fresh base. - **verify-releases.md** - Releases since 2026-11-16 (#32212) are built on `release/X.Y`, so the documented `--source-ref refs/tags/vX.Y.Z` and cosign identity fail for current releases. - Checked: `gh attestation verify` on v2.39.4 fails with the tag ref and passes with `refs/heads/release/2.39`. v2.39.1 still passes with its tag. Cosign verifies v2.39.4 with the new identity. ### Review fixes (second commit set) Two independent reviews (one functional, one adversarial) found the following, now fixed: - **A writer could get a real release to attest their image.** The index was built from, and its digest read back from, mutable staging tags. A writer moving `coder-staging:vX` mid-release could get their image attested. Now every digest comes from the registry's response to our own push (`docker push`, `docker manifest push`, depot, `helm push`), the index is built from per-arch **digests**, and syft and cosign run on `image@digest`. Tested against a local registry with Docker 29: each parsed digest matches what the registry stores, and the index contains exactly the pushed children. - **Commit binding.** The provenance commit field is the dispatched branch head, not the released commit (which differs whenever an older commit is released). Each artifact now gets a release attestation (`https://coder.com/attestations/release/v1`) stating version, commit and target package, and the publisher requires it, plus an approved `release` environment on the run. - **Re-runs:** a tag an earlier attempt promoted is accepted, and the publisher keeps that build. - **Tokens:** the tagging and promotion App tokens are revoked right after use. - **Docs:** `SOURCE_REF` is now correct for RCs (checked in bash and PowerShell). Image *provenance* attestations are best-effort again, as before; the publisher relies on the release attestations instead. ### Prerequisites (all done 2026-11-22) 1. coder/ghcr-publisher#1 and coder/ghcr-publisher#2 merged (#2 checks the release attestations this PR now produces). 2. The staging packages exist (created 2026-11-20), with coder/coder **Write** and `ghcr-publisher` **Read** set under Manage Actions access: `coder-staging`, `coder-base-staging`, `chart-staging/coder`, `chart-staging/coder-provisioner`, `chart-staging/coder-ai-gateway`. 3. The `coder-ghcr-dispatch` App exists and is installed on `ghcr-publisher` only (coder/gcp#472, coder/github-org-terraform#206), and `CODER_GHCR_DISPATCH_APP_ID` and `CODER_GHCR_DISPATCH_APP_KMS_KEY` are set in the `release` environment. `coder-release-publisher` is uninstalled from `ghcr-publisher`. ### After merge - Backport to release/2.39, 2.38, 2.37, 2.34 and 2.29. Each branch runs its own `release.yaml`. - After one real release promotes successfully, switch the five public packages to coder/coder **Read** and ghcr-publisher **Write**. Only then is the overwrite path closed. Tested: - The publisher's checks against the real v2.39.4 attestations: pass on the right ref, fail on a wrong ref, wrong commit or wrong signer. - The anonymous digest lookup against live image, base and chart tags (matches crane). - actionlint and zizmor are clean. - No release has run with this yet. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1207 lines
53 KiB
YAML
1207 lines
53 KiB
YAML
# GitHub release workflow.
|
|
name: Release
|
|
on:
|
|
workflow_dispatch:
|
|
inputs:
|
|
release_channel:
|
|
type: choice
|
|
description: Release channel
|
|
options:
|
|
- mainline
|
|
- stable
|
|
- rc
|
|
release_notes:
|
|
description: Release notes for the publishing the release. This is required to create a release.
|
|
version:
|
|
description: >-
|
|
Version to release, e.g. v2.39.2 or v2.40.0-rc.0. Required unless dry-run. Run the workflow on
|
|
release/X.Y (or main for an RC); the approved release job creates the annotated tag at the
|
|
workflow's commit with the release App, since only the App may create tags.
|
|
type: string
|
|
required: false
|
|
commit:
|
|
description: >-
|
|
Full SHA of the commit to tag and release. Required unless dry-run. It must already be on the
|
|
branch the workflow runs on (so it was reviewed), and pins the release to that commit even if
|
|
the branch moves. scripts/release.sh fills this in.
|
|
type: string
|
|
required: false
|
|
dry_run:
|
|
description: Perform a dry-run release (devel). No tag is created.
|
|
type: boolean
|
|
required: true
|
|
default: false
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
concurrency: ${{ github.workflow }}-${{ github.ref }}
|
|
|
|
env:
|
|
# Use `inputs` (vs `github.event.inputs`) to ensure that booleans are actual
|
|
# booleans, not strings.
|
|
# https://github.blog/changelog/2022-06-10-github-actions-inputs-unified-across-manual-and-reusable-workflows/
|
|
CODER_RELEASE: ${{ !inputs.dry_run }}
|
|
CODER_DRY_RUN: ${{ inputs.dry_run }}
|
|
CODER_RELEASE_CHANNEL: ${{ inputs.release_channel }}
|
|
CODER_RELEASE_NOTES: ${{ inputs.release_notes }}
|
|
|
|
jobs:
|
|
# Only allow maintainers/admins to release.
|
|
check-perms:
|
|
runs-on: ${{ github.repository_owner == 'coder' && 'depot-ubuntu-22.04-8' || 'ubuntu-latest' }}
|
|
steps:
|
|
- name: Allow only maintainers/admins
|
|
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
|
with:
|
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
script: |
|
|
const {data} = await github.rest.repos.getCollaboratorPermissionLevel({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
username: context.actor
|
|
});
|
|
const role = data.role_name || data.user?.role_name || data.permission;
|
|
const perms = data.user?.permissions || {};
|
|
core.info(`Actor ${context.actor} permission=${data.permission}, role_name=${role}`);
|
|
|
|
const allowed =
|
|
role === 'admin' ||
|
|
role === 'maintain' ||
|
|
perms.admin === true ||
|
|
perms.maintain === true;
|
|
|
|
if (!allowed) core.setFailed('Denied: requires maintain or admin');
|
|
|
|
release:
|
|
name: Build and publish
|
|
needs: [check-perms]
|
|
runs-on: ${{ github.repository_owner == 'coder' && 'depot-ubuntu-22.04-8' || 'ubuntu-latest' }}
|
|
# Gates access to the signing secrets and identities. The release-signer
|
|
# identity provider only exchanges tokens for this workflow when it is
|
|
# dispatched on main or release/* in this environment.
|
|
environment: release
|
|
permissions:
|
|
# Required to publish a release
|
|
contents: write
|
|
# Pushes images and charts to the ghcr.io/coder/*-staging packages only;
|
|
# coder/ghcr-publisher alone can write the public ones.
|
|
packages: write
|
|
# Necessary for GCP authentication (https://github.com/google-github-actions/setup-gcloud#usage)
|
|
# Also necessary for keyless cosign (https://docs.sigstore.dev/cosign/signing/overview/)
|
|
# And for GitHub Actions attestation
|
|
id-token: write
|
|
# Required for GitHub Actions attestation
|
|
attestations: write
|
|
env:
|
|
# Necessary for Docker manifest
|
|
DOCKER_CLI_EXPERIMENTAL: "enabled"
|
|
outputs:
|
|
version: ${{ steps.version.outputs.version }}
|
|
steps:
|
|
- name: Harden Runner
|
|
uses: step-security/harden-runner@dc2769abcc0fcfbadfc1df54081c1608579ef6b2 # v2.22.2
|
|
with:
|
|
egress-policy: audit
|
|
|
|
- name: Checkout
|
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
with:
|
|
fetch-depth: 0
|
|
persist-credentials: false
|
|
# Check out the dispatched commit first so the step below runs from reviewed workflow
|
|
# content before any file from the commit input's tree.
|
|
ref: ${{ github.sha }}
|
|
|
|
# Every later step runs files from the working tree with release credentials, dry run or not,
|
|
# so the commit input must be proven to be on the dispatched branch before it is checked out.
|
|
- name: Check out the commit being released
|
|
if: ${{ inputs.commit != '' }}
|
|
env:
|
|
COMMIT: ${{ inputs.commit }}
|
|
run: |
|
|
set -euo pipefail
|
|
|
|
if [[ ! "${COMMIT}" =~ ^[0-9a-f]{40}$ ]]; then
|
|
echo "::error::commit must be a full 40-character SHA, got '${COMMIT}'"
|
|
exit 1
|
|
fi
|
|
if ! git merge-base --is-ancestor "${COMMIT}" "${GITHUB_SHA}"; then
|
|
echo "::error::${COMMIT} is not on ${GITHUB_REF}"
|
|
exit 1
|
|
fi
|
|
git checkout --quiet --detach "${COMMIT}"
|
|
|
|
# Only the release App may create tags (ruleset "Release tags (App only)"), and this job only
|
|
# runs after a release manager other than the dispatcher approves the `release` environment.
|
|
# So the tag is created here, at the commit being released, instead of being pushed by a person
|
|
# beforehand.
|
|
- name: Generate release App token for tagging
|
|
id: tag_app_token
|
|
if: ${{ !inputs.dry_run }}
|
|
# The App's key is a non-exportable Cloud KMS key; only this workflow, in this environment,
|
|
# may sign with it.
|
|
uses: coder/github-app-token-action@00eaec58ee1bfea9c8b48655b7ab7470b07739e5 # main 2026-11-17
|
|
with:
|
|
client-id: ${{ secrets.RELEASE_APP_ID }}
|
|
kms-key: ${{ secrets.RELEASE_APP_KMS_KEY }}
|
|
workload-identity-provider: ${{ secrets.APP_KEYS_WORKLOAD_ID_PROVIDER }}
|
|
owner: coder
|
|
repositories: coder
|
|
permissions: |
|
|
contents: write
|
|
workflows: write
|
|
# Revoked by "Revoke the tagging token" right after the tag exists, rather than at
|
|
# the end of the job, since everything in between runs code from the release commit.
|
|
skip-token-revoke: true
|
|
|
|
- name: Create release tag
|
|
if: ${{ !inputs.dry_run }}
|
|
env:
|
|
GH_TOKEN: ${{ steps.tag_app_token.outputs.token }}
|
|
VERSION: ${{ inputs.version }}
|
|
COMMIT: ${{ inputs.commit }}
|
|
run: |
|
|
set -euo pipefail
|
|
|
|
if [[ ! "${VERSION}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-rc\.[0-9]+)?$ ]]; then
|
|
echo "::error::version must look like v2.39.2 or v2.40.0-rc.0, got '${VERSION}'"
|
|
exit 1
|
|
fi
|
|
if [[ ! "${COMMIT}" =~ ^[0-9a-f]{40}$ ]]; then
|
|
echo "::error::commit must be a full 40-character SHA, got '${COMMIT}'"
|
|
exit 1
|
|
fi
|
|
# The commit must already be on the dispatched branch, i.e. reviewed.
|
|
if ! git merge-base --is-ancestor "${COMMIT}" "${GITHUB_SHA}"; then
|
|
echo "::error::${COMMIT} is not on ${GITHUB_REF}"
|
|
exit 1
|
|
fi
|
|
|
|
# Non-RC releases must run on their release/X.Y branch; RCs on main or release/X.Y.
|
|
base_version="${VERSION#v}"
|
|
base_version="${base_version%%-*}"
|
|
release_branch="release/${base_version%.*}"
|
|
if [[ "${VERSION}" == *-rc.* ]]; then
|
|
allowed=("refs/heads/main" "refs/heads/${release_branch}")
|
|
else
|
|
allowed=("refs/heads/${release_branch}")
|
|
fi
|
|
if [[ ! " ${allowed[*]} " == *" ${GITHUB_REF} "* ]]; then
|
|
echo "::error::${VERSION} must be released from ${allowed[*]}, not ${GITHUB_REF}"
|
|
exit 1
|
|
fi
|
|
|
|
# Re-running a release whose tag already exists is fine, as long as it is this commit.
|
|
if existing="$(gh api "repos/${GITHUB_REPOSITORY}/git/ref/tags/${VERSION}" --jq .object.sha 2>/dev/null)"; then
|
|
target="$(gh api "repos/${GITHUB_REPOSITORY}/git/tags/${existing}" --jq .object.sha 2>/dev/null || echo "${existing}")"
|
|
if [[ "${target}" != "${COMMIT}" ]]; then
|
|
echo "::error::tag ${VERSION} already exists at ${target}, not ${COMMIT}"
|
|
exit 1
|
|
fi
|
|
echo "Tag ${VERSION} already exists at ${COMMIT}."
|
|
exit 0
|
|
fi
|
|
|
|
# Each version needs its own commit: version.sh refuses a commit with two release tags, so
|
|
# tagging a commit that was already released would only fail the build and leave a stray tag.
|
|
released="$(git tag --points-at "${COMMIT}" --list 'v*' | paste -sd ' ' -)"
|
|
if [[ -n "${released}" ]]; then
|
|
echo "::error::${COMMIT} was already released as ${released}; merge a new commit to ${GITHUB_REF#refs/heads/} and release that"
|
|
exit 1
|
|
fi
|
|
|
|
tag_object="$(gh api "repos/${GITHUB_REPOSITORY}/git/tags" \
|
|
-f tag="${VERSION}" -f message="Release ${VERSION}" -f object="${COMMIT}" -f type=commit \
|
|
--jq .sha)"
|
|
gh api "repos/${GITHUB_REPOSITORY}/git/refs" -f ref="refs/tags/${VERSION}" -f sha="${tag_object}" >/dev/null
|
|
echo "Created annotated tag ${VERSION} at ${COMMIT}."
|
|
|
|
- name: Revoke the tagging token
|
|
if: ${{ always() && steps.tag_app_token.outputs.token != '' }}
|
|
env:
|
|
GH_TOKEN: ${{ steps.tag_app_token.outputs.token }}
|
|
run: gh api -X DELETE installation/token || echo "::warning::could not revoke the tagging token; it expires within an hour"
|
|
|
|
# actions/checkout fetches tags as lightweight tags
|
|
# (https://github.com/actions/checkout/issues/290); refetch so the annotated release tag, created
|
|
# above, is present for version.sh.
|
|
- name: Fetch git tags
|
|
run: git fetch --tags --force
|
|
|
|
- name: Print version
|
|
id: version
|
|
run: |
|
|
set -euo pipefail
|
|
version="$(./scripts/version.sh)"
|
|
echo "version=$version" >> "$GITHUB_OUTPUT"
|
|
# Speed up future version.sh calls.
|
|
echo "CODER_FORCE_VERSION=$version" >> "$GITHUB_ENV"
|
|
echo "$version"
|
|
|
|
# Verify that all expectations for a release are met.
|
|
- name: Verify release input
|
|
if: ${{ !inputs.dry_run }}
|
|
env:
|
|
INPUT_VERSION: ${{ inputs.version }}
|
|
run: |
|
|
set -euo pipefail
|
|
|
|
version="$(./scripts/version.sh)"
|
|
if [[ "v${version}" != "${INPUT_VERSION}" ]]; then
|
|
echo "Version from the tag (${version}) does not match the version input (${INPUT_VERSION})."
|
|
exit 1
|
|
fi
|
|
|
|
# Derive the release branch from the version tag.
|
|
# Non-RC releases must be on a release/X.Y branch.
|
|
# RC tags are allowed on any branch (typically main).
|
|
version="$(./scripts/version.sh)"
|
|
# Strip any pre-release suffix first (e.g. 2.32.0-rc.0 -> 2.32.0)
|
|
base_version="${version%%-*}"
|
|
# Then strip patch to get major.minor (e.g. 2.32.0 -> 2.32)
|
|
release_branch="release/${base_version%.*}"
|
|
|
|
if [[ "$version" == *-rc.* ]]; then
|
|
echo "RC release detected, skipping release branch check (RC tags are cut from main)."
|
|
else
|
|
branch_contains_tag=$(git branch --remotes --contains "refs/tags/${INPUT_VERSION}" --list "*/${release_branch}" --format='%(refname)')
|
|
if [[ -z "${branch_contains_tag}" ]]; then
|
|
echo "Ref tag must exist in a branch named ${release_branch} when creating a non-RC release, did you use scripts/release.sh?"
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
if [[ -z "${CODER_RELEASE_NOTES}" ]]; then
|
|
echo "Release notes are required to create a release, did you use scripts/release.sh?"
|
|
exit 1
|
|
fi
|
|
|
|
echo "Release inputs verified:"
|
|
echo
|
|
echo "- Ref: ${GITHUB_REF} (tag ${INPUT_VERSION})"
|
|
echo "- Version: ${version}"
|
|
echo "- Release channel: ${CODER_RELEASE_CHANNEL}"
|
|
echo "- Release branch: ${release_branch}"
|
|
echo "- Release notes: true"
|
|
|
|
- name: Create release notes file
|
|
run: |
|
|
set -euo pipefail
|
|
|
|
release_notes_file="$(mktemp -t release_notes.XXXXXX)"
|
|
echo "$CODER_RELEASE_NOTES" > "$release_notes_file"
|
|
echo CODER_RELEASE_NOTES_FILE="$release_notes_file" >> "$GITHUB_ENV"
|
|
|
|
- name: Show release notes
|
|
run: |
|
|
set -euo pipefail
|
|
cat "$CODER_RELEASE_NOTES_FILE"
|
|
|
|
- name: Docker Login
|
|
uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
# Shared with build.yaml so main builds and releases are signed the same
|
|
# way. Signing material is deleted before the action returns. Dry runs
|
|
# sign too, so they exercise the signing path; they only build commits
|
|
# already on the dispatched branch (checked after checkout above).
|
|
- name: Build and sign binaries
|
|
id: build
|
|
uses: ./.github/actions/build-coder
|
|
with:
|
|
sign: "true"
|
|
notarize: "true"
|
|
extra-tools: "helm cosign syft"
|
|
apt-packages: nsis
|
|
targets: >-
|
|
build/coder_@VERSION@_linux_amd64.tar.gz
|
|
build/coder_@VERSION@_linux_armv7.tar.gz
|
|
build/coder_@VERSION@_linux_arm64.tar.gz
|
|
build/coder_@VERSION@_linux_amd64.apk
|
|
build/coder_@VERSION@_linux_armv7.apk
|
|
build/coder_@VERSION@_linux_arm64.apk
|
|
build/coder_@VERSION@_linux_amd64.deb
|
|
build/coder_@VERSION@_linux_armv7.deb
|
|
build/coder_@VERSION@_linux_arm64.deb
|
|
build/coder_@VERSION@_linux_amd64.rpm
|
|
build/coder_@VERSION@_linux_armv7.rpm
|
|
build/coder_@VERSION@_linux_arm64.rpm
|
|
build/coder_@VERSION@_darwin_amd64.zip
|
|
build/coder_@VERSION@_darwin_arm64.zip
|
|
build/coder_@VERSION@_windows_amd64.zip
|
|
build/coder_@VERSION@_windows_arm64.zip
|
|
build/coder_@VERSION@_windows_amd64_installer.exe
|
|
build/coder_helm_@VERSION@.tgz
|
|
build/provisioner_helm_@VERSION@.tgz
|
|
build/ai-gateway_helm_@VERSION@.tgz
|
|
ev-workload-identity-provider: ${{ vars.GCP_CODE_SIGNING_WORKLOAD_ID_PROVIDER }}
|
|
ev-service-account: ${{ vars.GCP_CODE_SIGNING_SERVICE_ACCOUNT }}
|
|
ev-key: ${{ secrets.EV_KEY }}
|
|
ev-keystore: ${{ secrets.EV_KEYSTORE }}
|
|
ev-tsa-url: ${{ secrets.EV_TSA_URL }}
|
|
ev-signing-cert: ${{ secrets.EV_SIGNING_CERT }}
|
|
release-signer-workload-identity-provider: ${{ secrets.GPG_KMS_WORKLOAD_ID_PROVIDER }}
|
|
release-signer-service-account: ${{ secrets.GPG_KMS_SERVICE_ACCOUNT }}
|
|
gpg-release-key: ${{ secrets.GPG_RELEASE_KEY_BASE64 }}
|
|
gpg-kms-key: ${{ secrets.GPG_KMS_KEY }}
|
|
ac-certificate-pem: ${{ secrets.AC_CERTIFICATE_PEM }}
|
|
ac-kms-key-ring: ${{ secrets.AC_KMS_KEY_RING }}
|
|
ac-kms-key: ${{ secrets.AC_KMS_KEY }}
|
|
ac-apikey-issuer-id: ${{ secrets.AC_APIKEY_ISSUER_ID }}
|
|
ac-apikey-id: ${{ secrets.AC_APIKEY_ID }}
|
|
ac-apikey-p8-base64: ${{ secrets.AC_APIKEY_P8_BASE64 }}
|
|
|
|
- name: Test migrations from current ref to main
|
|
run: |
|
|
POSTGRES_VERSION=13 make test-migrations
|
|
|
|
- name: Determine base image tag
|
|
id: image-base-tag
|
|
run: |
|
|
set -euo pipefail
|
|
if [[ "${CODER_RELEASE:-}" != *t* ]] || [[ "${CODER_DRY_RUN:-}" == *t* ]]; then
|
|
# Empty value means use the default and avoid building a fresh one.
|
|
echo "tag=" >> "$GITHUB_OUTPUT"
|
|
else
|
|
# Releases push to the staging package; coder/ghcr-publisher copies
|
|
# the attested digest to ghcr.io/coder/coder-base (see "Promote").
|
|
echo "tag=$(CODER_IMAGE_BASE=ghcr.io/coder/coder-base-staging ./scripts/image_tag.sh)" >> "$GITHUB_OUTPUT"
|
|
fi
|
|
|
|
- name: Create empty base-build-context directory
|
|
if: steps.image-base-tag.outputs.tag != ''
|
|
run: mkdir base-build-context
|
|
|
|
- name: Install depot.dev CLI
|
|
if: steps.image-base-tag.outputs.tag != ''
|
|
uses: depot/setup-action@91bc8495a33ebfc504ffc89e5674379ccf23c29c # v1.7.2
|
|
|
|
# This uses OIDC authentication, so no auth variables are required.
|
|
- name: Build base Docker image via depot.dev
|
|
id: build_base_image
|
|
if: steps.image-base-tag.outputs.tag != ''
|
|
uses: depot/build-push-action@98e78adca7817480b8185f474a400b451d74e287 # v1.18.0
|
|
with:
|
|
project: wl5hnrrkns
|
|
context: base-build-context
|
|
file: scripts/Dockerfile.base
|
|
platforms: linux/amd64,linux/arm64,linux/arm/v7
|
|
provenance: true
|
|
sbom: true
|
|
pull: true
|
|
no-cache: true
|
|
push: true
|
|
tags: |
|
|
${{ steps.image-base-tag.outputs.tag }}
|
|
|
|
- name: Verify that images are pushed properly
|
|
if: steps.image-base-tag.outputs.tag != ''
|
|
run: |
|
|
# retry 10 times with a 5 second delay as the images may not be
|
|
# available immediately
|
|
for i in {1..10}; do
|
|
rc=0
|
|
raw_manifests=$(docker buildx imagetools inspect --raw "${IMAGE_TAG}") || rc=$?
|
|
if [[ "$rc" -eq 0 ]]; then
|
|
break
|
|
fi
|
|
if [[ "$i" -eq 10 ]]; then
|
|
echo "Failed to pull manifests after 10 retries"
|
|
exit 1
|
|
fi
|
|
echo "Failed to pull manifests, retrying in 5 seconds"
|
|
sleep 5
|
|
done
|
|
|
|
manifests=$(
|
|
echo "$raw_manifests" | \
|
|
jq -r '.manifests[].platform | .os + "/" + .architecture + (if .variant then "/" + .variant else "" end)'
|
|
)
|
|
|
|
# Verify all 3 platforms are present.
|
|
set -euxo pipefail
|
|
echo "$manifests" | grep -q linux/amd64
|
|
echo "$manifests" | grep -q linux/arm64
|
|
echo "$manifests" | grep -q linux/arm/v7
|
|
env:
|
|
# By digest: the staging tag can be moved by anyone who can write staging.
|
|
IMAGE_TAG: ghcr.io/coder/coder-base-staging@${{ steps.build_base_image.outputs.digest }}
|
|
|
|
- name: GitHub Attestation for Base Docker image
|
|
id: attest_base
|
|
if: ${{ !inputs.dry_run && steps.build_base_image.outputs.digest != '' }}
|
|
continue-on-error: true
|
|
uses: actions/attest@1e69f48acb82d1966a394da916b4c1698aa569d6 # v4.2.2
|
|
with:
|
|
subject-name: ghcr.io/coder/coder-base-staging
|
|
subject-digest: ${{ steps.build_base_image.outputs.digest }}
|
|
push-to-registry: true
|
|
|
|
- name: Build Linux Docker images
|
|
id: build_docker
|
|
run: |
|
|
set -euxo pipefail
|
|
|
|
# we can't build multi-arch if the images aren't pushed, so quit now
|
|
# if dry-running
|
|
if [[ "$CODER_RELEASE" != *t* ]]; then
|
|
echo Skipping multi-arch docker builds due to dry-run.
|
|
exit 0
|
|
fi
|
|
|
|
# build Docker images for each architecture
|
|
version="$(./scripts/version.sh)"
|
|
make build/coder_"$version"_linux_{amd64,arm64,armv7}.tag
|
|
|
|
# Anyone who can write the staging package can move its tags, so
|
|
# every digest below comes from the registry's response to our own
|
|
# push, and the multi-arch index is built from those digests. No
|
|
# staging tag is ever read back.
|
|
refs=()
|
|
for arch in amd64 arm64 armv7; do
|
|
image_tag="$(cat "build/coder_${version}_linux_${arch}.tag")"
|
|
push_output="$(docker push "$image_tag")"
|
|
echo "$push_output"
|
|
digest="$(sed -nE 's/^.*: digest: (sha256:[0-9a-f]{64}) size: [0-9]+$/\1/p' <<<"$push_output" | tail -n1)"
|
|
if [[ -z "$digest" ]]; then
|
|
echo "::error::docker push printed no digest for ${image_tag}"
|
|
exit 1
|
|
fi
|
|
refs+=("${CODER_IMAGE_BASE}@${digest}")
|
|
done
|
|
|
|
multiarch_image="$(./scripts/image_tag.sh)"
|
|
docker manifest create --amend "$multiarch_image" "${refs[@]}"
|
|
push_output="$(docker manifest push "$multiarch_image")"
|
|
echo "$push_output"
|
|
multiarch_digest="$(grep -oE '^sha256:[0-9a-f]{64}$' <<<"$push_output" | tail -n1)"
|
|
if [[ -z "$multiarch_digest" ]]; then
|
|
echo "::error::docker manifest push printed no digest for ${multiarch_image}"
|
|
exit 1
|
|
fi
|
|
{
|
|
echo "multiarch_image=${multiarch_image}"
|
|
echo "multiarch_digest=${multiarch_digest}"
|
|
echo "multiarch_ref=${CODER_IMAGE_BASE}@${multiarch_digest}"
|
|
} >> "$GITHUB_OUTPUT"
|
|
|
|
# For debugging, print all docker image tags
|
|
docker images
|
|
|
|
# ghcr.io/coder/coder:latest is moved by coder/ghcr-publisher when it
|
|
# promotes the highest stable version.
|
|
env:
|
|
# Releases push to the staging package; coder/ghcr-publisher copies
|
|
# the attested digest to ghcr.io/coder/coder (see "Promote").
|
|
CODER_IMAGE_BASE: ghcr.io/coder/coder-staging
|
|
# Build on the base image just built, by digest, so nothing can swap
|
|
# the tag in between. Empty (no fresh base) falls back to the default.
|
|
CODER_BASE_IMAGE_TAG: ${{ steps.build_base_image.outputs.digest != '' && format('ghcr.io/coder/coder-base-staging@{0}', steps.build_base_image.outputs.digest) || '' }}
|
|
|
|
- name: SBOM Generation and Attestation
|
|
if: ${{ !inputs.dry_run }}
|
|
env:
|
|
COSIGN_EXPERIMENTAL: '1'
|
|
# By digest (see "Build Linux Docker images").
|
|
MULTIARCH_REF: ${{ steps.build_docker.outputs.multiarch_ref }}
|
|
VERSION: ${{ steps.version.outputs.version }}
|
|
run: |
|
|
set -euxo pipefail
|
|
|
|
# Generate SBOM for multi-arch image with version in filename
|
|
echo "Generating SBOM for multi-arch image: ${MULTIARCH_REF}"
|
|
syft "${MULTIARCH_REF}" -o spdx-json > "coder_${VERSION}_sbom.spdx.json"
|
|
|
|
# The attestation is stored next to the image digest; coder/ghcr-publisher
|
|
# copies it to ghcr.io/coder/coder along with the image.
|
|
echo "Attesting SBOM to multi-arch image: ${MULTIARCH_REF}"
|
|
cosign clean --force=true "${MULTIARCH_REF}"
|
|
cosign attest --type spdxjson \
|
|
--predicate "coder_${VERSION}_sbom.spdx.json" \
|
|
--yes \
|
|
"${MULTIARCH_REF}"
|
|
|
|
- name: GitHub Attestation for Docker image
|
|
id: attest_main
|
|
if: ${{ !inputs.dry_run }}
|
|
continue-on-error: true
|
|
uses: actions/attest@1e69f48acb82d1966a394da916b4c1698aa569d6 # v4.2.2
|
|
with:
|
|
subject-name: ghcr.io/coder/coder-staging
|
|
subject-digest: ${{ steps.build_docker.outputs.multiarch_digest }}
|
|
push-to-registry: true
|
|
|
|
- name: GitHub Attestation for release binaries
|
|
id: attest_binaries
|
|
if: ${{ !inputs.dry_run }}
|
|
continue-on-error: true
|
|
uses: actions/attest@1e69f48acb82d1966a394da916b4c1698aa569d6 # v4.2.2
|
|
with:
|
|
subject-path: |
|
|
./build/*.tar.gz
|
|
./build/*.zip
|
|
./build/*.deb
|
|
./build/*.rpm
|
|
./build/*.apk
|
|
./build/*_installer.exe
|
|
./build/*_helm_*.tgz
|
|
./build/provisioner_helm_*.tgz
|
|
|
|
# Report attestation failures but don't fail the workflow
|
|
- name: Check attestation status
|
|
if: ${{ !inputs.dry_run }}
|
|
run: | # zizmor: ignore[template-injection] We're just reading steps.attest_x.outcome here, no risk of injection
|
|
if [[ "${{ steps.attest_base.outcome }}" == "failure" && "${{ steps.attest_base.conclusion }}" != "skipped" ]]; then
|
|
echo "::warning::GitHub attestation for base image failed"
|
|
fi
|
|
if [[ "${{ steps.attest_main.outcome }}" == "failure" ]]; then
|
|
echo "::warning::GitHub attestation for main image failed"
|
|
fi
|
|
if [[ "${{ steps.attest_binaries.outcome }}" == "failure" && "${{ steps.attest_binaries.conclusion }}" != "skipped" ]]; then
|
|
echo "::warning::GitHub attestation for release binaries failed"
|
|
fi
|
|
|
|
# The OCI charts go to staging like the images; coder/ghcr-publisher
|
|
# copies them to oci://ghcr.io/coder/chart. The digests come from helm's
|
|
# response to the push, never from a staging tag.
|
|
- name: Push Helm charts to staging
|
|
id: chart_digests
|
|
if: ${{ !inputs.dry_run }}
|
|
run: |
|
|
set -euo pipefail
|
|
version="$(./scripts/version.sh)"
|
|
for chart in coder provisioner ai-gateway; do
|
|
out="$(helm push "build/${chart}_helm_${version}.tgz" oci://ghcr.io/coder/chart-staging 2>&1)"
|
|
echo "$out"
|
|
digest="$(sed -nE 's/^Digest: (sha256:[0-9a-f]{64})$/\1/p' <<<"$out")"
|
|
if [[ -z "$digest" ]]; then
|
|
echo "::error::helm push of ${chart} printed no digest"
|
|
exit 1
|
|
fi
|
|
echo "${chart//-/_}=${digest}" >> "$GITHUB_OUTPUT"
|
|
done
|
|
|
|
# coder/ghcr-publisher promotes a staging digest only with a release
|
|
# attestation from this workflow stating the version, the commit and the
|
|
# public package it is for, so a digest can't be reused for another
|
|
# version or package. These must succeed.
|
|
- name: Release attestation predicates
|
|
id: release_predicates
|
|
if: ${{ !inputs.dry_run }}
|
|
env:
|
|
VERSION: ${{ steps.version.outputs.version }}
|
|
run: |
|
|
set -euo pipefail
|
|
commit="$(git rev-parse HEAD)"
|
|
tag_commit="$(git rev-list -n 1 "v${VERSION}")"
|
|
if [[ "$commit" != "$tag_commit" ]]; then
|
|
echo "::error::checked out ${commit}, but v${VERSION} points at ${tag_commit}"
|
|
exit 1
|
|
fi
|
|
for pair in \
|
|
coder=ghcr.io/coder/coder \
|
|
coder_base=ghcr.io/coder/coder-base \
|
|
chart_coder=ghcr.io/coder/chart/coder \
|
|
chart_provisioner=ghcr.io/coder/chart/coder-provisioner \
|
|
chart_ai_gateway=ghcr.io/coder/chart/coder-ai-gateway; do
|
|
predicate="$(jq -nc --arg v "v${VERSION}" --arg c "$commit" --arg t "${pair#*=}" \
|
|
'{version: $v, commit: $c, target: $t}')"
|
|
echo "${pair%%=*}=${predicate}" >> "$GITHUB_OUTPUT"
|
|
done
|
|
|
|
- name: Release attestation for coder image
|
|
if: ${{ !inputs.dry_run }}
|
|
uses: actions/attest@1e69f48acb82d1966a394da916b4c1698aa569d6 # v4.2.2
|
|
with:
|
|
subject-name: ghcr.io/coder/coder-staging
|
|
subject-digest: ${{ steps.build_docker.outputs.multiarch_digest }}
|
|
predicate-type: https://coder.com/attestations/release/v1
|
|
predicate: ${{ steps.release_predicates.outputs.coder }}
|
|
|
|
- name: Release attestation for coder-base image
|
|
if: ${{ !inputs.dry_run }}
|
|
uses: actions/attest@1e69f48acb82d1966a394da916b4c1698aa569d6 # v4.2.2
|
|
with:
|
|
subject-name: ghcr.io/coder/coder-base-staging
|
|
subject-digest: ${{ steps.build_base_image.outputs.digest }}
|
|
predicate-type: https://coder.com/attestations/release/v1
|
|
predicate: ${{ steps.release_predicates.outputs.coder_base }}
|
|
|
|
- name: Release attestation for coder Helm chart
|
|
if: ${{ !inputs.dry_run }}
|
|
uses: actions/attest@1e69f48acb82d1966a394da916b4c1698aa569d6 # v4.2.2
|
|
with:
|
|
subject-name: ghcr.io/coder/chart-staging/coder
|
|
subject-digest: ${{ steps.chart_digests.outputs.coder }}
|
|
predicate-type: https://coder.com/attestations/release/v1
|
|
predicate: ${{ steps.release_predicates.outputs.chart_coder }}
|
|
|
|
- name: Release attestation for coder-provisioner Helm chart
|
|
if: ${{ !inputs.dry_run }}
|
|
uses: actions/attest@1e69f48acb82d1966a394da916b4c1698aa569d6 # v4.2.2
|
|
with:
|
|
subject-name: ghcr.io/coder/chart-staging/coder-provisioner
|
|
subject-digest: ${{ steps.chart_digests.outputs.provisioner }}
|
|
predicate-type: https://coder.com/attestations/release/v1
|
|
predicate: ${{ steps.release_predicates.outputs.chart_provisioner }}
|
|
|
|
- name: Release attestation for coder-ai-gateway Helm chart
|
|
if: ${{ !inputs.dry_run }}
|
|
uses: actions/attest@1e69f48acb82d1966a394da916b4c1698aa569d6 # v4.2.2
|
|
with:
|
|
subject-name: ghcr.io/coder/chart-staging/coder-ai-gateway
|
|
subject-digest: ${{ steps.chart_digests.outputs.ai_gateway }}
|
|
predicate-type: https://coder.com/attestations/release/v1
|
|
predicate: ${{ steps.release_predicates.outputs.chart_ai_gateway }}
|
|
|
|
# Only coder/ghcr-publisher can write the public images and charts. It copies
|
|
# each staging digest after verifying its release attestation and that this
|
|
# run's `release` environment was approved. coder-ghcr-dispatch has only
|
|
# contents: write, on coder/ghcr-publisher only: enough for a
|
|
# repository_dispatch and nothing else. The token is revoked right after.
|
|
- name: Generate coder-ghcr-dispatch token
|
|
id: promote_app_token
|
|
if: ${{ !inputs.dry_run }}
|
|
uses: coder/github-app-token-action@00eaec58ee1bfea9c8b48655b7ab7470b07739e5 # main 2026-11-17
|
|
with:
|
|
client-id: ${{ secrets.CODER_GHCR_DISPATCH_APP_ID }}
|
|
kms-key: ${{ secrets.CODER_GHCR_DISPATCH_APP_KMS_KEY }}
|
|
workload-identity-provider: ${{ secrets.APP_KEYS_WORKLOAD_ID_PROVIDER }}
|
|
owner: coder
|
|
repositories: ghcr-publisher
|
|
permissions: |
|
|
contents: write
|
|
skip-token-revoke: true
|
|
|
|
- name: Promote images and charts
|
|
if: ${{ !inputs.dry_run }}
|
|
env:
|
|
GH_TOKEN: ${{ steps.promote_app_token.outputs.token }}
|
|
VERSION: ${{ steps.version.outputs.version }}
|
|
DIGEST_CODER: ${{ steps.build_docker.outputs.multiarch_digest }}
|
|
DIGEST_CODER_BASE: ${{ steps.build_base_image.outputs.digest }}
|
|
DIGEST_CHART_CODER: ${{ steps.chart_digests.outputs.coder }}
|
|
DIGEST_CHART_CODER_PROVISIONER: ${{ steps.chart_digests.outputs.provisioner }}
|
|
DIGEST_CHART_CODER_AI_GATEWAY: ${{ steps.chart_digests.outputs.ai_gateway }}
|
|
run: |
|
|
set -euo pipefail
|
|
|
|
# Anonymous reads: these packages are public.
|
|
remote_digest() {
|
|
local ref="$1" repo tag token
|
|
repo="${ref#ghcr.io/}"
|
|
tag="${repo##*:}"
|
|
repo="${repo%:*}"
|
|
token="$(curl -fsS "https://ghcr.io/token?scope=repository:${repo}:pull" | jq -r .token)"
|
|
curl -fsS -o /dev/null -D - -I \
|
|
-H "Authorization: Bearer ${token}" \
|
|
-H "Accept: application/vnd.oci.image.index.v1+json, application/vnd.oci.image.manifest.v1+json, application/vnd.docker.distribution.manifest.list.v2+json, application/vnd.docker.distribution.manifest.v2+json" \
|
|
"https://ghcr.io/v2/${repo}/manifests/${tag}" |
|
|
tr -d '\r' | awk -F': ' 'tolower($1) == "docker-content-digest" {print $2}'
|
|
}
|
|
|
|
declare -A expected=(
|
|
["ghcr.io/coder/coder:v${VERSION}"]="${DIGEST_CODER}"
|
|
["ghcr.io/coder/coder-base:v${VERSION}"]="${DIGEST_CODER_BASE}"
|
|
["ghcr.io/coder/chart/coder:${VERSION}"]="${DIGEST_CHART_CODER}"
|
|
["ghcr.io/coder/chart/coder-provisioner:${VERSION}"]="${DIGEST_CHART_CODER_PROVISIONER}"
|
|
["ghcr.io/coder/chart/coder-ai-gateway:${VERSION}"]="${DIGEST_CHART_CODER_AI_GATEWAY}"
|
|
)
|
|
for arch in amd64 arm64 armv7; do
|
|
expected["ghcr.io/coder/coder:v${VERSION}-${arch}"]=""
|
|
done
|
|
|
|
# A re-run of this job builds new digests. If an earlier attempt
|
|
# already promoted this version, the publisher keeps that build
|
|
# (after verifying it), so a tag that existed before the dispatch may
|
|
# stay where it was.
|
|
declare -A before=()
|
|
for ref in "${!expected[@]}"; do
|
|
if got="$(remote_digest "$ref" 2>/dev/null)" && [[ -n "$got" ]]; then
|
|
before["$ref"]="$got"
|
|
echo "${ref} already exists at ${got}"
|
|
fi
|
|
done
|
|
|
|
gh api repos/coder/ghcr-publisher/dispatches \
|
|
-f event_type=promote-coder \
|
|
-f "client_payload[version]=v${VERSION}" \
|
|
-f "client_payload[coder]=${DIGEST_CODER}" \
|
|
-f "client_payload[coder_base]=${DIGEST_CODER_BASE}" \
|
|
-f "client_payload[chart_coder]=${DIGEST_CHART_CODER}" \
|
|
-f "client_payload[chart_coder_provisioner]=${DIGEST_CHART_CODER_PROVISIONER}" \
|
|
-f "client_payload[chart_coder_ai_gateway]=${DIGEST_CHART_CODER_AI_GATEWAY}"
|
|
# Nothing else needs the token.
|
|
gh api -X DELETE installation/token || echo "::warning::could not revoke the promotion token; it expires within an hour"
|
|
unset GH_TOKEN
|
|
|
|
# The token couldn't read the publisher's runs anyway, so wait until
|
|
# every public tag serves the expected digest (or the one it already
|
|
# had). The arch tags are copied last.
|
|
deadline=$((SECONDS + 1800))
|
|
while true; do
|
|
pending=()
|
|
for ref in "${!expected[@]}"; do
|
|
if ! got="$(remote_digest "$ref" 2>/dev/null)" || [[ -z "$got" ]]; then
|
|
pending+=("$ref (missing)")
|
|
continue
|
|
fi
|
|
want="${expected[$ref]}"
|
|
if [[ -n "$want" && "$got" != "$want" && "$got" != "${before[$ref]:-}" ]]; then
|
|
echo "::error::${ref} is ${got}, expected ${want}"
|
|
exit 1
|
|
fi
|
|
done
|
|
if [[ ${#pending[@]} -eq 0 ]]; then
|
|
echo "All images and charts are promoted."
|
|
break
|
|
fi
|
|
if ((SECONDS > deadline)); then
|
|
printf '::error::Promotion did not finish in 30 minutes; still waiting for:\n' >&2
|
|
printf ' %s\n' "${pending[@]}" >&2
|
|
echo "::error::Check the latest run of https://github.com/coder/ghcr-publisher/actions/workflows/promote-coder.yaml"
|
|
exit 1
|
|
fi
|
|
sleep 20
|
|
done
|
|
|
|
- name: Generate offline docs
|
|
run: |
|
|
version="$(./scripts/version.sh)"
|
|
make -j build/coder_docs_"$version".tgz
|
|
|
|
- name: ls build
|
|
run: ls -lh build
|
|
|
|
- name: Authenticate to Google Cloud (release artifacts)
|
|
uses: google-github-actions/auth@7c6bc770dae815cd3e89ee6cdf493a5fab2cc093 # v3.0.0
|
|
with:
|
|
workload_identity_provider: ${{ vars.GCP_RELEASE_ARTIFACTS_WORKLOAD_ID_PROVIDER }}
|
|
service_account: ${{ vars.GCP_RELEASE_ARTIFACTS_SERVICE_ACCOUNT }}
|
|
|
|
- name: Publish Coder CLI binaries and detached signatures to GCS
|
|
if: ${{ !inputs.dry_run }}
|
|
run: |
|
|
set -euxo pipefail
|
|
|
|
version="$(./scripts/version.sh)"
|
|
|
|
# Source array of slim binaries
|
|
declare -A binaries
|
|
binaries["coder-darwin-amd64"]="coder-slim_${version}_darwin_amd64"
|
|
binaries["coder-darwin-arm64"]="coder-slim_${version}_darwin_arm64"
|
|
binaries["coder-linux-amd64"]="coder-slim_${version}_linux_amd64"
|
|
binaries["coder-linux-arm64"]="coder-slim_${version}_linux_arm64"
|
|
binaries["coder-linux-armv7"]="coder-slim_${version}_linux_armv7"
|
|
binaries["coder-windows-amd64.exe"]="coder-slim_${version}_windows_amd64.exe"
|
|
binaries["coder-windows-arm64.exe"]="coder-slim_${version}_windows_arm64.exe"
|
|
|
|
for cli_name in "${!binaries[@]}"; do
|
|
slim_binary="${binaries[$cli_name]}"
|
|
detached_signature="${slim_binary}.asc"
|
|
gcloud storage cp "./build/${slim_binary}" "gs://releases.coder.com/coder-cli/${version}/${cli_name}"
|
|
gcloud storage cp "./build/${detached_signature}" "gs://releases.coder.com/coder-cli/${version}/${cli_name}.asc"
|
|
# Cloud KMS signature, only present when GPG_KMS_KEY is set.
|
|
if [[ -f "./build/${slim_binary}.v2.asc" ]]; then
|
|
gcloud storage cp "./build/${slim_binary}.v2.asc" "gs://releases.coder.com/coder-cli/${version}/${cli_name}.v2.asc"
|
|
fi
|
|
done
|
|
|
|
# Mint a short-lived installation token from the dedicated release
|
|
# GitHub App. Only the App may create tags (ruleset "Release tags (App
|
|
# only)"), so `gh release create` needs its token for any tag it creates.
|
|
# Dry runs create no release, so they never mint it.
|
|
- name: Generate release App token
|
|
id: release_app_token
|
|
if: ${{ !inputs.dry_run }}
|
|
# The App's key is a non-exportable Cloud KMS key; only this workflow, in this environment,
|
|
# may sign with it.
|
|
uses: coder/github-app-token-action@00eaec58ee1bfea9c8b48655b7ab7470b07739e5 # main 2026-11-17
|
|
with:
|
|
client-id: ${{ secrets.RELEASE_APP_ID }}
|
|
kms-key: ${{ secrets.RELEASE_APP_KMS_KEY }}
|
|
workload-identity-provider: ${{ secrets.APP_KEYS_WORKLOAD_ID_PROVIDER }}
|
|
owner: coder
|
|
repositories: coder
|
|
permissions: |
|
|
contents: write
|
|
workflows: write
|
|
|
|
- name: Publish release
|
|
run: |
|
|
set -euo pipefail
|
|
|
|
publish_args=()
|
|
if [[ $CODER_RELEASE_CHANNEL == "stable" ]]; then
|
|
publish_args+=(--stable)
|
|
fi
|
|
if [[ $CODER_RELEASE_CHANNEL == "rc" ]]; then
|
|
publish_args+=(--rc)
|
|
fi
|
|
if [[ $CODER_DRY_RUN == *t* ]]; then
|
|
publish_args+=(--dry-run)
|
|
fi
|
|
declare -p publish_args
|
|
|
|
# Build the list of files to publish
|
|
files=(
|
|
./build/*_installer.exe
|
|
./build/*.zip
|
|
./build/*.tar.gz
|
|
./build/*.tgz
|
|
./build/*.apk
|
|
./build/*.deb
|
|
./build/*.rpm
|
|
)
|
|
|
|
# The SBOM is only generated for real releases.
|
|
if [[ $CODER_DRY_RUN != *t* ]]; then
|
|
files+=("./coder_${VERSION}_sbom.spdx.json")
|
|
fi
|
|
|
|
./scripts/release/publish.sh \
|
|
"${publish_args[@]}" \
|
|
--release-notes-file "$CODER_RELEASE_NOTES_FILE" \
|
|
"${files[@]}"
|
|
env:
|
|
# Use the dedicated release App token (github-actions[bot] is blocked
|
|
# from creating tags by the tag-create protection ruleset).
|
|
GITHUB_TOKEN: ${{ steps.release_app_token.outputs.token }}
|
|
CODER_GPG_RELEASE_KEY_BASE64: ${{ secrets.GPG_RELEASE_KEY_BASE64 }}
|
|
CODER_GPG_KMS_KEY: ${{ secrets.GPG_KMS_KEY }}
|
|
CODER_GPG_KMS_CREDENTIALS_FILE: ${{ steps.build.outputs.release-signer-credentials-file }}
|
|
VERSION: ${{ steps.version.outputs.version }}
|
|
|
|
# Mark the Linear release as shipped.
|
|
- name: Extract Linear release version
|
|
if: ${{ !inputs.dry_run }}
|
|
id: linear_version
|
|
run: |
|
|
# Skip RC releases — they must not complete the Linear release.
|
|
if [[ "$VERSION" == *-rc* ]]; then
|
|
echo "RC release (${VERSION}), skipping Linear release completion."
|
|
echo "skip=true" >> "$GITHUB_OUTPUT"
|
|
exit 0
|
|
fi
|
|
# Strip patch to get the Linear release version (e.g. 2.32.0 -> 2.32).
|
|
linear_version=$(echo "$VERSION" | cut -d. -f1,2)
|
|
echo "version=$linear_version" >> "$GITHUB_OUTPUT"
|
|
echo "skip=false" >> "$GITHUB_OUTPUT"
|
|
echo "Completing Linear release ${linear_version}"
|
|
env:
|
|
VERSION: ${{ steps.version.outputs.version }}
|
|
|
|
- name: Complete Linear release
|
|
if: ${{ !inputs.dry_run && steps.linear_version.outputs.skip != 'true' }}
|
|
continue-on-error: true
|
|
uses: linear/linear-release-action@30f9ae77461ec29f07fffe0c52edd1909bfbb6f5 # v0.18.1
|
|
with:
|
|
access_key: ${{ secrets.LINEAR_ACCESS_KEY }}
|
|
command: complete
|
|
version: ${{ steps.linear_version.outputs.version }}
|
|
timeout: 300
|
|
|
|
- name: Authenticate to Google Cloud
|
|
uses: google-github-actions/auth@7c6bc770dae815cd3e89ee6cdf493a5fab2cc093 # v3.0.0
|
|
with:
|
|
workload_identity_provider: ${{ vars.GCP_WORKLOAD_ID_PROVIDER }}
|
|
service_account: ${{ vars.GCP_SERVICE_ACCOUNT }}
|
|
|
|
- name: Setup GCloud SDK
|
|
uses: google-github-actions/setup-gcloud@aa5489c8933f4cc7a4f7d45035b3b1440c9c10db # 3.0.1
|
|
|
|
- name: Publish Helm Chart
|
|
if: ${{ !inputs.dry_run }}
|
|
run: |
|
|
set -euo pipefail
|
|
version="$(./scripts/version.sh)"
|
|
mkdir -p build/helm
|
|
cp "build/coder_helm_${version}.tgz" build/helm
|
|
cp "build/provisioner_helm_${version}.tgz" build/helm
|
|
cp "build/ai-gateway_helm_${version}.tgz" build/helm
|
|
gsutil -h "Cache-Control:no-cache,max-age=0" cp "build/helm/coder_helm_${version}.tgz" gs://helm.coder.com/v2
|
|
gsutil -h "Cache-Control:no-cache,max-age=0" cp "build/helm/provisioner_helm_${version}.tgz" gs://helm.coder.com/v2
|
|
gsutil -h "Cache-Control:no-cache,max-age=0" cp "build/helm/ai-gateway_helm_${version}.tgz" gs://helm.coder.com/v2
|
|
|
|
# index.yaml is shared by every release, so two releases publishing
|
|
# concurrently would each merge only their own charts and the last
|
|
# writer would drop the other's entries. The if-generation-match
|
|
# precondition makes the loser fail instead; re-running the job
|
|
# merges against the fresh index.
|
|
index_url=gs://helm.coder.com/v2/index.yaml
|
|
generation="$(gsutil stat "$index_url" | awk '/^ *Generation:/ {print $2}')"
|
|
gsutil cp "$index_url" build/helm/index.yaml
|
|
helm repo index build/helm --url https://helm.coder.com/v2 --merge build/helm/index.yaml
|
|
if ! gsutil -h "Cache-Control:no-cache,max-age=0" -h "x-goog-if-generation-match:${generation}" cp build/helm/index.yaml "$index_url"; then
|
|
echo "::error::index.yaml was modified by another release since it was read (generation $generation). Re-run this job to merge against the current index." >&2
|
|
exit 1
|
|
fi
|
|
|
|
gsutil -h "Cache-Control:no-cache,max-age=0" cp "helm/artifacthub-repo.yml" gs://helm.coder.com/v2
|
|
# The OCI charts (oci://ghcr.io/coder/chart) were promoted above.
|
|
|
|
- name: Upload artifacts to actions (if dry-run)
|
|
if: ${{ inputs.dry_run }}
|
|
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
|
|
with:
|
|
name: release-artifacts
|
|
path: |
|
|
./build/*_installer.exe
|
|
./build/*.zip
|
|
./build/*.tar.gz
|
|
./build/*.tgz
|
|
./build/*.apk
|
|
./build/*.deb
|
|
./build/*.rpm
|
|
./coder_${{ steps.version.outputs.version }}_sbom.spdx.json
|
|
retention-days: 7
|
|
|
|
# The coder-package-publisher App (installed on coder/packages and coder/homebrew-coder) has its key only in
|
|
# the release-publish environment, so the packages dispatch runs here rather than in the release job.
|
|
publish-packages:
|
|
name: Publish to coder/packages
|
|
runs-on: ubuntu-latest
|
|
needs: release
|
|
if: ${{ !inputs.dry_run && inputs.release_channel != 'rc' }}
|
|
environment: release-publish
|
|
permissions:
|
|
contents: read
|
|
id-token: write # Cloud KMS signs the coder-package-publisher App's JWT
|
|
steps:
|
|
- name: Harden Runner
|
|
uses: step-security/harden-runner@dc2769abcc0fcfbadfc1df54081c1608579ef6b2 # v2.22.2
|
|
with:
|
|
egress-policy: audit
|
|
|
|
- name: Generate coder-package-publisher App token
|
|
id: publisher_token
|
|
# The App's key is a non-exportable Cloud KMS key; only this workflow, in this environment,
|
|
# may sign with it.
|
|
uses: coder/github-app-token-action@00eaec58ee1bfea9c8b48655b7ab7470b07739e5 # main 2026-11-17
|
|
with:
|
|
client-id: ${{ secrets.CODER_PACKAGE_PUBLISHER_APP_ID }}
|
|
kms-key: ${{ secrets.CODER_PACKAGE_PUBLISHER_APP_KMS_KEY }}
|
|
workload-identity-provider: ${{ secrets.APP_KEYS_WORKLOAD_ID_PROVIDER }}
|
|
owner: coder
|
|
repositories: packages
|
|
# repository_dispatch needs contents: write on the target repository.
|
|
permissions: |
|
|
contents: write
|
|
|
|
- name: Send repository-dispatch event
|
|
uses: peter-evans/repository-dispatch@28959ce8df70de7be546dd1250a005dd32156697 # v4.0.1
|
|
with:
|
|
token: ${{ steps.publisher_token.outputs.token }}
|
|
repository: coder/packages
|
|
event-type: coder-release
|
|
client-payload: '{"coder_version": "${{ needs.release.outputs.version }}", "release_channel": "${{ inputs.release_channel }}"}'
|
|
|
|
publish-homebrew:
|
|
name: Publish to Homebrew tap
|
|
runs-on: ubuntu-latest
|
|
needs: release
|
|
if: ${{ !inputs.dry_run && inputs.release_channel == 'mainline' }}
|
|
environment: release-publish
|
|
permissions:
|
|
contents: read
|
|
id-token: write # Cloud KMS signs the coder-package-publisher App's JWT
|
|
|
|
steps:
|
|
- name: Harden Runner
|
|
uses: step-security/harden-runner@dc2769abcc0fcfbadfc1df54081c1608579ef6b2 # v2.22.2
|
|
with:
|
|
egress-policy: audit
|
|
|
|
- name: Generate coder-package-publisher App token
|
|
id: publisher_token
|
|
# The App's key is a non-exportable Cloud KMS key; only this workflow, in this environment,
|
|
# may sign with it.
|
|
uses: coder/github-app-token-action@00eaec58ee1bfea9c8b48655b7ab7470b07739e5 # main 2026-11-17
|
|
with:
|
|
client-id: ${{ secrets.CODER_PACKAGE_PUBLISHER_APP_ID }}
|
|
kms-key: ${{ secrets.CODER_PACKAGE_PUBLISHER_APP_KMS_KEY }}
|
|
workload-identity-provider: ${{ secrets.APP_KEYS_WORKLOAD_ID_PROVIDER }}
|
|
owner: coder
|
|
repositories: homebrew-coder
|
|
permissions: |
|
|
contents: write
|
|
pull_requests: write
|
|
|
|
- name: Update homebrew
|
|
env:
|
|
GH_REPO: coder/homebrew-coder
|
|
# The App token only reaches coder/homebrew-coder; the release assets are read with the
|
|
# workflow's own token.
|
|
GH_TOKEN: ${{ steps.publisher_token.outputs.token }}
|
|
RELEASE_READ_TOKEN: ${{ github.token }}
|
|
VERSION: ${{ needs.release.outputs.version }}
|
|
run: |
|
|
# Keep version number around for reference, removing any potential leading v
|
|
coder_version="$(echo "${VERSION}" | tr -d v)"
|
|
|
|
set -euxo pipefail
|
|
|
|
# Setup Git
|
|
git config --global user.email "ci@coder.com"
|
|
git config --global user.name "Coder CI"
|
|
git config --global credential.helper "store"
|
|
|
|
temp_dir="$(mktemp -d)"
|
|
cd "$temp_dir"
|
|
|
|
# Download checksums
|
|
checksums_url="$(GH_TOKEN="$RELEASE_READ_TOKEN" gh release view --repo coder/coder "v$coder_version" --json assets \
|
|
| jq -r ".assets | map(.url) | .[]" \
|
|
| grep -e ".checksums.txt\$")"
|
|
wget "$checksums_url" -O checksums.txt
|
|
|
|
# Get the SHAs
|
|
darwin_arm_sha="$(grep "darwin_arm64.zip" checksums.txt | awk '{ print $1 }')"
|
|
darwin_intel_sha="$(grep "darwin_amd64.zip" checksums.txt | awk '{ print $1 }')"
|
|
linux_sha="$(grep "linux_amd64.tar.gz" checksums.txt | awk '{ print $1 }')"
|
|
|
|
echo "macOS arm64: $darwin_arm_sha"
|
|
echo "macOS amd64: $darwin_intel_sha"
|
|
echo "Linux amd64: $linux_sha"
|
|
|
|
# Check out the homebrew repo
|
|
git clone "https://github.com/$GH_REPO" homebrew-coder
|
|
brew_branch="auto-release/$coder_version"
|
|
cd homebrew-coder
|
|
|
|
# Check if a PR already exists.
|
|
pr_count="$(gh pr list --search "head:$brew_branch" --json id,closed | jq -r ".[] | select(.closed == false) | .id" | wc -l)"
|
|
if [ "$pr_count" -gt 0 ]; then
|
|
echo "Bailing out as PR already exists" 2>&1
|
|
exit 0
|
|
fi
|
|
|
|
# Set up coder-package-publisher credentials for pushing to homebrew-coder
|
|
echo "https://x-access-token:$GH_TOKEN@github.com" >> ~/.git-credentials
|
|
# Update the formulae and push
|
|
git checkout -b "$brew_branch"
|
|
./scripts/update-v2.sh "$coder_version" "$darwin_arm_sha" "$darwin_intel_sha" "$linux_sha"
|
|
git add .
|
|
git commit -m "coder $coder_version"
|
|
git push -u origin -f "$brew_branch"
|
|
|
|
# Create PR
|
|
gh pr create \
|
|
-B master -H "$brew_branch" \
|
|
-t "coder $coder_version" \
|
|
-b "" \
|
|
-r "${GITHUB_ACTOR}" \
|
|
-a "${GITHUB_ACTOR}" \
|
|
-b "This automatic PR was triggered by the release of Coder v$coder_version"
|
|
|
|
publish-winget:
|
|
name: Publish to winget-pkgs
|
|
runs-on: windows-latest
|
|
needs: release
|
|
if: ${{ !inputs.dry_run && inputs.release_channel != 'rc' }}
|
|
environment: release-publish
|
|
|
|
steps:
|
|
- name: Harden Runner
|
|
uses: step-security/harden-runner@dc2769abcc0fcfbadfc1df54081c1608579ef6b2 # v2.22.2
|
|
with:
|
|
egress-policy: audit
|
|
|
|
- name: Sync fork
|
|
run: gh repo sync cdrci/winget-pkgs -b master
|
|
env:
|
|
GH_TOKEN: ${{ secrets.CDRCI_GITHUB_TOKEN }}
|
|
|
|
- name: Checkout
|
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
with:
|
|
fetch-depth: 0
|
|
persist-credentials: false
|
|
|
|
# If the event that triggered the build was an annotated tag (which our
|
|
# tags are supposed to be), actions/checkout has a bug where the tag in
|
|
# question is only a lightweight tag and not a full annotated tag. This
|
|
# command seems to fix it.
|
|
# https://github.com/actions/checkout/issues/290
|
|
- name: Fetch git tags
|
|
run: git fetch --tags --force
|
|
|
|
# Pinned to a release and checked against its SHA-256, which matches both
|
|
# GitHub's asset digest and the wingetcreate.exe.txt checksum file Microsoft
|
|
# publishes alongside it. To update, take both values from a newer release
|
|
# at https://github.com/microsoft/winget-create/releases.
|
|
- name: Install wingetcreate
|
|
run: |
|
|
$ErrorActionPreference = "Stop"
|
|
Invoke-WebRequest -Uri "https://github.com/microsoft/winget-create/releases/download/$env:WINGETCREATE_VERSION/wingetcreate.exe" -OutFile wingetcreate.exe
|
|
$hash = (Get-FileHash -Algorithm SHA256 -Path wingetcreate.exe).Hash
|
|
if ($hash -ne $env:WINGETCREATE_SHA256) {
|
|
Remove-Item wingetcreate.exe
|
|
throw "wingetcreate.exe $env:WINGETCREATE_VERSION checksum mismatch: got $hash"
|
|
}
|
|
env:
|
|
WINGETCREATE_VERSION: v1.28.1.0
|
|
WINGETCREATE_SHA256: 63D980BA79E97042395BD6EB5992C2DB9E01E9E7A8A22958A95C288F27310413
|
|
|
|
- name: Submit updated manifest to winget-pkgs
|
|
run: |
|
|
# The package version is the same as the tag minus the leading "v".
|
|
# The version in this output already has the leading "v" removed but
|
|
# we do it again to be safe.
|
|
$version = $env:VERSION.Trim('v')
|
|
|
|
$release_assets = gh release view --repo coder/coder "v${version}" --json assets | `
|
|
ConvertFrom-Json
|
|
# Get the installer URLs from the release assets.
|
|
$amd64_installer_url = $release_assets.assets | `
|
|
Where-Object name -Match ".*_windows_amd64_installer.exe$" | `
|
|
Select -ExpandProperty url
|
|
$amd64_zip_url = $release_assets.assets | `
|
|
Where-Object name -Match ".*_windows_amd64.zip$" | `
|
|
Select -ExpandProperty url
|
|
$arm64_zip_url = $release_assets.assets | `
|
|
Where-Object name -Match ".*_windows_arm64.zip$" | `
|
|
Select -ExpandProperty url
|
|
|
|
echo "amd64 Installer URL: ${amd64_installer_url}"
|
|
echo "amd64 zip URL: ${amd64_zip_url}"
|
|
echo "arm64 zip URL: ${arm64_zip_url}"
|
|
echo "Package version: ${version}"
|
|
|
|
.\wingetcreate.exe update Coder.Coder `
|
|
--submit `
|
|
--version "${version}" `
|
|
--urls "${amd64_installer_url}" "${amd64_zip_url}" "${arm64_zip_url}"
|
|
|
|
env:
|
|
# For gh CLI:
|
|
GH_TOKEN: ${{ github.token }}
|
|
# For wingetcreate. We need a real token since we're pushing a commit
|
|
# to GitHub and then making a PR in a different repo.
|
|
# wingetcreate will read the token from the environment variable defined below.
|
|
# Reference: https://aka.ms/winget-create-token
|
|
WINGET_CREATE_GITHUB_TOKEN: ${{ secrets.CDRCI_GITHUB_TOKEN }}
|
|
VERSION: ${{ needs.release.outputs.version }}
|
|
|
|
- name: Comment on PR
|
|
run: |
|
|
# wait 30 seconds
|
|
Start-Sleep -Seconds 30.0
|
|
# Find the PR that wingetcreate just made.
|
|
$version = $env:VERSION.Trim('v')
|
|
$pr_list = gh pr list --repo microsoft/winget-pkgs --search "author:cdrci Coder.Coder version ${version}" --limit 1 --json number | `
|
|
ConvertFrom-Json
|
|
$pr_number = $pr_list[0].number
|
|
|
|
gh pr comment --repo microsoft/winget-pkgs "${pr_number}" --body "🤖 cc: @deansheather @matifali"
|
|
|
|
env:
|
|
# For gh CLI. We need a real token since we're commenting on a PR in a
|
|
# different repo.
|
|
GH_TOKEN: ${{ secrets.CDRCI_GITHUB_TOKEN }}
|
|
VERSION: ${{ needs.release.outputs.version }}
|