Skip to content

Commit 9dae16e

Browse files
Merge pull request #15 from Commanderx-code/ci/build-attestations
Sign build provenance for release packages
2 parents 94d2159 + 5fc103b commit 9dae16e

4 files changed

Lines changed: 46 additions & 2 deletions

File tree

‎.github/workflows/linux-packages.yml‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,3 +178,36 @@ jobs:
178178
name: arch-package
179179
path: /arch-release/*
180180
if-no-files-found: error
181+
182+
# Sign SLSA build provenance for the exact packages a release is drafted from, once they
183+
# have built and passed every install test. Only tag runs attest, and only this job gets
184+
# the signing permissions. release:draft verifies these attestations before drafting.
185+
attest:
186+
if: github.ref_type == 'tag'
187+
needs: [build, install-deb, install-rpm, arch]
188+
runs-on: ubuntu-24.04
189+
timeout-minutes: 10
190+
permissions:
191+
contents: read
192+
id-token: write
193+
attestations: write
194+
artifact-metadata: write
195+
steps:
196+
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
197+
with:
198+
name: packages
199+
path: packages
200+
- uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
201+
with:
202+
name: arch-package
203+
path: arch-package
204+
- name: Verify checksums
205+
run: |
206+
(cd packages && sha256sum --check --strict SHA256SUMS)
207+
(cd arch-package && sha256sum --check --strict SHA256SUMS)
208+
- uses: actions/attest@1e69f48acb82d1966a394da916b4c1698aa569d6 # v4.2.2
209+
with:
210+
subject-path: |
211+
packages/*.deb
212+
packages/*.rpm
213+
arch-package/*.pkg.tar.zst

‎docs/installation.md‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@ sha256sum --check --ignore-missing SHA256SUMS
1616

1717
Each downloaded package must report `OK`. The `--ignore-missing` option lets you download only the package you need.
1818

19+
Checksums catch a damaged download. To also confirm a package was built by this repository's CI from its release tag, and not replaced afterwards, verify its signed build provenance with the [GitHub CLI](https://cli.github.com/) (0.7.2 and later):
20+
21+
```bash
22+
gh attestation verify ./command-center_<version>_amd64.deb --repo Commanderx-code/command-center
23+
```
24+
25+
It must report that verification succeeded and name the `.github/workflows/linux-packages.yml` workflow and the release tag.
26+
1927
On a compatible Debian/Ubuntu system:
2028

2129
```bash

‎docs/releases.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ git push origin v0.7.1
3030
npm run release:draft -- v0.7.1
3131
```
3232

33-
The draft command requires an authenticated GitHub CLI (`gh`). It checks for a clean working tree and a matching local/remote tag and runs the checks and tests. It then finds the successful **Linux packages** run for the tagged commit, downloads that run's `packages` and `arch-package` artifacts, verifies their checksums, writes one `SHA256SUMS` covering the `.deb`, `.rpm`, and Arch package, and creates an **unpublished** GitHub release. The release notes are docs/release-notes.md plus a build-and-validation section linking the workflow run. If CI has not passed for the tag, no draft is created. The command never builds release packages locally: a build on a newer distribution such as Garuda would require a newer glibc than the packages declare. It does not push tags or publish the draft. Download and verify the hosted assets and test the app on your machine before publishing.
33+
The draft command requires an authenticated GitHub CLI (`gh`). It checks for a clean working tree and a matching local/remote tag and runs the checks and tests. It then finds the successful **Linux packages** run for the tagged commit, downloads that run's `packages` and `arch-package` artifacts, verifies their checksums, verifies each package's build provenance attestation (signed by that run's `attest` job for this tag and commit, on a GitHub-hosted runner), writes one `SHA256SUMS` covering the `.deb`, `.rpm`, and Arch package, and creates an **unpublished** GitHub release. The release notes are docs/release-notes.md plus a build-and-validation section linking the workflow run. If CI has not passed for the tag, no draft is created. The command never builds release packages locally: a build on a newer distribution such as Garuda would require a newer glibc than the packages declare. It does not push tags or publish the draft. Download and verify the hosted assets and test the app on your machine before publishing.
3434

3535
The app discovers only published releases. Building a package, creating a tag, or preparing a draft does not publish a release.
3636

@@ -45,6 +45,7 @@ The **Linux packages** workflow runs these jobs:
4545
| `install-deb` | Installs that `.deb` on Ubuntu 22.04, Debian 12, and Ubuntu 24.04 and runs a 20-second launch check under a virtual display as an ordinary user. |
4646
| `install-rpm` | Installs that `.rpm` on Fedora 43 and runs the same launch check. |
4747
| `arch` | Builds `packaging/aur/PKGBUILD` in a clean `archlinux` container, lints the recipe and package with namcap, installs, and launches it. Tag pushes build the recipe unmodified from its release tag (the pkgver must match the tag) and upload the `arch-package` artifact; other pushes build the pushed commit. |
48+
| `attest` | Tag pushes only, after every build and install job passes: downloads the `packages` and `arch-package` artifacts, rechecks their checksums, and signs SLSA build provenance for the `.deb`, `.rpm`, and Arch package with `actions/attest`. It is the only job with signing permissions. |
4849

4950
These are installation and launch checks, not end-to-end validation of system-changing workflows.
5051

‎scripts/release-draft.mjs‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,10 @@ if(!readFileSync(join(archDir,'SHA256SUMS'),'utf8').includes(` ${arch}\n`))thro
3838
run('sha256sum',['--check','--strict','SHA256SUMS'],archDir);
3939
copyFileSync(join(archDir,arch),join(out,arch));
4040
const assets=[...packages,arch];
41+
// Each package must carry build provenance signed by this repository's packages workflow for this tag.
42+
for(const asset of assets)run('gh',['attestation','verify',join(out,asset),'--repo',repo,'--signer-workflow',`${repo}/.github/workflows/linux-packages.yml`,'--source-ref',`refs/tags/${tag}`,'--source-digest',head,'--deny-self-hosted-runners']);
4143
writeFileSync(join(out,'SHA256SUMS'),run('sha256sum',assets,out)+'\n');
4244
const notes=join(mkdtempSync(join(tmpdir(),'command-center-release-')),'notes.md');
43-
writeFileSync(notes,`${readFileSync(new URL('docs/release-notes.md',root),'utf8').trimEnd()}\n\n### Build and validation\n\nBoth packages were built once on Ubuntu 22.04 (glibc 2.35), then installed and launched as a normal user on Ubuntu 22.04, Debian 12, Ubuntu 24.04 and Fedora 43. The Arch package was built from the release tag with packaging/aur/PKGBUILD in a clean container, linted with namcap, installed and launched. Workflow run: ${passed.url}\n`);
45+
writeFileSync(notes,`${readFileSync(new URL('docs/release-notes.md',root),'utf8').trimEnd()}\n\n### Build and validation\n\nBoth packages were built once on Ubuntu 22.04 (glibc 2.35), then installed and launched as a normal user on Ubuntu 22.04, Debian 12, Ubuntu 24.04 and Fedora 43. The Arch package was built from the release tag with packaging/aur/PKGBUILD in a clean container, linted with namcap, installed and launched. Workflow run: ${passed.url}\n\nEach package carries signed build provenance from that workflow. To confirm a download was built by this repository's CI from the ${tag} tag, run \`gh attestation verify <file> --repo ${repo}\`.\n`);
4446
console.log(run('gh',['release','create',tag,...assets.map(a=>join(out,a)),join(out,'SHA256SUMS'),'--repo',repo,'--verify-tag','--draft','--title',`Command Center ${tag}`,'--notes-file',notes]));
4547
console.log(`Draft created from ${passed.url}. Download and verify the hosted assets, test the app on your machine, then publish on GitHub.`);

0 commit comments

Comments
 (0)