@@ -10,39 +10,47 @@ permissions:
1010 contents : read
1111
1212jobs :
13- test :
14- uses : chainloop-dev/chainloop/.github/workflows/test.yml@main
15-
16- init_attestation :
13+ release_gate :
14+ name : Release Gate
1715 runs-on : ubuntu-latest
16+ if : github.ref_type == 'tag'
1817 permissions :
19- id-token : write # required for SLSA provenance - https://docs.chainloop.dev/guides/slsa/
20- needs : test
21- if : github.ref_type == 'tag' # Guard to make sure we are releasing once
22- outputs :
23- attestation_id : ${{ steps.init_attestation.outputs.attestation_id }}
18+ id-token : write # required for SLSA provenance
2419 steps :
2520 - uses : actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
21+
2622 - name : Install Chainloop
2723 run : |
28- # Need the ee CLI to have access to project management capabilities
2924 curl -sfL https://dl.chainloop.dev/cli/install.sh | bash -s -- --ee
3025
31- - name : Initialize Attestation
32- id : init_attestation
26+ - name : Run Release Gate Attestation
3327 run : |
34- attestation_id=$( chainloop attestation init --workflow ${CHAINLOOP_WORKFLOW_NAME} --project ${CHAINLOOP_PROJECT_NAME} -- release --remote-state -o json | jq -r .attestationID)
35- echo "attestation_id=$attestation_id" >> $GITHUB_OUTPUT
28+ chainloop attestation init --workflow release-gate --project chainloop
29+ chainloop attestation push
3630 env :
3731 CHAINLOOP_TOKEN : ${{ secrets.CHAINLOOP_TOKEN }}
38- CHAINLOOP_WORKFLOW_NAME : " release"
39- CHAINLOOP_PROJECT_NAME : " chainloop"
40- # Needed for commit signature verification: https://docs.chainloop.dev/concepts/attestations#commit-verification
4132 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
4233
34+ - name : Mark attestation as failed
35+ if : ${{ failure() }}
36+ run : |
37+ chainloop attestation reset
38+ env :
39+ CHAINLOOP_TOKEN : ${{ secrets.CHAINLOOP_TOKEN }}
40+
41+ - name : Mark attestation as cancelled
42+ if : ${{ cancelled() }}
43+ run : |
44+ chainloop attestation reset --trigger cancellation
45+ env :
46+ CHAINLOOP_TOKEN : ${{ secrets.CHAINLOOP_TOKEN }}
47+
48+ test :
49+ uses : chainloop-dev/chainloop/.github/workflows/test.yml@d427768c0b07d50b485df0bcae87eb8ae8769e04
50+
4351 release :
4452 name : Release CLI and control-plane/artifact-cas container images
45- needs : init_attestation
53+ needs : [release_gate, test]
4654 runs-on : ubuntu-latest
4755 if : github.ref_type == 'tag' # Guard to make sure we are releasing once
4856 permissions :
5361 attestations : write # required for SLSA provenance
5462 env :
5563 CHAINLOOP_TOKEN : ${{ secrets.CHAINLOOP_TOKEN }}
56- ATTESTATION_ID : ${{ needs.init_attestation.outputs.attestation_id }}
5764 GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
58- outputs :
59- attestation_hash : ${{ steps.attest_goreleaser.outputs.attestation_hash }}
60- current_version : ${{ steps.project_version.outputs.current_version }}
6165
6266 steps :
6367 - name : Install Cosign
@@ -67,11 +71,23 @@ jobs:
6771
6872 - name : Install Chainloop
6973 run : |
74+ # Need the ee CLI to have access to project management capabilities
7075 curl -sfL https://dl.chainloop.dev/cli/install.sh | bash -s -- --ee
7176
7277 - name : Checkout
7378 uses : actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
7479
80+ - name : Initialize Attestation
81+ id : init_attestation
82+ run : |
83+ attestation_id=$(chainloop attestation init --workflow ${CHAINLOOP_WORKFLOW_NAME} --project ${CHAINLOOP_PROJECT_NAME} --release --remote-state -o json | jq -r .attestationID)
84+ echo "attestation_id=$attestation_id" >> $GITHUB_OUTPUT
85+ env :
86+ CHAINLOOP_WORKFLOW_NAME : " release"
87+ CHAINLOOP_PROJECT_NAME : " chainloop"
88+ # Needed for commit signature verification: https://docs.chainloop.dev/concepts/attestations#commit-verification
89+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
90+
7591 - name : Docker login to Github Packages
7692 uses : docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc # v2.2.0
7793 with :
@@ -112,6 +128,7 @@ jobs:
112128 id : attest_goreleaser
113129 env :
114130 SYFT_GOLANG_SEARCH_REMOTE_LICENSES : " true"
131+ ATTESTATION_ID : ${{ steps.init_attestation.outputs.attestation_id }}
115132 run : |
116133 # goreleaser output resides in dist/artifacts.json
117134 # Attest all built containers and manifests
@@ -166,6 +183,8 @@ jobs:
166183 done
167184
168185 - name : Include source code on attestation
186+ env :
187+ ATTESTATION_ID : ${{ steps.init_attestation.outputs.attestation_id }}
169188 run : |
170189 # This needs to run AFTER goreleaser to make sure the source code is available
171190
@@ -197,27 +216,14 @@ jobs:
197216 automated
198217 helm
199218
200- finish_attestation :
201- name : Finish Attestation
202- runs-on : ubuntu-latest
203- needs :
204- - init_attestation
205- - release
206- env :
207- CHAINLOOP_TOKEN : ${{ secrets.CHAINLOOP_TOKEN }}
208- outputs :
209- attestation_hash : ${{ steps.attestation_push.outputs.attestation_sha }}
210- steps :
211- - name : Install Chainloop
212- run : |
213- curl -sfL https://dl.chainloop.dev/cli/install.sh | bash -s -- --ee
214-
215219 - name : Finish and Record Attestation
216220 id : attestation_push
217221 if : ${{ success() }}
222+ env :
223+ ATTESTATION_ID : ${{ steps.init_attestation.outputs.attestation_id }}
218224 run : |
219- chainloop attestation push --attestation-id ${{ needs.init_attestation.outputs.attestation_id }}
220- attestation_sha=$(chainloop wf run describe --id ${{ needs.init_attestation.outputs.attestation_id }} -o json | jq -r '.attestation.digest')
225+ chainloop attestation push --attestation-id ${{ env.ATTESTATION_ID }}
226+ attestation_sha=$(chainloop wf run describe --id ${{ env.ATTESTATION_ID }} -o json | jq -r '.attestation.digest')
221227 # check that the command succeeded
222228 if [ -n "$attestation_sha" ]; then
223229 echo "attestation_sha=$attestation_sha" >> $GITHUB_OUTPUT
@@ -228,38 +234,17 @@ jobs:
228234 - name : Promote Chainloop Project Version
229235 if : ${{ success() }}
230236 env :
231- CURRENT_VERSION : ${{ needs.release .outputs.current_version }}
237+ CURRENT_VERSION : ${{ steps.project_version .outputs.current_version }}
232238 TARGET_VERSION : ${{ github.ref_name }}
233239 run : |
234240 echo "current_version=$CURRENT_VERSION"
235241 echo "target_version=$TARGET_VERSION"
236242 chainloop project version update --project chainloop --name "$CURRENT_VERSION" --new-name "$TARGET_VERSION" || true
237243
238- - name : Mark attestation as failed
239- if : ${{ failure() }}
240- run : |
241- chainloop attestation reset --attestation-id ${{ needs.init_attestation.outputs.attestation_id }}
242-
243- - name : Mark attestation as cancelled
244- if : ${{ cancelled() }}
245- run : |
246- chainloop attestation reset --trigger cancellation --attestation-id ${{ needs.init_attestation.outputs.attestation_id }}
247-
248- modify_release_notes :
249- if : ${{ success() }}
250- needs : finish_attestation
251- runs-on : ubuntu-latest
252- permissions :
253- packages : write
254- contents : write
255- steps :
256- - uses : actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
257-
258244 - name : Add attestation link to release notes
259245 if : ${{ success() }}
260246 env :
261- GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
262- ATTESTATION_SHA : ${{ needs.finish_attestation.outputs.attestation_hash }}
247+ ATTESTATION_SHA : ${{ steps.attestation_push.outputs.attestation_sha }}
263248 run : |
264249 chainloop_release_url="## Chainloop Attestation"$'\n'"[View the attestation of this release](https://app.chainloop.dev/attestation/${{ env.ATTESTATION_SHA }})"
265250 current_notes=$(gh release view ${{github.ref_name}} --json body -q '.body')
@@ -274,3 +259,17 @@ jobs:
274259
275260 # Update the release notes and ignore if it fails since we might be lacking permissions to update the release notes
276261 gh release edit ${{github.ref_name}} -n "$modified_notes" || echo -n "Not enough permissions to edit the release notes. Skipping..."
262+
263+ - name : Mark attestation as failed
264+ if : ${{ failure() }}
265+ env :
266+ ATTESTATION_ID : ${{ steps.init_attestation.outputs.attestation_id }}
267+ run : |
268+ chainloop attestation reset --attestation-id ${{ env.ATTESTATION_ID }}
269+
270+ - name : Mark attestation as cancelled
271+ if : ${{ cancelled() }}
272+ env :
273+ ATTESTATION_ID : ${{ steps.init_attestation.outputs.attestation_id }}
274+ run : |
275+ chainloop attestation reset --trigger cancellation --attestation-id ${{ env.ATTESTATION_ID }}
0 commit comments