-
Notifications
You must be signed in to change notification settings - Fork 180
Add SBOM generation to CI/CD pipeline and releases #5588
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
ad2ce41
b455826
2998b33
629a9e1
254ba4b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -37,6 +37,7 @@ jobs: | |
| attestations: write | ||
| outputs: | ||
| release_id: ${{ steps.get_release.outputs.release_id }} | ||
| release_tag: ${{ steps.get_release.outputs.release_tag }} | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v5 | ||
|
|
@@ -59,7 +60,58 @@ jobs: | |
| echo "Getting release ID for tag: $RELEASE_TAG" | ||
| RELEASE_ID=$(gh release view "$RELEASE_TAG" --json databaseId --jq '.databaseId') | ||
| echo "release_id=$RELEASE_ID" >> "$GITHUB_OUTPUT" | ||
| echo "release_tag=$RELEASE_TAG" >> "$GITHUB_OUTPUT" | ||
| echo "✓ Release ID: $RELEASE_ID" | ||
| echo "✓ Release Tag: $RELEASE_TAG" | ||
| generate-sbom: | ||
| needs: ["release"] | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: write | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v5 | ||
|
|
||
| - name: Set up Go | ||
| uses: actions/setup-go@v5 | ||
| with: | ||
| go-version-file: go.mod | ||
| cache: true | ||
|
|
||
| - name: Download Go modules | ||
| run: go mod download | ||
|
|
||
| - name: Generate SBOM (SPDX format) | ||
| uses: anchore/sbom-action@v0 | ||
| with: | ||
| artifact-name: sbom.spdx.json | ||
| output-file: sbom.spdx.json | ||
| format: spdx-json | ||
|
|
||
| - name: Generate SBOM (CycloneDX format) | ||
| uses: anchore/sbom-action@v0 | ||
| with: | ||
| artifact-name: sbom.cdx.json | ||
| output-file: sbom.cdx.json | ||
| format: cyclonedx-json | ||
|
|
||
| - name: Upload SBOM artifacts | ||
| uses: actions/upload-artifact@v4 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @copilot use latest version of action
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated to |
||
| with: | ||
| name: sbom-artifacts | ||
| path: | | ||
| sbom.spdx.json | ||
| sbom.cdx.json | ||
| retention-days: 90 | ||
|
|
||
| - name: Attach SBOM to release | ||
| env: | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| RELEASE_TAG: ${{ needs.release.outputs.release_tag }} | ||
| run: | | ||
| echo "Attaching SBOM files to release: $RELEASE_TAG" | ||
| gh release upload "$RELEASE_TAG" sbom.spdx.json sbom.cdx.json --clobber | ||
| echo "✓ SBOM files attached to release" | ||
| steps: | ||
| - name: Setup environment and fetch release data | ||
| env: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot should be released write, not contents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
releasesis not a valid GitHub Actions permission. Thegh release uploadcommand requirescontents: writepermission to upload assets to releases. This is the correct permission as per GitHub's documentation.