Skip to content

Commit 22ebfbf

Browse files
authored
ci(release): build provenance attestations and CycloneDX SBOM (draft-only) (#24)
1 parent 3981997 commit 22ebfbf

1 file changed

Lines changed: 38 additions & 4 deletions

File tree

‎.github/workflows/release.yml‎

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ on:
88
permissions:
99
contents: read
1010

11+
env:
12+
# Pinned tool version; bump deliberately.
13+
CARGO_CYCLONEDX_VERSION: "0.5.9"
14+
1115
jobs:
1216
linux-x86_64:
1317
runs-on: ubuntu-22.04
@@ -40,6 +44,13 @@ jobs:
4044
- name: Build and exercise Debian-family package without host installation
4145
run: |
4246
bash scripts/test_deb.sh
47+
- name: Generate CycloneDX SBOM (pinned cargo-cyclonedx)
48+
run: |
49+
set -euo pipefail
50+
cargo install --locked --version "${CARGO_CYCLONEDX_VERSION}" cargo-cyclonedx
51+
cargo cyclonedx --format json --spec-version 1.5 --override-filename wraith-linux-x86_64.cdx
52+
mv wraith-linux-x86_64.cdx.json target/dist/
53+
jq -e '.bomFormat == "CycloneDX" and (.components | length > 0)' target/dist/wraith-linux-x86_64.cdx.json >/dev/null
4354
- uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6
4455
with:
4556
name: wraith-linux-x86_64
@@ -48,14 +59,37 @@ jobs:
4859
target/dist/SHA256SUMS
4960
target/dist/wraith_*_amd64.deb
5061
target/dist/DebSHA256SUMS
62+
target/dist/wraith-linux-x86_64.cdx.json
5163
retention-days: 30
5264
if-no-files-found: error
5365

66+
attest:
67+
# Build provenance for the tarball and .deb. Runs for tag pushes and for the
68+
# workflow_dispatch dry run (artifact-only: nothing is released).
69+
# id-token/attestations permissions are scoped to this job only.
70+
needs: linux-x86_64
71+
runs-on: ubuntu-22.04
72+
timeout-minutes: 10
73+
permissions:
74+
contents: read
75+
id-token: write
76+
attestations: write
77+
steps:
78+
- uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7
79+
with:
80+
name: wraith-linux-x86_64
81+
path: dist
82+
- uses: actions/attest-build-provenance@4d101475d8b20a2381f78447822ac1eab6504dd8 # v4.2.2
83+
with:
84+
subject-path: |
85+
dist/wraith-linux-x86_64.tar.gz
86+
dist/wraith_*_amd64.deb
87+
5488
draft-release:
5589
# Only for tag pushes; workflow_dispatch remains an artifact-only dry run.
5690
# Creates a DRAFT release: a maintainer must review and publish it manually.
5791
if: startsWith(github.ref, 'refs/tags/v')
58-
needs: linux-x86_64
92+
needs: [linux-x86_64, attest]
5993
runs-on: ubuntu-22.04
6094
timeout-minutes: 10
6195
permissions:
@@ -94,7 +128,7 @@ jobs:
94128
shopt -s nullglob
95129
debs=(wraith_*_amd64.deb)
96130
[ "${#debs[@]}" -eq 1 ] || { echo "::error::expected exactly one wraith_*_amd64.deb, found ${#debs[@]}"; exit 1; }
97-
expected=$(printf '%s\n' DebSHA256SUMS SHA256SUMS wraith-linux-x86_64.tar.gz "${debs[0]}" | sort)
131+
expected=$(printf '%s\n' DebSHA256SUMS SHA256SUMS wraith-linux-x86_64.cdx.json wraith-linux-x86_64.tar.gz "${debs[0]}" | sort)
98132
actual=$(find . -maxdepth 1 -type f -printf '%f\n' | sort)
99133
[ "$expected" = "$actual" ] || { echo "::error::unexpected dist contents"; diff <(echo "$expected") <(echo "$actual") || true; exit 1; }
100134
- name: Verify checksums before attaching
@@ -110,6 +144,6 @@ jobs:
110144
gh release create "$GITHUB_REF_NAME" \
111145
--draft --verify-tag \
112146
--title "$GITHUB_REF_NAME" \
113-
--notes "Draft release for $GITHUB_REF_NAME. Review CHANGELOG.md and SECURITY.md before publishing. Verify downloads with the attached checksums." \
147+
--notes "Draft release for $GITHUB_REF_NAME. Review CHANGELOG.md and SECURITY.md before publishing. Verify downloads with the attached checksums or with gh attestation verify (build provenance); a CycloneDX SBOM is attached." \
114148
dist/wraith-linux-x86_64.tar.gz dist/wraith_*_amd64.deb \
115-
dist/SHA256SUMS dist/DebSHA256SUMS
149+
dist/SHA256SUMS dist/DebSHA256SUMS dist/wraith-linux-x86_64.cdx.json

0 commit comments

Comments
 (0)