Skip to content

Commit 21ca6db

Browse files
committed
feat: sign release artifacts with cosign keyless + provenance attestations
1 parent f02f30f commit 21ca6db

1 file changed

Lines changed: 73 additions & 0 deletions

File tree

‎.github/workflows/release.yml‎

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,76 @@ jobs:
3131
args: release --clean
3232
env:
3333
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34+
35+
sign:
36+
name: Sign artifacts
37+
needs: goreleaser
38+
runs-on: ubuntu-latest
39+
permissions:
40+
contents: write
41+
id-token: write # OIDC identity for Sigstore keyless signing / attestation
42+
env:
43+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
44+
steps:
45+
- name: download release assets
46+
run: |
47+
mkdir dist
48+
gh release download "${GITHUB_REF_NAME}" --repo "${GITHUB_REPOSITORY}" --dir dist
49+
50+
- name: verify checksums
51+
working-directory: dist
52+
run: sha256sum -c checksums.txt
53+
54+
# SPDX SBOM so the SBOM ships signed like every other asset.
55+
- name: SBOM
56+
uses: anchore/sbom-action@3ad7283483fc7af8ff2b4ea19663c2d5ca935e26 # v0.24.2
57+
with:
58+
format: spdx-json
59+
output-file: dist/bodek-${{ github.ref_name }}-sbom.spdx.json
60+
upload-artifact: false
61+
upload-release-assets: false
62+
63+
- uses: sigstore/cosign-installer@6f9f17788090df1f26f669e9d70d6ae9567deba6 # v4.1.2
64+
with:
65+
cosign-release: v3.1.3 # pinned: a future cosign major must not break a tagged release mid-flight
66+
67+
# Keyless signing: Fulcio cert bound to this workflow's OIDC identity,
68+
# logged in Rekor. Explicit file list (not a glob of everything) so
69+
# generated .bundle outputs can never be re-signed.
70+
- name: sign artifacts
71+
working-directory: dist
72+
run: |
73+
FILES="checksums.txt"
74+
for f in bodek_*.tar.gz bodek_*.zip; do
75+
FILES="$FILES $f"
76+
done
77+
for f in $FILES bodek-*-sbom.spdx.json; do
78+
cosign sign-blob --yes --bundle "${f}.bundle" "$f"
79+
done
80+
81+
# in-toto attestation naming the exact source commit each artifact was
82+
# built from. Predicate type "custom" keeps the step free of cosign's
83+
# SLSA schema validation; the content is SLSA-provenance-shaped.
84+
- name: provenance attestation
85+
working-directory: dist
86+
env:
87+
GIT_REF: ${{ github.ref }}
88+
GIT_SHA: ${{ github.sha }}
89+
run: |
90+
printf '{
91+
"builder": {"id": "https://github.com/BackendStack21/bodek/.github/workflows/release.yml@%s"},
92+
"buildType": "https://github.com/BackendStack21/bodek/.github/workflows/release.yml",
93+
"invocation": {"configSource": {"uri": "git+https://github.com/BackendStack21/bodek", "digest": {"sha1": "%s"}}},
94+
"metadata": {"completeness": {"parameters": true, "environment": false}, "reproducible": false},
95+
"materials": [{"uri": "git+https://github.com/BackendStack21/bodek", "digest": {"sha1": "%s"}}]
96+
}' "${GIT_REF}" "${GIT_SHA}" "${GIT_SHA}" > provenance.json
97+
FILES="checksums.txt"
98+
for f in bodek_*.tar.gz bodek_*.zip; do
99+
FILES="$FILES $f"
100+
done
101+
for f in $FILES bodek-*-sbom.spdx.json; do
102+
cosign attest-blob --yes --type custom --predicate provenance.json --bundle "${f}.attestation.bundle" "$f"
103+
done
104+
105+
- name: upload signatures
106+
run: gh release upload "${GITHUB_REF_NAME}" --repo "${GITHUB_REPOSITORY}" --clobber dist/*.bundle

0 commit comments

Comments
 (0)