|
| 1 | +name: Generate SBOM |
| 2 | + |
| 3 | +# Runs only when the 'generate sbom' label is added to a PR. |
| 4 | +on: |
| 5 | + pull_request: |
| 6 | + types: [labeled] |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: read |
| 10 | + |
| 11 | +concurrency: |
| 12 | + group: sbom-${{ github.event.pull_request.number }} |
| 13 | + cancel-in-progress: true |
| 14 | + |
| 15 | +env: |
| 16 | + BUILD_CONFIGURATION: Release |
| 17 | + PACKAGE_VERSION: 0.0.0-pr.${{ github.event.pull_request.number }} |
| 18 | + |
| 19 | +jobs: |
| 20 | + sbom: |
| 21 | + if: github.event.label.name == 'generate sbom' |
| 22 | + runs-on: ubuntu-latest |
| 23 | + |
| 24 | + steps: |
| 25 | + - uses: actions/checkout@v7 |
| 26 | + |
| 27 | + - name: Setup .NET |
| 28 | + uses: actions/setup-dotnet@v5 |
| 29 | + with: |
| 30 | + dotnet-version: "10.0.x" |
| 31 | + |
| 32 | + - uses: actions/setup-node@v6.4.0 |
| 33 | + with: |
| 34 | + node-version: '22' |
| 35 | + |
| 36 | + - run: npm ci |
| 37 | + working-directory: src/IgniteUI.Blazor.GridLite |
| 38 | + |
| 39 | + - run: npm run build |
| 40 | + working-directory: src/IgniteUI.Blazor.GridLite |
| 41 | + |
| 42 | + # GenerateSBOM=true pulls in Microsoft.Sbom.Targets (conditional PackageReference) |
| 43 | + # and embeds _manifest/spdx_2.2 into the nupkg after Pack. |
| 44 | + - name: Pack with SBOM |
| 45 | + run: > |
| 46 | + dotnet pack src/IgniteUI.Blazor.GridLite/IgniteUI.Blazor.GridLite.csproj |
| 47 | + --configuration ${{ env.BUILD_CONFIGURATION }} |
| 48 | + -p:RunNodeBuild=false |
| 49 | + -p:GeneratePackageOnBuild=false |
| 50 | + -p:GenerateSBOM=true |
| 51 | + -p:Version=${{ env.PACKAGE_VERSION }} |
| 52 | + -o ./artifacts |
| 53 | +
|
| 54 | + - name: Extract and verify SBOM |
| 55 | + run: | |
| 56 | + set -euo pipefail |
| 57 | + nupkg=(artifacts/*.nupkg) |
| 58 | + unzip -q "${nupkg[0]}" "_manifest/*" -d extracted |
| 59 | + test -s extracted/_manifest/spdx_2.2/manifest.spdx.json |
| 60 | + test -s extracted/_manifest/spdx_2.2/manifest.spdx.json.sha256 |
| 61 | + echo "SBOM verified in ${nupkg[0]}" |
| 62 | +
|
| 63 | + - name: Upload NuGet package (with embedded SBOM) |
| 64 | + uses: actions/upload-artifact@v7 |
| 65 | + with: |
| 66 | + name: nupkg-with-sbom |
| 67 | + path: artifacts/*.nupkg |
| 68 | + retention-days: 1 |
| 69 | + if-no-files-found: error |
| 70 | + |
| 71 | + - name: Upload SBOM files |
| 72 | + uses: actions/upload-artifact@v7 |
| 73 | + with: |
| 74 | + name: sbom-spdx_2.2 |
| 75 | + path: extracted/_manifest/spdx_2.2 |
| 76 | + retention-days: 1 |
| 77 | + if-no-files-found: error |
0 commit comments