|
| 1 | +# Generates a Software Bill of Materials for each published release, stamps |
| 2 | +# Santander Group as document creator, signs a build provenance attestation |
| 3 | +# (Sigstore, verifiable with `gh attestation verify`) and attaches both |
| 4 | +# standard formats (SPDX + CycloneDX) as release assets. |
| 5 | +# Manual runs (workflow_dispatch) upload the SBOMs as workflow artifacts only. |
| 6 | +name: SBOM |
| 7 | + |
| 8 | +on: |
| 9 | + release: |
| 10 | + types: [published] |
| 11 | + workflow_dispatch: |
| 12 | + |
| 13 | +permissions: {} |
| 14 | + |
| 15 | +env: |
| 16 | + BASE: ${{ github.event.repository.name }}-${{ github.ref_name }} |
| 17 | + |
| 18 | +jobs: |
| 19 | + sbom: |
| 20 | + name: Generate, attest and attach SBOM |
| 21 | + runs-on: ubuntu-latest |
| 22 | + permissions: |
| 23 | + contents: write # upload release assets |
| 24 | + id-token: write # sign the attestation (Sigstore) |
| 25 | + attestations: write # store the attestation |
| 26 | + steps: |
| 27 | + - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 |
| 28 | + with: |
| 29 | + persist-credentials: false |
| 30 | + - name: Generate SPDX SBOM |
| 31 | + uses: anchore/sbom-action@e22c389904149dbc22b58101806040fa8d37a610 # v0.24.0 |
| 32 | + with: |
| 33 | + format: spdx-json |
| 34 | + output-file: ${{ env.BASE }}.spdx.json |
| 35 | + upload-artifact: false |
| 36 | + upload-release-assets: false |
| 37 | + - name: Generate CycloneDX SBOM |
| 38 | + uses: anchore/sbom-action@e22c389904149dbc22b58101806040fa8d37a610 # v0.24.0 |
| 39 | + with: |
| 40 | + format: cyclonedx-json |
| 41 | + output-file: ${{ env.BASE }}.cdx.json |
| 42 | + upload-artifact: false |
| 43 | + upload-release-assets: false |
| 44 | + - name: Stamp Santander Group as document creator |
| 45 | + run: | |
| 46 | + jq '.creationInfo.creators += ["Organization: Santander Group"]' \ |
| 47 | + "$BASE.spdx.json" > tmp.json && mv tmp.json "$BASE.spdx.json" |
| 48 | + jq '.metadata.authors = [{"name": "Open Source Santander AI", "email": "opensource@gruposantander.com"}]' \ |
| 49 | + "$BASE.cdx.json" > tmp.json && mv tmp.json "$BASE.cdx.json" |
| 50 | + - name: Attest SBOM build provenance |
| 51 | + uses: actions/attest-build-provenance@0f67c3f4856b2e3261c31976d6725780e5e4c373 # v4.1.1 |
| 52 | + with: |
| 53 | + subject-path: | |
| 54 | + ${{ env.BASE }}.spdx.json |
| 55 | + ${{ env.BASE }}.cdx.json |
| 56 | + - name: Upload SBOMs as workflow artifacts (manual runs) |
| 57 | + if: github.event_name == 'workflow_dispatch' |
| 58 | + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 |
| 59 | + with: |
| 60 | + name: sboms |
| 61 | + path: | |
| 62 | + ${{ env.BASE }}.spdx.json |
| 63 | + ${{ env.BASE }}.cdx.json |
| 64 | + - name: Attach SBOMs to the release |
| 65 | + if: github.event_name == 'release' |
| 66 | + env: |
| 67 | + GH_TOKEN: ${{ github.token }} |
| 68 | + run: | |
| 69 | + gh release upload "${{ github.event.release.tag_name }}" \ |
| 70 | + "$BASE.spdx.json" "$BASE.cdx.json" --clobber |
0 commit comments