11name : Generate SBOM
22
3- # Runs only when the 'generate sbom' label is added to a PR.
3+ # Runs when the 'generate sbom' label is added to a PR, or when a release is published.
4+ # Uses the sbom-tool CLI (version pinned in .config/sbom-tool/dotnet-tools.json)
5+ # so the NuGet package is never modified and no SBOM is embedded in it.
46on :
57 pull_request :
68 types : [labeled]
9+ release :
10+ types : [published]
711
812permissions :
913 contents : read
1014
1115concurrency :
12- group : sbom-${{ github.event.pull_request.number }}
16+ group : sbom-${{ github.event_name == 'release' && github.ref_name || github. event.pull_request.number }}
1317 cancel-in-progress : true
1418
1519env :
1620 BUILD_CONFIGURATION : Release
17- PACKAGE_VERSION : 0.0.0-pr.${{ github.event.pull_request.number }}
21+ PACKAGE_VERSION : ${{ github.event_name == 'release' && github.ref_name || format(' 0.0.0-pr.{0}', github.event.pull_request.number) }}
1822
1923jobs :
2024 sbom :
21- if : github.event.label.name == 'generate sbom'
25+ if : github.event_name == 'release' || github. event.label.name == 'generate sbom'
2226 runs-on : ubuntu-latest
2327
2428 steps :
@@ -39,31 +43,44 @@ jobs:
3943 - run : npm run build
4044 working-directory : src/IgniteUI.Blazor.GridLite
4145
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
46+ - name : Pack NuGet package
4547 run : >
4648 dotnet pack src/IgniteUI.Blazor.GridLite/IgniteUI.Blazor.GridLite.csproj
4749 --configuration ${{ env.BUILD_CONFIGURATION }}
4850 -p:RunNodeBuild=false
4951 -p:GeneratePackageOnBuild=false
50- -p:GenerateSBOM=true
5152 -p:Version=${{ env.PACKAGE_VERSION }}
5253 -o ./artifacts
5354
54- - name : Extract and verify SBOM
55+ # Dedicated nested manifest keeps sbom-tool out of the root 'dotnet tool restore' used by publish.yml
56+ - name : Restore sbom-tool (pinned)
57+ run : dotnet tool restore --tool-manifest .config/sbom-tool/dotnet-tools.json
58+
59+ # -b: the shipped artifact (nupkg) gets listed with its hash in the SBOM's files section
60+ # -bc: dependency detection scans the project dir (NuGet + npm)
61+ - name : Generate SBOM
62+ working-directory : .config/sbom-tool
63+ run : >
64+ dotnet tool run sbom-tool -- generate
65+ -b ${{ github.workspace }}/artifacts
66+ -bc ${{ github.workspace }}/src/IgniteUI.Blazor.GridLite
67+ -pn IgniteUI.Blazor.GridLite
68+ -pv ${{ env.PACKAGE_VERSION }}
69+ -ps Infragistics
70+ -nsb http://spdx.org/spdxdocs/IgniteUI.Blazor.GridLite
71+ -V Information
72+
73+ - name : Verify SBOM
5574 run : |
5675 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]}"
76+ test -s artifacts/_manifest/spdx_2.2/manifest.spdx.json
77+ test -s artifacts/_manifest/spdx_2.2/manifest.spdx.json.sha256
78+ echo "SBOM generated successfully."
6279
63- - name : Upload NuGet package (with embedded SBOM)
80+ - name : Upload NuGet package
6481 uses : actions/upload-artifact@v7
6582 with :
66- name : nupkg-with-sbom
83+ name : nupkg
6784 path : artifacts/*.nupkg
6885 retention-days : 1
6986 if-no-files-found : error
7289 uses : actions/upload-artifact@v7
7390 with :
7491 name : sbom-spdx_2.2
75- path : extracted /_manifest/spdx_2.2
92+ path : artifacts /_manifest/spdx_2.2
7693 retention-days : 1
7794 if-no-files-found : error
95+
96+ attach-to-release :
97+ if : github.event_name == 'release'
98+ needs : sbom
99+ runs-on : ubuntu-latest
100+ permissions :
101+ contents : write # required to upload release assets
102+
103+ steps :
104+ - name : Download SBOM artifact
105+ uses : actions/download-artifact@v8
106+ with :
107+ name : sbom-spdx_2.2
108+ path : spdx_2.2
109+
110+ - name : Attach SBOM to release
111+ env :
112+ GH_TOKEN : ${{ github.token }}
113+ TAG : ${{ github.ref_name }}
114+ run : |
115+ set -euo pipefail
116+ asset="IgniteUI.Blazor.GridLite.${TAG}.spdx_2.2.zip"
117+ (cd spdx_2.2 && zip -r "../${asset}" .)
118+ gh release upload "$TAG" "$asset" --clobber -R "${{ github.repository }}"
0 commit comments