Skip to content

Commit edb6867

Browse files
authored
chore(ci): Upload SBOMs to GitHub release (#1784)
1 parent 0ca7778 commit edb6867

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

.github/workflows/release.yaml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,10 @@ jobs:
9797
POSTHOG_API_KEY: ${{ secrets.POSTHOG_API_KEY }}
9898
POSTHOG_ENDPOINT: ${{ secrets.POSTHOG_ENDPOINT }}
9999

100-
- name: Attest GoReleaser outputs
100+
- name: Generate SBOMs, upload to release and attest
101101
id: attest_goreleaser
102+
env:
103+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
102104
run: |
103105
# goreleaser output resides in dist/artifacts.json
104106
# Attest all built containers and manifests
@@ -110,9 +112,12 @@ jobs:
110112
repo="${entry%:*}" # Remove tag
111113
repo="${repo##*/}" # Extract last segment after the last '/'
112114
material_name="${repo}-${entry##*-}" # Construct final name
113-
syft -o cyclonedx-json=/tmp/sbom.cyclonedx.json $entry
115+
syft -o cyclonedx-json=/tmp/sbom-$material_name.cyclonedx.json $entry
114116
chainloop attestation add --name $material_name --value $entry --kind CONTAINER_IMAGE --attestation-id ${{ env.ATTESTATION_ID }}
115-
chainloop attestation add --name sbom-$material_name --value /tmp/sbom.cyclonedx.json --attestation-id ${{ env.ATTESTATION_ID }}
117+
chainloop attestation add --name sbom-$material_name --value /tmp/sbom-$material_name.cyclonedx.json --attestation-id ${{ env.ATTESTATION_ID }}
118+
119+
# Upload the SBOM to the release
120+
gh release upload ${{ github.ref_name }} /tmp/sbom-$material_name.cyclonedx.json --clobber
116121
fi
117122
done
118123
@@ -182,7 +187,7 @@ jobs:
182187
if: ${{ success() }}
183188
run: |
184189
chainloop_release_url="## Chainloop Attestation"$'\n'"[View the attestation of this release](https://app.chainloop.dev/attestation/${{ needs.finish_attestation.outputs.attestation_hash }})"
185-
current_notes=$(gh release view ${{inputs.tag}} --json body -q '.body')
190+
current_notes=$(gh release view ${{github.ref_name}} --json body -q '.body')
186191
187192
if echo "$current_notes" | grep -q "## Chainloop Attestation"; then
188193
# Replace the existing Chainloop Attestation section with the new URL
@@ -193,4 +198,4 @@ jobs:
193198
fi
194199
195200
# Update the release notes and ignore if it fails since we might be lacking permissions to update the release notes
196-
gh release edit ${{inputs.tag}} -n "$modified_notes" || echo -n "Not enough permissions to edit the release notes. Skipping..."
201+
gh release edit ${{github.ref_name}} -n "$modified_notes" || echo -n "Not enough permissions to edit the release notes. Skipping..."

0 commit comments

Comments
 (0)