Skip to content

Add SBOM attestation #202

Add SBOM attestation

Add SBOM attestation #202

Workflow file for this run

name: BuildAndPack
on:
push:
branches:
- master
- main
tags:
- '*'
pull_request:
branches:
- '*'
jobs:
build-and-test:
strategy:
matrix:
include:
- os: windows
vm: windows-latest
- os: linux
vm: ubuntu-latest
- os: macos
vm: macos-13 # latest is arm64, and it breaks a bunch of stuff
env:
MSBuildEnableWorkloadResolver: false
name: ${{ matrix.os}}
runs-on: ${{ matrix.vm}}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-dotnet@v4
with:
dotnet-version: |
9.0.x
8.0.x
6.0.x
3.1.x
- name: Cache .nuke/temp, ~/.nuget/packages
uses: actions/cache@v3
with:
path: |
.nuke/temp
~/.nuget/packages
key: ${{ runner.os }}-${{ hashFiles('**/global.json', '**/*.csproj') }}
- name: Run './build.cmd Test Pack PushToNuGet GenerateSbom'
run: ./build.cmd Test Pack PushToNuGet GenerateSbom
env:
GithubToken: ${{ secrets.GITHUB_TOKEN }}
NuGetToken: ${{ secrets.NUGET_TOKEN }}
DOTNET_SYSTEM_GLOBALIZATION_INVARIANT: "true"
- uses: actions/upload-artifact@v4
if: ${{ matrix.os == 'windows' }}
with:
name: packages
path: artifacts/packages
- uses: actions/upload-artifact@v4
if: ${{ matrix.os == 'windows' }}
with:
name: sboms
path: artifacts/sboms
- uses: actions/upload-artifact@v4
with:
name: results-${{ matrix.os}}
path: artifacts/results
generate-attestations:
name: "Generate attestations"
needs: build-and-test
runs-on: ubuntu-latest
permissions:
id-token: write
attestations: write
steps:
- name: Download Sboms
uses: actions/download-artifact@v4
with:
name: sboms
path: artifacts/sboms
- name: Download packages
uses: actions/download-artifact@v4
with:
name: packages
path: artifacts/packages
- name: Attest package
uses: actions/attest-sbom@v2
with:
subject-path: artifacts/packages/NetEscapades.AspNetCore.SecurityHeaders.*.nupkg
sbom-path: artifacts/sboms/netescapades_aspnetcore_securityheaders.bom.json
- name: Attest testhelpers
uses: actions/attest-sbom@v2
with:
subject-path: artifacts/packages/NetEscapades.AspNetCore.SecurityHeaders.TagHelpers.*.nupkg
sbom-path: artifacts/sboms/netescapades_aspnetcore_securityheaders_taghelpers.bom.json
publish-test-results:
name: "Publish Tests Results"
needs: build-and-test
runs-on: ubuntu-latest
permissions:
checks: write
pull-requests: write # needed unless run with comment_mode: off
# contents: read # only needed for private repository
# issues: read # only needed for private repository
if: always()
steps:
- name: Download Artifacts
uses: actions/download-artifact@v4
with:
path: artifacts/results
- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action@v2
with:
files: "artifacts/**/*.trx"
json_thousands_separator: ","
check_run_annotations_branch: "*"