|
32 | 32 | id-token: write
|
33 | 33 | env:
|
34 | 34 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
| 35 | + # renovate: datasource=github-releases depName=cosign packageName=sigstore/cosign |
| 36 | + COSIGN_VERSION: v2.5.3 |
35 | 37 | COSIGN_YES: "yes"
|
36 | 38 |
|
37 | 39 | outputs:
|
|
52 | 54 | - name: Install Cosign
|
53 | 55 | uses: sigstore/cosign-installer@d7543c93d881b35a8faa02e8e3605f69b7a1ce62 # v3.10.0
|
54 | 56 | with:
|
55 |
| - cosign-release: v2.5.3 |
| 57 | + cosign-release: ${{ env.COSIGN_VERSION }} |
56 | 58 |
|
57 | 59 | - name: dotnet restore
|
58 | 60 | run: dotnet restore ./build/OpenTelemetry.proj -p:RunningDotNetPack=true
|
|
71 | 73 |
|
72 | 74 | Get-ChildItem -Path artifacts/bin/$projectName/release_*/$projectName.dll -File | ForEach-Object {
|
73 | 75 | $fileFullPath = $_.FullName
|
74 |
| - Write-Host "Signing $fileFullPath" |
| 76 | + Write-Output "Signing $fileFullPath" |
75 | 77 |
|
76 | 78 | cosign.exe sign-blob $fileFullPath --yes --output-signature $fileFullPath-keyless.sig --output-certificate $fileFullPath-keyless.pem
|
77 | 79 | }
|
|
83 | 85 | PACK_TAG: ${{ github.ref_type == 'tag' && github.ref_name || '' }}
|
84 | 86 | run: dotnet pack ./build/OpenTelemetry.proj --configuration Release --no-restore --no-build -p:"PackTag=${env:PACK_TAG}"
|
85 | 87 |
|
| 88 | + - name: Verify package DLL Cosign Keyless signatures |
| 89 | + shell: pwsh |
| 90 | + run: | |
| 91 | + $nupkgFiles = Get-ChildItem -Path artifacts/package/release/*.nupkg -File |
| 92 | +
|
| 93 | + # Copy the NuGet packages to a temporary directory and extract them |
| 94 | + $tempDir = New-Item -ItemType Directory -Path (Join-Path -Path ${env:RUNNER_TEMP} -ChildPath ([System.Guid]::NewGuid().ToString())) |
| 95 | + foreach ($nupkgFile in $nupkgFiles) { |
| 96 | + $nupkgFilePath = $nupkgFile.FullName |
| 97 | + $packageName = [System.IO.Path]::GetFileNameWithoutExtension($nupkgFilePath) |
| 98 | + Write-Output "Extracting $nupkgFilePath" |
| 99 | + Expand-Archive -Path $nupkgFilePath -DestinationPath (Join-Path $tempDir.FullName $packageName) |
| 100 | + } |
| 101 | +
|
| 102 | + # Iterate over all DLL files in the extracted packages and verify their signatures |
| 103 | + $dllFiles = Get-ChildItem -Path $tempDir.FullName -Recurse -Filter *.dll -File |
| 104 | + foreach ($dllFile in $dllFiles) { |
| 105 | + $dllFilePath = $dllFile.FullName |
| 106 | + Write-Output "Verifying $dllFilePath" |
| 107 | + cosign.exe verify-blob ` |
| 108 | + --signature $dllFilePath-keyless.sig ` |
| 109 | + --certificate $dllFilePath-keyless.pem ` |
| 110 | + --certificate-identity "${env:GITHUB_SERVER_URL}/${env:GITHUB_REPOSITORY}/.github/workflows/publish-packages-1.0.yml@${env:GITHUB_REF}" ` |
| 111 | + --certificate-oidc-issuer "https://token.actions.githubusercontent.com" ` |
| 112 | + $dllFilePath |
| 113 | + if ($LASTEXITCODE -ne 0) { |
| 114 | + Write-Output "::error::Signature verification failed for $dllFilePath." |
| 115 | + exit 1 |
| 116 | + } |
| 117 | + Write-Output "Signature verification succeeded for $dllFilePath" |
| 118 | + } |
| 119 | +
|
86 | 120 | - name: Publish Artifacts
|
87 | 121 | id: upload-artifacts
|
88 | 122 | uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
|
0 commit comments