Skip to content

Commit e7ff0c4

Browse files
kylecarbsclaude
andauthored
ci: releases need a second approver and come only from attested builds (#8143)
* ci: releases need a second approver and come only from attested builds The Release workflow builds the packages from a commit on main (the merge commit of an update/ PR, or a commit given to a dispatch on main) and attests each file's provenance. A member of code-server-release-team other than the person who started the run then approves the release-approval environment. Only that job, as the coder-release-publisher App (key in Cloud KMS), creates the tag and publishes the release with the attested files, in one step. Releases are immutable, so the files can't change after that, and there is no draft for anyone to edit. publish.yaml publishes nothing until it has checked that the release came from coder-release-publisher, is immutable, and that every file was attested by release.yaml from main. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ci: upload release-packages directly instead of copying it package.tar.gz is now written into release-packages next to the platform packages, so every build job attests and uploads one flat directory without a copy. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * ci: remove a doubled blank line in release.yaml Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 452dd09 commit e7ff0c4

3 files changed

Lines changed: 357 additions & 86 deletions

File tree

‎.github/workflows/publish.yaml‎

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ on:
1212
release:
1313
types: [released]
1414

15+
permissions: {}
16+
1517
# Cancel in-progress runs for pull requests when developers push
1618
# additional changes, and serialize builds in branches.
1719
# https://docs.github.com/en/actions/using-jobs/using-concurrency#example-using-concurrency-to-cancel-any-in-progress-job-or-run
@@ -20,8 +22,47 @@ concurrency:
2022
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
2123

2224
jobs:
25+
# Nothing is published unless the release came from release.yaml: coder-release-publisher made
26+
# it (only release.yaml's approve job can sign as that App, after a second person approved), it
27+
# is published and immutable, and every file was built and attested by release.yaml from main.
28+
verify:
29+
runs-on: ubuntu-latest
30+
permissions:
31+
contents: read
32+
attestations: read
33+
env:
34+
GH_TOKEN: ${{ github.token }}
35+
TAG: ${{ inputs.version || github.ref_name }}
36+
steps:
37+
- name: Check the release
38+
run: |
39+
set -euo pipefail
40+
fail() { echo "::error::$*"; exit 1; }
41+
# TAG comes from the dispatch input, so only a version may reach the shell.
42+
[[ "$TAG" =~ ^v?[0-9]+\.[0-9]+\.[0-9]+(-rc\.[0-9]+)?$ ]] || fail "The version must look like v1.2.3 or v1.2.3-rc.1."
43+
tag="v${TAG#v}"
44+
release="$(gh api "repos/$GITHUB_REPOSITORY/releases/tags/$tag")"
45+
author="$(jq -r .author.login <<<"$release")"
46+
[[ "$author" == "coder-release-publisher[bot]" ]] || fail "$tag was published by $author, not by release.yaml (coder-release-publisher)."
47+
[[ "$(jq -r .draft <<<"$release")" == "false" ]] || fail "$tag is a draft."
48+
[[ "$(jq -r .immutable <<<"$release")" == "true" ]] || fail "$tag is not an immutable release."
49+
50+
- name: Verify the files
51+
run: |
52+
set -euo pipefail
53+
tag="v${TAG#v}"
54+
gh release download "$tag" --repo "$GITHUB_REPOSITORY" --dir release-files
55+
for f in release-files/*; do
56+
gh attestation verify "$f" \
57+
--repo "$GITHUB_REPOSITORY" \
58+
--signer-workflow "$GITHUB_REPOSITORY/.github/workflows/release.yaml" \
59+
--source-ref refs/heads/main \
60+
--deny-self-hosted-runners
61+
done
62+
2363
npm:
2464
runs-on: ubuntu-latest
65+
needs: verify
2566
environment: release
2667
permissions:
2768
# Required so GitHub can issue an OIDC token for trusted publishing.
@@ -60,6 +101,7 @@ jobs:
60101
61102
aur:
62103
runs-on: ubuntu-latest
104+
needs: verify
63105
environment: release
64106
permissions:
65107
contents: read
@@ -135,6 +177,7 @@ jobs:
135177
136178
docker:
137179
runs-on: ubuntu-latest
180+
needs: verify
138181
# Scopes the Docker Hub OIDC subject claim to
139182
# repo:coder/code-server:environment:release.
140183
environment: release

0 commit comments

Comments
 (0)