Repository navigation
59 lines (57 loc) · 2.3 KB
/
Copy pathrelease-sign.yml
File metadata and controls
59 lines (57 loc) · 2.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# sscsb: Sigstore keyless release signing (Cosign + Fulcio + Rekor) with SBOM
# attached. Artifacts are signed as blobs with offline-verifiable bundles;
# certificates bind to this workflow's OIDC identity.
name: Release — Sign & SBOM
on:
release:
types: [published]
permissions:
contents: read
jobs:
sign:
runs-on: ubuntu-latest
permissions:
contents: write # upload assets to the release
id-token: write # keyless signing (Fulcio OIDC)
steps:
- name: Harden runner
uses: step-security/harden-runner@bf7454d06d71f1098171f2acdf0cd4708d7b5920 # v2.20.0
with:
egress-policy: audit
- name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
with:
persist-credentials: false
# CUSTOMIZE: replace with your real build. The default packs the source
# tree so the pipeline works end-to-end on any repo from day one.
- name: Build artifact
run: |
mkdir -p dist
git archive --format=tar.gz -o "dist/${GITHUB_REPOSITORY#*/}-${GITHUB_REF_NAME}.tar.gz" HEAD
- name: Install cosign
uses: sigstore/cosign-installer@6f9f17788090df1f26f669e9d70d6ae9567deba6 # v4.1.2
- name: Generate SBOM for the artifact tree
uses: anchore/sbom-action@e22c389904149dbc22b58101806040fa8d37a610 # v0.24.0
with:
format: cyclonedx-json
output-file: dist/sbom.cdx.json
upload-release-assets: false
# Fails EXPLICITLY on an empty dist/: "there was nothing to sign" must never
# be indistinguishable from "everything was signed".
- name: Keyless sign all artifacts (bundle = cert + sig + Rekor proof)
run: |
set -uo pipefail
shopt -s nullglob
artifacts=(dist/*)
if [ ${#artifacts[@]} -eq 0 ]; then
echo "::error::dist/ is empty — nothing to sign (did the build step run?)"
exit 1
fi
for f in "${artifacts[@]}"; do
[ "${f%.sigstore.json}" != "$f" ] && continue
cosign sign-blob "$f" --bundle "$f.sigstore.json" --yes
done
- name: Upload artifacts + signatures + SBOM to the release
env:
GH_TOKEN: ${{ github.token }}
run: gh release upload "$GITHUB_REF_NAME" dist/* --clobber