Skip to content

Commit 31446c3

Browse files
authored
Implement SBOM generation and Azure upload
Added steps to generate and upload SBOM and its checksum.
1 parent 8443fe6 commit 31446c3

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

.github/workflows/Build-Release.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# This workflow will build, test, sign and pack the release branches for EPPlus.
2+
# It will also generate and publish an SBOM
23
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net
34

45
name: Build Release Branches
@@ -21,6 +22,26 @@ jobs:
2122
dotnet-version: '9.0.x'
2223
- name: Restore dependencies
2324
run: dotnet restore ./src/EPPlus.sln
25+
26+
# --- SBOM ---
27+
- name: Install CycloneDX
28+
run: dotnet tool install --global CycloneDX
29+
- name: Read version from csproj
30+
id: read_version
31+
run: |
32+
$version = ([xml](Get-Content ./src/EPPlus/EPPlus.csproj)).Project.PropertyGroup.Version | Where-Object { $_ } | Select-Object -First 1
33+
echo "VERSION=$version" >> $env:GITHUB_ENV
34+
shell: pwsh
35+
- name: Generate SBOM
36+
run: dotnet CycloneDX ./src/EPPlus/EPPlus.csproj -o ./sbom -F Json -st Library -sv ${{ env.VERSION }} -fn epplus-${{ env.VERSION }}.sbom.json -imp ./src/EPPlus/sbom-metadata-template.xml
37+
- name: Generate SHA-256 checksum for SBOM
38+
run: |
39+
$sbomFile = "./sbom/epplus-${{ env.VERSION }}.sbom.json"
40+
$hash = (Get-FileHash -Path $sbomFile -Algorithm SHA256).Hash.ToLower()
41+
"$hash epplus-${{ env.VERSION }}.sbom.json" | Out-File -FilePath "./sbom/epplus-${{ env.VERSION }}.sbom.json.sha256" -Encoding utf8NoBOM
42+
shell: pwsh
43+
# --- SBOM ---
44+
2445
- name: Build
2546
run: dotnet build ./src/EPPlus.sln --no-restore --configuration Release
2647
- name: Test
@@ -70,3 +91,32 @@ jobs:
7091
with:
7192
name: signed-nuget-package
7293
path: ./output/*.nupkg
94+
# --- SBOM ---
95+
- name: Upload SBOM to Azure Blob Storage
96+
run: |
97+
az storage blob upload `
98+
--account-name eppluswebprod `
99+
--container-name sbom `
100+
--name epplus-${{ env.VERSION }}.sbom.json `
101+
--file ./sbom/epplus-${{ env.VERSION }}.sbom.json `
102+
--auth-mode login `
103+
--overwrite
104+
shell: pwsh
105+
- name: Upload SBOM checksum to Azure Blob Storage
106+
run: |
107+
az storage blob upload `
108+
--account-name eppluswebprod `
109+
--container-name sbom `
110+
--name epplus-${{ env.VERSION }}.sbom.json.sha256 `
111+
--file ./sbom/epplus-${{ env.VERSION }}.sbom.json.sha256 `
112+
--auth-mode login `
113+
--overwrite
114+
shell: pwsh
115+
- name: Upload SBOM as artifact
116+
uses: actions/upload-artifact@v4
117+
with:
118+
name: sbom
119+
path: |
120+
./sbom/epplus-${{ env.VERSION }}.sbom.json
121+
./sbom/epplus-${{ env.VERSION }}.sbom.json.sha256
122+
# --- SBOM ---

0 commit comments

Comments
 (0)