Skip to content

Commit f08c779

Browse files
authored
feat(ci): add sbom generation (#165)
Signed-off-by: Travis Truman <trumant@gmail.com>
1 parent 41d7404 commit f08c779

File tree

2 files changed

+90
-0
lines changed

2 files changed

+90
-0
lines changed

.github/workflows/release.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ jobs:
2323
attestations: write
2424
contents: write
2525
id-token: write
26+
outputs:
27+
attestation_matrix: ${{ steps.generate_matrix.outputs.matrix }}
2628
steps:
2729
- name: Checkout
2830
uses: actions/checkout@v5
@@ -33,6 +35,10 @@ jobs:
3335
uses: actions/setup-go@v5
3436
with:
3537
go-version: 1.23.4
38+
- name: Install Syft
39+
uses: anchore/sbom-action/download-syft@f8bdd1d8ac5e901a77a92f111440fdb1b593736b
40+
with:
41+
syft-version: v1.33.0
3642
- name: Run GoReleaser
3743
uses: goreleaser/goreleaser-action@e435ccd777264be153ace6237001ef4d979d3a7a
3844
with:
@@ -45,3 +51,32 @@ jobs:
4551
uses: actions/attest-build-provenance@v3
4652
with:
4753
subject-checksums: dist/checksums.txt
54+
- name: Generate attestation matrix
55+
id: generate_matrix
56+
run: |
57+
matrix=$(ls dist/*.spdx.json | jq -R '{"sbom": ., "archive": sub("\\.spdx\\.json$"; "")}' | jq -s -c '{"include": .}')
58+
echo "matrix=$matrix" >> $GITHUB_OUTPUT
59+
- name: Upload artifacts
60+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
61+
with:
62+
name: dist
63+
path: dist
64+
attest-sboms:
65+
needs: goreleaser
66+
runs-on: ubuntu-latest
67+
permissions:
68+
attestations: write
69+
id-token: write
70+
strategy:
71+
matrix: ${{ fromJson(needs.goreleaser.outputs.attestation_matrix) }}
72+
steps:
73+
- name: Download artifacts
74+
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0
75+
with:
76+
name: dist
77+
path: dist
78+
- name: Attest SBOM
79+
uses: actions/attest-sbom@4651f806c01d8637787e274ac3bdf724ef169f34
80+
with:
81+
subject-path: "${{ matrix.archive }}"
82+
sbom-path: "${{ matrix.sbom }}"

.goreleaser.yaml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,60 @@ checksum:
4848
release:
4949
prerelease: auto
5050

51+
sboms:
52+
- # ID of the sbom config, must be unique.
53+
#
54+
# Default: 'default'.
55+
id: sboms
56+
57+
# List of names of the SBOM documents created at this step
58+
# (relative to the dist dir).
59+
#
60+
# Each element configured is made available as variables. For example:
61+
# documents: ["foo", "bar"]
62+
#
63+
# would make the following variables that can be referenced as template keys:
64+
# document0: "foo"
65+
# document1: "bar"
66+
#
67+
# Note that multiple sbom values are only allowed if the value of
68+
# "artifacts" is "any".
69+
#
70+
# Default:
71+
# When "binary": ["{{ .Binary }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}.sbom.json"]
72+
# When "any": []
73+
# Otherwise: ["{{ .ArtifactName }}.sbom.json"]
74+
# Templates: allowed.
75+
documents:
76+
- "${artifact}.spdx.json"
77+
78+
# Path to the SBOM generator command
79+
#
80+
# Note: the process CWD will be set to the same location as "dist"
81+
#
82+
# Default: 'syft'.
83+
cmd: syft
84+
85+
# Command line arguments for the command
86+
#
87+
# Default: ["$artifact", "--output", "spdx-json=$document", "--enrich", "all"].
88+
# Templates: allowed.
89+
# args: ["$artifact", "--output", "cyclonedx-json=$document"]
90+
91+
# Which artifacts to catalog.
92+
#
93+
# Valid options are:
94+
# - any: let the SBOM tool decide which artifacts available in
95+
# the cwd should be cataloged
96+
# - source: source archive
97+
# - package: Linux packages (deb, rpm, apk, etc)
98+
# - installer: Windows MSI installers (Pro only)
99+
# - diskimage: macOS DMG disk images (Pro only)
100+
# - archive: archives from archive pipe
101+
# - binary: binaries output from the build stage
102+
#
103+
# Default: 'archive'.
104+
artifacts: archive
105+
51106
universal_binaries:
52107
- replace: true

0 commit comments

Comments
 (0)