Skip to content

ci: publish release images and charts through coder/ghcr-publisher - #32566

Merged
kylecarbs merged 4 commits into
mainfrom
ghcr-staging-promote
Nov 22, 2026
Merged

kylecarbs merged 4 commits into
mainfrom
ghcr-staging-promote

Conversation

@kylecarbs

@kylecarbs kylecarbs commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

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 (ci: create release tags and branches with the release App after approval #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 (chore: Initial database scaffolding #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

GitHub grants package write per repository, so any workflow on any branch
here could overwrite ghcr.io/coder/coder or the OCI charts with the
repository's GITHUB_TOKEN. Releases now push to *-staging packages and
dispatch coder/ghcr-publisher, the only repository that can write the
public ones. It copies each digest only after verifying this workflow
attested it, on the release branch, from the tagged commit.

- Images, the base image and the OCI charts go to the staging packages.
  The charts get their own attestations (manifest digests).
- Attestations the promotion depends on now fail the release.
- The final image builds on the fresh base image by digest.
- latest is moved by the publisher; the latest SBOM asset is dropped
  (same image).
- docker-base.yaml publishes coder-base-preview, the base for non-release
  builds.
- verify-releases.md: releases since 2026-11-16 are built on
  release/X.Y, so --source-ref refs/tags/vX.Y.Z no longer matches.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
kylecarbs and others added 3 commits November 20, 2026 16:35
coder/ghcr-publisher moves coder-base:latest to the base of each new
highest stable release, so non-release and local builds keep using it.
docker-base.yaml now only checks on pull requests that Dockerfile.base
builds; it no longer publishes or needs packages: write.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Review fixes for the GHCR promotion:

- Every staging digest now comes from the registry's response to the
  push (docker push, docker manifest push, depot, helm push), and the
  multi-arch index is built from per-arch digests. Nothing reads a
  staging tag back, so a writer moving a staging tag mid-release can't
  get their image attested. syft and cosign run against image@digest.
- Each artifact gets a release attestation
  (https://coder.com/attestations/release/v1) stating the version, the
  commit the tag points to and the public package it is for. The
  attestation's own commit field is the dispatched branch head, which is
  not the released commit when an older commit is released.
- A re-run accepts tags an earlier attempt already promoted.
- The tagging and promotion App tokens are revoked right after use.
- Image provenance attestations are best-effort again, as before; the
  publisher relies on the release attestations instead.
- verify-releases.md: SOURCE_REF works for release candidates.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
coder-ghcr-dispatch has contents: write on coder/ghcr-publisher only, so
the release no longer needs coder-release-publisher installed there.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@kylecarbs
kylecarbs marked this pull request as ready for review November 22, 2026 16:35
@kylecarbs
kylecarbs requested a review from a team November 22, 2026 16:35
kylecarbs added a commit that referenced this pull request Nov 22, 2026
**The problem.** Any workflow on any branch here can push
`ghcr.io/coder/coder-preview`, because GitHub grants package write per
repository. coder/dogfood's Flux
(`coder-image/resourcesetinputprovider-coder-preview.yaml`) deploys the
alphabetically newest `main-<10 digits>-<12 hex>` tag every 2 minutes,
with no signature check. So a writer can push `main-9999999999-…` from a
branch, and dogfood runs it within minutes and stays on it.

**The fix.** It follows the release flow in #32566:
- `build.yaml` pushes to **`coder-preview-staging`**.
- Each per-arch digest comes from the registry's response to its own
`docker push`, and the index is built from those digests. No staging tag
is read back, which closes a race where a writer swaps a tag mid-build.
- It signs a **preview attestation**
(`https://coder.com/attestations/preview/v1`: commit, version tag,
target). This step must succeed.
- It dispatches **coder/ghcr-publisher** (`promote-preview.yaml`) with a
`coder-ghcr-dispatch` token (`contents: write` on `ghcr-publisher`
only), revokes the token, and waits for the version tag and, on main,
the `main-<commit time>-<sha>` tag.
- **The publisher** verifies the attestation came from a push run of
`build.yaml` on `main` or `release/*` at that run's head commit. It then
**derives every public tag from the verified commit**: the version,
`main-<commit time>-<sha>`, `main`, `latest` and `release-X.Y`.
- The derived tag matches today's `main-1795210592-ecc0850e369a`
exactly, so dogfood's filter keeps working.
  - Rolling tags only move forward.
- **Pruning** now targets the staging package. Public package storage is
free, and only the publisher can write the public one.
- **SBOM and provenance attestations** now run on the digest, once,
instead of once per tag.

**Prerequisites (all done 2026-11-22)**
- [x] coder/ghcr-publisher#2 merged
- [x] The `coder-ghcr-dispatch` App exists (coder/gcp#472,
coder/github-org-terraform#206). The `ci-signing` environment has
`CODER_GHCR_DISPATCH_APP_ID`, `CODER_GHCR_DISPATCH_APP_KMS_KEY` and
`APP_KEYS_WORKLOAD_ID_PROVIDER`.
- [x] `coder-preview-staging` exists: coder/coder **Admin** (pushes and
prunes), `ghcr-publisher` **Read**
- [x] `ghcr-publisher` has **Write** on `coder-preview`

**After the first successful promotion:** set coder/coder to **Read** on
`coder-preview`. Only then is the dogfood path closed. Pruning
`coder-preview` moves to coder/ghcr-publisher (`prune-preview.yaml`,
which has Admin on that package); this PR points the prune job here at
`coder-preview-staging`.

actionlint and zizmor are clean. The push and index steps were rehearsed
on a local registry, where the parsed digests matched what the registry
stored.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 5.5 <[email protected]>
@kylecarbs
kylecarbs merged commit 11f72a8 into main Nov 22, 2026
49 of 50 checks passed
@kylecarbs
kylecarbs deleted the ghcr-staging-promote branch November 22, 2026 20:05
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 22, 2026

This branch had an error being deployed

1 failed deployment
docs-preview — e8824904 Deployed Nov 22, 2026 by kylecarbs via cleanup #325
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants