@@ -24,6 +24,8 @@ project simply generates provenance as a separate step in an existing workflow.
24
24
- [ Workflow Outputs] ( #workflow-outputs )
25
25
- [ Provenance Format] ( #provenance-format )
26
26
- [ Provenance Example] ( #provenance-example )
27
+ - [ Integration With Other Build Systems] ( #integration-with-other-build-systems )
28
+ - [ Provenance with GoReleaser] ( #provenance-with-goreleaser )
27
29
28
30
---
29
31
@@ -77,7 +79,7 @@ provenance:
77
79
contents : read # Needed for API access
78
80
uses :
slsa-framework/slsa-github-generator/.github/workflows/[email protected]
79
81
with :
80
- base64-subjects : " ${{ needs.build.outputs.digest }}"
82
+ base64-subjects : " ${{ needs.build.outputs.hashes }}"
81
83
` ` `
82
84
83
85
Here's an example of what it might look like all together.
@@ -88,29 +90,32 @@ jobs:
88
90
# outputs their digest.
89
91
build :
90
92
outputs :
91
- digest : ${{ steps.hash.outputs.digest }}
93
+ hashes : ${{ steps.hash.outputs.hashes }}
92
94
runs-on : ubuntu-latest
93
95
steps :
94
- - name : " build artifacts"
96
+ - name : Build artifacts
95
97
run : |
96
98
# These are some amazing artifacts.
97
99
echo "foo" > artifact1
98
100
echo "bar" > artifact2
99
- - name : " generate hash"
101
+
102
+ - name : Generate hashes
100
103
shell : bash
101
104
id : hash
102
105
run : |
103
106
# sha256sum generates sha256 hash for all artifacts.
104
107
# base64 -w0 encodes to base64 and outputs on a single line.
105
108
# sha256sum artifact1 artifact2 ... | base64 -w0
106
- echo "::set-output name=digest::$(sha256sum artifact1 artifact2 | base64 -w0)"
109
+ echo "::set-output name=hashes::$(sha256sum artifact1 artifact2 | base64 -w0)"
110
+
107
111
- name : Upload artifact1
108
112
uses : actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # v3.1.0
109
113
with :
110
114
name : artifact1
111
115
path : artifact1
112
116
if-no-files-found : error
113
117
retention-days : 5
118
+
114
119
- name : Upload artifact2
115
120
uses : actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # v3.1.0
116
121
with :
@@ -126,10 +131,9 @@ jobs:
126
131
actions : read
127
132
id-token : write
128
133
contents : read
129
- if : startsWith(github.ref, 'refs/tags/')
130
134
uses :
slsa-framework/slsa-github-generator/.github/workflows/[email protected]
131
135
with :
132
- base64-subjects : " ${{ needs.build.outputs.digest }}"
136
+ base64-subjects : " ${{ needs.build.outputs.hashes }}"
133
137
134
138
# This step creates a GitHub release with our artifacts and provenance.
135
139
release :
@@ -141,16 +145,19 @@ jobs:
141
145
uses : actions/download-artifact@fb598a63ae348fa914e94cd0ff38f362e927b741 # v2.1.0
142
146
with :
143
147
name : artifact1
148
+
144
149
- name : Download artifact2
145
150
uses : actions/download-artifact@fb598a63ae348fa914e94cd0ff38f362e927b741 # v2.1.0
146
151
with :
147
152
name : artifact2
153
+
148
154
- name : Download provenance
149
155
uses : actions/download-artifact@fb598a63ae348fa914e94cd0ff38f362e927b741 # v2.1.0
150
156
with :
151
157
# The provenance step returns an output with the artifact name of
152
158
# our provenance.
153
159
name : ${{needs.provenance.outputs.attestation-name}}
160
+
154
161
- name : Create release
155
162
uses : softprops/action-gh-release@1e07f4398721186383de40550babbdf2b84acfc5 # v0.1.14
156
163
with :
@@ -270,3 +277,70 @@ generated as an [in-toto](https://in-toto.io/) statement with a SLSA predicate.
270
277
}
271
278
}
272
279
` ` `
280
+
281
+ # # Integration With Other Build Systems
282
+
283
+ This section explains how to generate non-forgeable SLSA provenance with existing build systems.
284
+
285
+ # ## Provenance for GoReleaser
286
+
287
+ If you use [GoReleaser](https://github.com/goreleaser/goreleaser-action) to generate your build, you can easily
288
+ generate SLSA3 provenance by updating your existing workflow with the 4 steps indicated in the workflow below :
289
+
290
+ ` ` ` yaml
291
+ jobs:
292
+ goreleaser:
293
+ # =================================================
294
+ #
295
+ # Step 1: Declare an ` outputs` for the GoReleaser job.
296
+ #
297
+ # =================================================
298
+ outputs :
299
+ hashes : ${{ steps.hash.outputs.hashes }}
300
+
301
+ [...]
302
+
303
+ steps :
304
+ [...]
305
+ - name : Run GoReleaser
306
+ # =================================================
307
+ #
308
+ # Step 2: Add an `id: run-goreleaser` field
309
+ # to your goreleaser step.
310
+ #
311
+ # =================================================
312
+ id : run-goreleaser
313
+ uses : goreleaser/goreleaser-action@b953231f81b8dfd023c58e0854a721e35037f28b
314
+
315
+ # =================================================
316
+ #
317
+ # Step 3: Add a step to generate the provenance subjects
318
+ # as shown below.
319
+ #
320
+ # =================================================
321
+ - name : Generate subject
322
+ id : hash
323
+ env :
324
+ ARTIFACTS : " ${{ steps.run-goreleaser.outputs.artifacts }}"
325
+ run : |
326
+ set -euo pipefail
327
+
328
+ checksum_file=$(echo "$ARTIFACTS" | jq -r '.[] | select (.type=="Checksum") | .path')
329
+ echo "::set-output name=hashes::$(cat $checksum_file | base64 -w0)"
330
+
331
+ # =========================================================
332
+ #
333
+ # Step 4: Call the generic workflow to generate provenance
334
+ # by declaring the job below.
335
+ #
336
+ # =========================================================
337
+ provenance :
338
+ needs : [goreleaser]
339
+ permissions :
340
+ actions : read
341
+ id-token : write
342
+ contents : read
343
+ uses :
slsa-framework/slsa-github-generator/.github/workflows/[email protected]
344
+ with :
345
+ base64-subjects : " ${{ needs.goreleaser.outputs.hashes }}"
346
+ ` ` `
0 commit comments