diff --git a/.github/workflows/draft-release.yml b/.github/workflows/draft-release.yml new file mode 100644 index 00000000..cf690d8d --- /dev/null +++ b/.github/workflows/draft-release.yml @@ -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 diff --git a/RELEASING.md b/RELEASING.md index d3469531..86fb3c74 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -42,7 +42,10 @@ 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), @@ -50,9 +53,11 @@ match source manifests exactly; the manifests identify `0.8.0`. 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 diff --git a/docs/DEVELOPMENT.md b/docs/DEVELOPMENT.md index 0ab2b9fd..d81dd8f0 100644 --- a/docs/DEVELOPMENT.md +++ b/docs/DEVELOPMENT.md @@ -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 diff --git a/scripts/release/check-ci-release-gating.test.mjs b/scripts/release/check-ci-release-gating.test.mjs index 0c330a2a..1539dd63 100644 --- a/scripts/release/check-ci-release-gating.test.mjs +++ b/scripts/release/check-ci-release-gating.test.mjs @@ -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); @@ -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')); +});