Skip to content

Commit 8fcf051

Browse files
committed
Update Code Signing to use GitHub Actions and Software Trust Manager
1 parent c43439d commit 8fcf051

1 file changed

Lines changed: 33 additions & 37 deletions

File tree

.github/workflows/package.yml

Lines changed: 33 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -50,57 +50,53 @@ jobs:
5050
- name: Install rust target
5151
run: rustup target add ${{ matrix.target }}
5252

53-
- name: Add signtool.exe to PATH
54-
if: ${{ runner.os == 'Windows' }}
55-
shell: pwsh
53+
- name: Decode DigiCert client auth certificate
54+
if: ${{ runner.os == 'Windows' && startsWith(github.ref, 'refs/tags/') }}
55+
shell: bash
5656
run: |
57-
$root = "${env:ProgramFiles(x86)}\Windows Kits\10\bin"
58-
$signtool = Get-ChildItem $root -Recurse -Filter signtool.exe -ErrorAction SilentlyContinue |
59-
Where-Object { $_.FullName -match '\\x64\\signtool\.exe$' } |
60-
Sort-Object FullName -Descending |
61-
Select-Object -First 1
62-
63-
if (-not $signtool) { throw "signtool.exe not found under $root" }
57+
echo "${{ secrets.SM_CLIENT_CERT_FILE_B64 }}" | base64 --decode > /d/Certificate_pkcs12.p12
6458
65-
"Found: $($signtool.FullName)"
66-
$dir = Split-Path $signtool.FullName
67-
Add-Content -Path $env:GITHUB_PATH -Value $dir
68-
69-
- name: Write certificate file for signing
70-
if: ${{ runner.os == 'Windows' }}
71-
shell: powershell
59+
- name: Setup DigiCert Software Trust Manager
60+
if: ${{ runner.os == 'Windows' && startsWith(github.ref, 'refs/tags/') }}
61+
uses: digicert/code-signing-software-trust-action@v1
7262
env:
73-
DIGICERT_CERT_B64: ${{ secrets.DIGICERT_CERT_B64 }}
74-
run: |
75-
[IO.File]::WriteAllBytes("digicert.pfx", [Convert]::FromBase64String($env:DIGICERT_CERT_B64))
63+
SM_HOST: ${{ vars.SM_HOST }}
64+
SM_API_KEY: ${{ secrets.SM_API_KEY }}
65+
SM_CLIENT_CERT_FILE: D:\Certificate_pkcs12.p12
66+
SM_CLIENT_CERT_PASSWORD: ${{ secrets.SM_CLIENT_CERT_PASSWORD }}
7667

7768
- name: Compile
7869
run: |
7970
cargo build --release --target ${{ matrix.target }} -p spacetimedb-cli -p spacetimedb-standalone -p spacetimedb-update
8071
8172
- name: Sign binaries for Windows
82-
# Disabled for now since the current flow isn't working.
83-
if: false
84-
#if: ${{ runner.os == 'Windows' }}
85-
shell: powershell
73+
if: ${{ runner.os == 'Windows' && startsWith(github.ref, 'refs/tags/') }}
74+
shell: bash
8675
env:
8776
DIGICERT_KEYPAIR_ALIAS: ${{ secrets.DIGICERT_KEYPAIR_ALIAS }}
77+
run: |
78+
targetDir="$GITHUB_WORKSPACE/target/x86_64-pc-windows-msvc/release"
79+
for exe in spacetimedb-update.exe spacetimedb-cli.exe spacetimedb-standalone.exe; do
80+
echo "Signing $exe..."
81+
smctl sign --keypair-alias "$DIGICERT_KEYPAIR_ALIAS" \
82+
--input "$targetDir/$exe"
83+
done
84+
85+
- name: Verify signatures
86+
if: ${{ runner.os == 'Windows' && startsWith(github.ref, 'refs/tags/') }}
87+
shell: pwsh
8888
run: |
8989
$ErrorActionPreference = 'Stop'
90-
$targetDir = Join-Path $env:GITHUB_WORKSPACE 'target\x86_64-pc-windows-msvc\release'
91-
$certFile = Join-Path $env:GITHUB_WORKSPACE 'digicert.pfx'
92-
93-
$signtool = Get-Command signtool.exe -ErrorAction Stop
94-
95-
$files = @(
96-
(Join-Path $targetDir 'spacetimedb-update.exe'),
97-
(Join-Path $targetDir 'spacetimedb-cli.exe'),
98-
(Join-Path $targetDir 'spacetimedb-standalone.exe')
99-
)
90+
$root = "${env:ProgramFiles(x86)}\Windows Kits\10\bin"
91+
$signtool = Get-ChildItem $root -Recurse -Filter signtool.exe -ErrorAction SilentlyContinue |
92+
Where-Object { $_.FullName -match '\\x64\\signtool\.exe$' } |
93+
Sort-Object FullName -Descending |
94+
Select-Object -First 1
95+
if (-not $signtool) { throw "signtool.exe not found" }
10096
101-
foreach ($file in $files) {
102-
& $signtool.Path sign /f $certFile /tr http://timestamp.digicert.com /td SHA256 /fd SHA256 $file
103-
& $signtool.Path verify /v /pa $file
97+
$targetDir = Join-Path $env:GITHUB_WORKSPACE 'target\x86_64-pc-windows-msvc\release'
98+
foreach ($exe in @('spacetimedb-update.exe','spacetimedb-cli.exe','spacetimedb-standalone.exe')) {
99+
& $signtool.FullName verify /v /pa (Join-Path $targetDir $exe)
104100
}
105101
106102
- name: Package (unix)

0 commit comments

Comments
 (0)