diff options
Diffstat (limited to '.github/workflows/sign-windows-release.yml')
| -rw-r--r-- | .github/workflows/sign-windows-release.yml | 142 |
1 files changed, 142 insertions, 0 deletions
diff --git a/.github/workflows/sign-windows-release.yml b/.github/workflows/sign-windows-release.yml new file mode 100644 index 00000000..a040ab43 --- /dev/null +++ b/.github/workflows/sign-windows-release.yml @@ -0,0 +1,142 @@ +name: Sign Windows Release + +on: + workflow_call: + inputs: + version: + required: true + type: string + release_channel: + required: true + type: string + rc_number: + required: false + type: string + default: "" + windows_signing: + required: false + type: string + default: signpath +permissions: + actions: read + contents: read + +jobs: + build: + uses: ./.github/workflows/build-windows.yml + with: + version: ${{ inputs.version }} + hamlib_branch: "4.7.2" + release_channel: ${{ inputs.release_channel }} + rc_number: ${{ inputs.rc_number }} + + sign: + if: inputs.windows_signing != 'unsigned' + needs: build + runs-on: ubuntu-latest + timeout-minutes: 90 + environment: windows-release-signing + permissions: + actions: read + contents: read + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7 + - name: Require a public RC or GA invocation + env: + VERSION: ${{ inputs.version }} + CHANNEL: ${{ inputs.release_channel }} + RC_NUMBER: ${{ inputs.rc_number }} + run: | + set -euo pipefail + IDENTITY=$(python3 .github/scripts/release-policy.py classify "$VERSION") + test "$(jq -r .channel <<<"$IDENTITY")" = "$CHANNEL" + test "$(jq -r .rc_number <<<"$IDENTITY")" = "$RC_NUMBER" + test "$GITHUB_REPOSITORY" = WSJTX/wsjtx + - name: Submit release signing request to SignPath + id: signpath + uses: signpath/github-action-submit-signing-request@v3 + with: + api-token: ${{ secrets.SIGNPATH_API_TOKEN }} + organization-id: "4c211821-e011-48a2-8a84-2cc29a76a8bf" + project-slug: wsjtx + signing-policy-slug: release-signing + github-artifact-id: ${{ needs.build.outputs.installer-artifact-id }} + wait-for-completion: true + wait-for-completion-timeout-in-seconds: "3600" + output-artifact-directory: signed + - name: Record signing request + env: + REQUEST_URL: ${{ steps.signpath.outputs.signing-request-web-url }} + run: | + printf '{"schema":1,"provider":"SignPath","policy":"release-signing","request_url":"%s","tag":"%s","commit":"%s"}\n' \ + "$REQUEST_URL" "$GITHUB_REF_NAME" "$GITHUB_SHA" > windows-signing-request.json + - name: Upload signed installer + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7 + with: + name: wsjtx-${{ inputs.version }}-windows-x86_64-installer-signed + path: signed/*.exe + if-no-files-found: error + - name: Upload signing request report + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7 + with: + name: wsjtx-${{ inputs.version }}-windows-signing-request + path: windows-signing-request.json + if-no-files-found: error + + verify: + needs: sign + runs-on: windows-latest + timeout-minutes: 15 + environment: windows-release-signing + steps: + - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8 + with: + name: wsjtx-${{ inputs.version }}-windows-x86_64-installer-signed + path: signed + - name: Verify trusted Authenticode signature and timestamp + shell: pwsh + env: + EXPECTED_SIGNER_SUBJECT: ${{ vars.WINDOWS_SIGNER_SUBJECT }} + EXPECTED_SIGNER_THUMBPRINTS: ${{ vars.WINDOWS_SIGNER_THUMBPRINTS }} + run: | + $exe = Get-ChildItem signed -Filter *.exe + if ($exe.Count -ne 1) { throw "Expected exactly one signed installer" } + $signtool = Get-ChildItem "C:\Program Files (x86)\Windows Kits\10\bin\*\x64\signtool.exe" | + Sort-Object FullName | Select-Object -Last 1 + if (-not $signtool) { throw "signtool.exe not found" } + & $signtool.FullName verify /pa /all /v $exe.FullName + if ($LASTEXITCODE -ne 0) { throw "Authenticode trust verification failed" } + $signature = Get-AuthenticodeSignature $exe.FullName + if ($signature.Status -ne 'Valid') { throw "Authenticode status is $($signature.Status)" } + if (-not $signature.TimeStamperCertificate) { throw "Installer signature has no trusted timestamp" } + if (-not $env:EXPECTED_SIGNER_SUBJECT) { throw "WINDOWS_SIGNER_SUBJECT is not configured" } + if ($signature.SignerCertificate.Subject -ne $env:EXPECTED_SIGNER_SUBJECT) { + throw "Unexpected Authenticode signer subject: $($signature.SignerCertificate.Subject)" + } + $allowedThumbprints = $env:EXPECTED_SIGNER_THUMBPRINTS.Split(',') | + ForEach-Object { $_.Replace(' ', '').ToUpperInvariant() } | + Where-Object { $_ } + $actualThumbprint = $signature.SignerCertificate.Thumbprint.ToUpperInvariant() + if ($allowedThumbprints.Count -eq 0 -or $actualThumbprint -notin $allowedThumbprints) { + throw "Unexpected Authenticode signer thumbprint: $actualThumbprint" + } + $sha256 = (Get-FileHash -Algorithm SHA256 $exe.FullName).Hash.ToLowerInvariant() + [ordered]@{ + schema = 1 + tag = $env:GITHUB_REF_NAME + commit = $env:GITHUB_SHA + artifact = $exe.Name + sha256 = $sha256 + status = $signature.Status.ToString() + signer_subject = $signature.SignerCertificate.Subject + signer_thumbprint = $signature.SignerCertificate.Thumbprint + identity_verified = $true + timestamp_subject = $signature.TimeStamperCertificate.Subject + timestamp_thumbprint = $signature.TimeStamperCertificate.Thumbprint + } | ConvertTo-Json | Set-Content windows-signing-verification.json + - name: Upload verification report + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7 + with: + name: wsjtx-${{ inputs.version }}-windows-signing-verification + path: windows-signing-verification.json + if-no-files-found: error |
