Skip to content

Commit 3bdcf77

Browse files
jenshennebergaskpt
andauthored
ci: Generate SBOM (#245)
## This PR Generates Software Bill of Materials (SBOM) as described in #159. Once NuGet/Home#12497 is implemented, the SBOM file(s) should be embedded in the published nuget packages. Until then, I've added the SBOM as an asset under the release. ### Known issue The SBOM file lists the dependences for all target frameworks combined. Once the above [NuGet ](NuGet/Home#12497 is implemented, it should be changed, so there is one sbom created for each target framework with only the applicable references included. ### Related Issues Fixes #159 ### How to test Unfortunately, this is somewhat cumbersome to test, as the logic in question only kicks in upon a release from the main branch. I've tested it myself this way: - Create new fork of this repo - Merge this branch to main in the new repo - Create a release in the new repo Signed-off-by: Jens Henneberg <[email protected]> Co-authored-by: André Silva <[email protected]>
1 parent b23334b commit 3bdcf77

File tree

1 file changed

+33
-6
lines changed

1 file changed

+33
-6
lines changed

.github/workflows/release.yml

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
- main
77

88
jobs:
9-
release-package:
9+
release-please:
1010
runs-on: ubuntu-latest
1111

1212
steps:
@@ -16,14 +16,21 @@ jobs:
1616
command: manifest
1717
token: ${{secrets.GITHUB_TOKEN}}
1818
default-branch: main
19+
outputs:
20+
release_created: ${{ steps.release.outputs.release_created }}
21+
release_tag_name: ${{ steps.release.outputs.tag_name }}
1922

23+
release:
24+
runs-on: ubuntu-latest
25+
needs: release-please
26+
if: ${{ needs.release-please.outputs.release_created }}
27+
28+
steps:
2029
- uses: actions/checkout@v4
21-
if: ${{ steps.release.outputs.releases_created }}
2230
with:
2331
fetch-depth: 0
2432

2533
- name: Setup .NET SDK
26-
if: ${{ steps.release.outputs.releases_created }}
2734
uses: actions/setup-dotnet@v4
2835
env:
2936
NUGET_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -34,13 +41,33 @@ jobs:
3441
source-url: https://nuget.pkg.github.com/open-feature/index.json
3542

3643
- name: Install dependencies
37-
if: ${{ steps.release.outputs.releases_created }}
3844
run: dotnet restore
3945

4046
- name: Pack
41-
if: ${{ steps.release.outputs.releases_created }}
4247
run: dotnet pack --no-restore
4348

4449
- name: Publish to Nuget
45-
if: ${{ steps.release.outputs.releases_created }}
4650
run: dotnet nuget push "src/**/*.nupkg" --api-key "${{ secrets.NUGET_TOKEN }}" --source https://api.nuget.org/v3/index.json
51+
52+
sbom:
53+
runs-on: ubuntu-latest
54+
needs: release-please
55+
continue-on-error: true
56+
if: ${{ needs.release-please.outputs.release_created }}
57+
58+
steps:
59+
- uses: actions/checkout@v4
60+
with:
61+
fetch-depth: 0
62+
63+
- name: Install CycloneDX.NET
64+
run: dotnet tool install CycloneDX
65+
66+
- name: Generate .NET BOM
67+
run: dotnet CycloneDX --json --exclude-dev -sv "${{ needs.release-please.outputs.release_tag_name }}" ./src/OpenFeature/OpenFeature.csproj
68+
69+
- name: Attach SBOM to artifact
70+
env:
71+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
72+
run:
73+
gh release upload ${{ needs.release-please.outputs.release_tag_name }} bom.json

0 commit comments

Comments
 (0)