-
Notifications
You must be signed in to change notification settings - Fork 0
106 lines (94 loc) · 3.66 KB
/
Copy pathrelease.yml
File metadata and controls
106 lines (94 loc) · 3.66 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
name: Release
on:
push:
tags:
- 'v*'
permissions:
contents: write
jobs:
goreleaser:
name: GoReleaser
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v7
with:
go-version-file: go.mod
cache: true
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v7
with:
distribution: goreleaser
version: '~> v2'
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
sign:
name: Sign artifacts
needs: goreleaser
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write # OIDC identity for Sigstore keyless signing / attestation
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: download release assets
run: |
mkdir dist
gh release download "${GITHUB_REF_NAME}" --repo "${GITHUB_REPOSITORY}" --dir dist
- name: verify checksums
working-directory: dist
run: sha256sum -c checksums.txt
# SPDX SBOM so the SBOM ships signed like every other asset.
- name: SBOM
uses: anchore/sbom-action@3ad7283483fc7af8ff2b4ea19663c2d5ca935e26 # v0.24.2
with:
format: spdx-json
output-file: dist/bodek-${{ github.ref_name }}-sbom.spdx.json
upload-artifact: false
upload-release-assets: false
- uses: sigstore/cosign-installer@6f9f17788090df1f26f669e9d70d6ae9567deba6 # v4.1.2
with:
cosign-release: v3.1.3 # pinned: a future cosign major must not break a tagged release mid-flight
# Keyless signing: Fulcio cert bound to this workflow's OIDC identity,
# logged in Rekor. Explicit file list (not a glob of everything) so
# generated .bundle outputs can never be re-signed.
- name: sign artifacts
working-directory: dist
run: |
FILES="checksums.txt"
for f in bodek_*.tar.gz bodek_*.zip; do
FILES="$FILES $f"
done
for f in $FILES bodek-*-sbom.spdx.json; do
cosign sign-blob --yes --bundle "${f}.bundle" "$f"
done
# in-toto attestation naming the exact source commit each artifact was
# built from. Predicate type "custom" keeps the step free of cosign's
# SLSA schema validation; the content is SLSA-provenance-shaped.
- name: provenance attestation
working-directory: dist
env:
GIT_REF: ${{ github.ref }}
GIT_SHA: ${{ github.sha }}
run: |
printf '{
"builder": {"id": "https://github.com/BackendStack21/bodek/.github/workflows/release.yml@%s"},
"buildType": "https://github.com/BackendStack21/bodek/.github/workflows/release.yml",
"invocation": {"configSource": {"uri": "git+https://github.com/BackendStack21/bodek", "digest": {"sha1": "%s"}}},
"metadata": {"completeness": {"parameters": true, "environment": false}, "reproducible": false},
"materials": [{"uri": "git+https://github.com/BackendStack21/bodek", "digest": {"sha1": "%s"}}]
}' "${GIT_REF}" "${GIT_SHA}" "${GIT_SHA}" > provenance.json
FILES="checksums.txt"
for f in bodek_*.tar.gz bodek_*.zip; do
FILES="$FILES $f"
done
for f in $FILES bodek-*-sbom.spdx.json; do
cosign attest-blob --yes --type custom --predicate provenance.json --bundle "${f}.attestation.bundle" "$f"
done
- name: upload signatures
run: gh release upload "${GITHUB_REF_NAME}" --repo "${GITHUB_REPOSITORY}" --clobber dist/*.bundle