4747 env :
4848 CHAINLOOP_TOKEN : ${{ secrets.CHAINLOOP_TOKEN }}
4949 ATTESTATION_ID : ${{ needs.init_attestation.outputs.attestation_id }}
50- outputs :
51- matrix : ${{ steps.attest_goreleaser.outputs.matrix }}
5250
5351 steps :
5452 - name : Install Cosign
8078 id : qemu
8179 uses : docker/setup-qemu-action@v3
8280
81+ - name : Install Syft
82+ run : |
83+ # Install Syft
84+ wget --no-verbose https://raw.githubusercontent.com/anchore/syft/main/install.sh -O - | sh -s -- -b /usr/local/bin
85+
8386 - name : Run GoReleaser
8487 id : release
8588 uses : goreleaser/goreleaser-action@b508e2e3ef3b19d4e4146d4f8fb3ba9db644a757 # v3.2.0
@@ -99,14 +102,20 @@ jobs:
99102 run : |
100103 # goreleaser output resides in dist/artifacts.json
101104 # Attest all built containers and manifests
102- images=$(cat dist/artifacts.json | jq -r '[.[] | select(.type=="Docker Image" or .type=="Docker Manifest") | {"type": "image", "path": .path}]')
105+ images=$(cat dist/artifacts.json | jq -r '.[] | select(.type=="Docker Image" or .type=="Docker Manifest") | .path')
106+ for entry in $images; do
107+ syft -o cyclonedx-json=/tmp/sbom.cyclonedx.json $entry
108+ chainloop attestation add --value $entry --kind CONTAINER_IMAGE --attestation-id ${{ env.ATTESTATION_ID }}
109+ chainloop attestation add --value /tmp/sbom.cyclonedx.json
110+ done
103111
104112 # Attest CLI archives
105- archives=$(cat dist/artifacts.json | jq -r '[.[] | select(.type=="Archive") | {"type": "archive", "path": .path}]')
106-
107- # convert them to json and join arrays
108- artifacts_json=$(jq -c -s 'add' <(echo "$images") <(echo "$archives"))
109- echo "matrix=$artifacts_json" >> $GITHUB_OUTPUT
113+ archives=$(cat dist/artifacts.json | jq -r '.[] | select(.type=="Archive") | .path')
114+ for entry in $archives; do
115+ syft -o cyclonedx-json=/tmp/sbom.cyclonedx.json $entry
116+ chainloop attestation add --value $entry --attestation-id ${{ env.ATTESTATION_ID }}
117+ chainloop attestation add --value /tmp/sbom.cyclonedx.json
118+ done
110119
111120 - name : Bump Chart and Dagger Version
112121 run : .github/workflows/utils/bump-chart-and-dagger-version.sh deployment/chainloop extras/dagger ${{ github.ref_name }}
@@ -126,57 +135,12 @@ jobs:
126135 automated
127136 helm
128137
129- generate_sboms_and_attest :
130- name : ${{ matrix.artifact.path }}
131- permissions :
132- packages : read
133- contents : read
134- needs : release
135- runs-on : ubuntu-latest
136- env :
137- CHAINLOOP_TOKEN : ${{ secrets.CHAINLOOP_TOKEN }}
138- ATTESTATION_ID : ${{ needs.init_attestation.outputs.attestation_id }}
139- strategy :
140- matrix :
141- artifact : ${{ fromJson(needs.release.outputs.matrix) }}
142-
143- steps :
144- - name : Docker login to Github Packages
145- uses : docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc # v2.2.0
146- with :
147- registry : ghcr.io
148- username : ${{ github.actor }}
149- password : ${{ secrets.GITHUB_TOKEN }}
150-
151- - name : Install Chainloop
152- run : |
153- curl -sfL https://docs.chainloop.dev/install.sh | bash -s
154- - name : Checkout
155- uses : actions/checkout@v3
156-
157- - uses : anchore/sbom-action@df80a981bc6edbc4e220a492d3cbe9f5547a6e75 # v0.17.9
158- if : ${{ matrix.artifact.type == 'image' }}
159- with :
160- image : ${{ matrix.artifact.path }}
161- format : cyclonedx-json
162- output-file : /tmp/sbom.cyclonedx.json
163-
164- - uses : anchore/sbom-action@df80a981bc6edbc4e220a492d3cbe9f5547a6e75 # v0.17.9
165- if : ${{ matrix.artifact.type == 'archive' }}
166- with :
167- file : ${{ matrix.artifact.path }}
168- format : cyclonedx-json
169- output-file : /tmp/sbom.cyclonedx.json
170-
171- - name : Add Artifact and SBOM to attestation
172- run : |
173- chainloop attestation add --value ${{ matrix.artifact.path }} --attestation-id ${{ env.ATTESTATION_ID }}
174- chainloop attestation add --value /tmp/sbom.cyclonedx.json --attestation-id ${{ env.ATTESTATION_ID }}
175-
176138 finish_attestation :
177139 name : Finish Attestation
178140 runs-on : ubuntu-latest
179- needs : generate_sboms_and_attest
141+ needs :
142+ - init_attestation
143+ - release
180144 steps :
181145 - name : Install Chainloop
182146 run : |
0 commit comments