Skip to content
Open
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
60 changes: 60 additions & 0 deletions .github/workflows/draft-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Draft release

# Attach a version tag's verified release candidate to that tag's DRAFT
# GitHub release. The Build workflow stays read-only; this workflow runs only
# after a successful tag build, never builds or checks out code, and never
# publishes: the maintainer publishes the draft.
on:
workflow_run:
workflows: [Build]
types: [completed]

permissions:
contents: read

concurrency:
group: draft-release-${{ github.event.workflow_run.head_branch }}
cancel-in-progress: false

jobs:
attach:
name: Attach release candidate to draft release
if: >-
github.event.workflow_run.conclusion == 'success' &&
github.event.workflow_run.event == 'push' &&
startsWith(github.event.workflow_run.head_branch, 'v')
runs-on: ubuntu-24.04
timeout-minutes: 30
permissions:
contents: write
actions: read
steps:
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: release-candidate
path: release-candidate
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ github.token }}
- name: Verify the candidate's checksums
working-directory: release-candidate
run: sha256sum --check --strict checksums-sha256.txt
- name: Attach to the draft release without publishing it
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
TAG: ${{ github.event.workflow_run.head_branch }}
SOURCE: ${{ github.event.workflow_run.head_sha }}
shell: bash
run: |
set -euo pipefail
[[ "$TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+([.-][0-9A-Za-z.-]+)?$ ]] || { echo "::error::not a version tag: $TAG"; exit 1; }
# The tag must still name the commit that was built.
tagged="$(gh api "repos/$GH_REPO/commits/$TAG" --jq .sha)"
[ "$tagged" = "$SOURCE" ] || { echo "::error::$TAG now names $tagged, not the built $SOURCE"; exit 1; }
state="$(gh release view "$TAG" --json isDraft --jq .isDraft 2>/dev/null || echo missing)"
case "$state" in
missing) gh release create "$TAG" --draft --verify-tag --title "$TAG" --notes "Release notes: see CHANGELOG.md." ;;
true) ;;
*) echo "::error::$TAG is already published; its assets are never replaced"; exit 1 ;;
esac
gh release upload "$TAG" release-candidate/* --clobber
13 changes: 9 additions & 4 deletions RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,22 @@ match source manifests exactly; the manifests identify `0.8.0`.
against the manifests automatically.
4. Complete local QA below, push the candidate commit, and create its version
tag. Inspect every platform result produced for that exact tag.
5. Review the `release-candidate` workflow artifact. It contains all sixteen
5. Review the `release-candidate` workflow artifact. After the tag build
succeeds, the Draft release workflow attaches the same files to the tag's
draft GitHub release. Publishing that draft is the maintainer's decision.
The artifact contains all sixteen
required files selected by [the artifact plan](scripts/release/artifact-plan.json):
five full desktop installers (GUI with inference plugins), five
no-inference desktop installers (GUI with an inference-disabled backend),
three headless no-inference RPC archives, and three inference headless RPC
archives for embedding. It also carries
checksums over those final bytes.

The workflow deliberately assembles **candidates**, with read-only repository
permissions. It does not create or publish a GitHub release. Publication requires
all the release acceptance evidence below; green compilation alone is inadequate.
The Build workflow assembles **candidates** with read-only repository
permissions. Only the Draft release workflow can write, and it only attaches a
successful tag build's verified files to that tag's draft release. Nothing in CI
publishes a release. Publication requires all the release acceptance evidence
below; green compilation alone is inadequate.

## Local QA

Expand Down
10 changes: 7 additions & 3 deletions docs/DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -246,9 +246,13 @@ intended to decide a property.
`release-candidate` runs only after every candidate-run QA job succeeds. It
checks that the downloaded set is exactly the sixteen files in
`scripts/release/artifact-plan.json`, then writes SPDX inventories, unsigned
provenance, notices and SHA-256 checksums over the final files. Candidate
assembly never publishes a GitHub release. See [Releasing](../RELEASING.md) for
the remaining publication obligations.
provenance, notices and SHA-256 checksums over the final files. The Build
workflow stays read-only. After a successful version-tag build, the separate
`draft-release.yml` workflow checks those checksums and that the tag still
names the built commit. It then attaches the files to the tag's **draft**
GitHub release, creating the draft if needed. It never publishes, and it
refuses to touch a release that is already published. See
[Releasing](../RELEASING.md) for the remaining publication obligations.

### Pending Higher-Fidelity Claims

Expand Down
17 changes: 17 additions & 0 deletions scripts/release/check-ci-release-gating.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ test('dependency audit is advisory on reviews, blocking on candidates and feeds
test('every checkout drops its credentials; no job pushes', () => {
for (const file of ['build.yml', 'scorecard.yml']) {
const text = fs.readFileSync(path.join(root, '.github/workflows', file), 'utf8');
// draft-release.yml is the single writer; it has its own contract below.
assert.doesNotMatch(text, /git push|contents: write/, file);
const checkouts = [...text.matchAll(/uses: actions\/checkout@[0-9a-f]{40} # \S+\n((?: {8,}.*\n)*)/g)];
assert.ok(checkouts.length > 0, file);
Expand Down Expand Up @@ -328,3 +329,19 @@ test('the desktop contract has one tracked copy, checked against a fresh export'
}
assert.match(job('build-frontend'), /^ - run: pnpm --dir electron check:desktop-contract$/m);
});

test('only the draft-release workflow writes, and only to a draft of a successful tag build', () => {
const draft = fs.readFileSync(path.join(root, '.github/workflows/draft-release.yml'), 'utf8');
assert.match(draft, /^on:\n workflow_run:\n workflows: \[Build\]\n types: \[completed\]\n\n/m);
assert.match(draft, /^permissions:\n contents: read\n/m);
assert.match(draft, /github\.event\.workflow_run\.conclusion == 'success'/);
assert.match(draft, /github\.event\.workflow_run\.event == 'push'/);
assert.match(draft, /startsWith\(github\.event\.workflow_run\.head_branch, 'v'\)/);
assert.equal([...draft.matchAll(/contents: write/g)].length, 1);
// It never runs repository code, never pushes and never publishes.
assert.doesNotMatch(draft, /actions\/checkout|git push|git tag|--draft=false|--latest|gh release edit|gh release delete|secrets\./);
assert.match(draft, /sha256sum --check --strict checksums-sha256\.txt/);
assert.match(draft, /gh release create "\$TAG" --draft --verify-tag/);
assert.match(draft, /already published; its assets are never replaced/);
assert.ok(draft.indexOf('[ "$tagged" = "$SOURCE" ]') < draft.indexOf('gh release upload'));
});
Loading