From 84ff215a5d473bd92bb287b73ff347112e1e6594 Mon Sep 17 00:00:00 2001 From: Tom Tan Date: Mon, 28 Oct 2024 15:31:21 -0700 Subject: [PATCH] [BUILD] Signing OpenTelemetry .NET DLLs Using Sigstore certificate (#5880) Co-authored-by: Mikel Blanchard --- .github/workflows/publish-packages-1.0.yml | 27 ++++++++++++++++++++++ build/Common.prod.props | 13 +++++++++++ 2 files changed, 40 insertions(+) diff --git a/.github/workflows/publish-packages-1.0.yml b/.github/workflows/publish-packages-1.0.yml index 7553bd66627..df29e3af554 100644 --- a/.github/workflows/publish-packages-1.0.yml +++ b/.github/workflows/publish-packages-1.0.yml @@ -23,6 +23,12 @@ jobs: build-pack-publish: runs-on: windows-latest + permissions: + contents: read + id-token: write + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + COSIGN_YES: "yes" outputs: artifact-url: ${{ steps.upload-artifacts.outputs.artifact-url }} @@ -39,12 +45,33 @@ jobs: - name: Setup dotnet uses: actions/setup-dotnet@v4 + - name: Install Cosign + uses: sigstore/cosign-installer@v3 + with: + cosign-release: v2.4.0 + - name: dotnet restore run: dotnet restore ./build/OpenTelemetry.proj -p:RunningDotNetPack=true - name: dotnet build run: dotnet build ./build/OpenTelemetry.proj --configuration Release --no-restore -p:Deterministic=true -p:BuildNumber=${{ github.run_number }} -p:RunningDotNetPack=true + - name: Sign DLLs with Cosign Keyless + shell: pwsh + run: | + $projectFiles = Get-ChildItem -Path src/*/*.csproj -File + + foreach ($projectFile in $projectFiles) { + $projectName = [System.IO.Path]::GetFileNameWithoutExtension($projectFile) + + Get-ChildItem -Path src/$projectName/bin/Release/*/$projectName.dll -File | ForEach-Object { + $fileFullPath = $_.FullName + Write-Host "Signing $fileFullPath" + + cosign.exe sign-blob $fileFullPath --yes --output-signature $fileFullPath-keyless.sig --output-certificate $fileFullPath-keyless.pem + } + } + - name: dotnet pack run: dotnet pack ./build/OpenTelemetry.proj --configuration Release --no-restore --no-build -p:PackTag=${{ github.ref_type == 'tag' && github.ref_name || '' }} diff --git a/build/Common.prod.props b/build/Common.prod.props index 3738c0a691d..832306e1405 100644 --- a/build/Common.prod.props +++ b/build/Common.prod.props @@ -60,6 +60,19 @@ + + + + + + + + + + + + +