|
93 | 93 | $ErrorActionPreference = 'Stop' |
94 | 94 | # Sync certificates from DigiCert cloud to local Windows certificate store |
95 | 95 | # This is required so signtool can find the certificate |
96 | | - smctl windows certsync |
| 96 | + Write-Host "Syncing certificates from DigiCert cloud..." |
| 97 | + smctl windows certsync --verbose |
97 | 98 | # Run healthcheck to confirm everything is connected |
98 | 99 | smctl healthcheck |
99 | 100 |
|
@@ -130,23 +131,32 @@ jobs: |
130 | 131 | $ErrorActionPreference = 'Stop' |
131 | 132 | $targetDir = Join-Path $env:GITHUB_WORKSPACE 'target\x86_64-pc-windows-msvc\release' |
132 | 133 |
|
133 | | - # Find the code signing certificate synced from DigiCert |
134 | | - $cert = Get-ChildItem Cert:\CurrentUser\My -CodeSigningCert | Select-Object -First 1 |
| 134 | + # Check if certsync placed a code signing certificate in the store |
| 135 | + $cert = Get-ChildItem Cert:\CurrentUser\My -CodeSigningCert -ErrorAction SilentlyContinue | Select-Object -First 1 |
135 | 136 | if (-not $cert) { |
136 | | - $cert = Get-ChildItem Cert:\LocalMachine\My -CodeSigningCert | Select-Object -First 1 |
| 137 | + $cert = Get-ChildItem Cert:\LocalMachine\My -CodeSigningCert -ErrorAction SilentlyContinue | Select-Object -First 1 |
137 | 138 | } |
138 | | - if (-not $cert) { |
139 | | - throw "No code signing certificate found in certificate store" |
140 | | - } |
141 | | - $thumbprint = $cert.Thumbprint |
142 | | - Write-Host "Using certificate: $($cert.Subject) [$thumbprint]" |
143 | 139 |
|
144 | | - foreach ($exe in @('spacetimedb-update.exe','spacetimedb-cli.exe','spacetimedb-standalone.exe')) { |
145 | | - $path = Join-Path $targetDir $exe |
146 | | - Write-Host "Signing $exe..." |
147 | | - & signtool.exe sign /sha1 $thumbprint /tr http://timestamp.digicert.com /td SHA256 /fd SHA256 $path |
148 | | - if ($LASTEXITCODE -ne 0) { throw "Signing failed for $exe (exit code $LASTEXITCODE)" } |
149 | | - Write-Host "$exe signed successfully" |
| 140 | + if ($cert) { |
| 141 | + $thumbprint = $cert.Thumbprint |
| 142 | + Write-Host "Found certificate: $($cert.Subject) [$thumbprint]" |
| 143 | + Write-Host "Signing with signtool /sha1..." |
| 144 | + foreach ($exe in @('spacetimedb-update.exe','spacetimedb-cli.exe','spacetimedb-standalone.exe')) { |
| 145 | + $path = Join-Path $targetDir $exe |
| 146 | + Write-Host "Signing $exe..." |
| 147 | + & signtool.exe sign /sha1 $thumbprint /tr http://timestamp.digicert.com /td SHA256 /fd SHA256 $path |
| 148 | + if ($LASTEXITCODE -ne 0) { throw "Signing failed for $exe (exit code $LASTEXITCODE)" } |
| 149 | + Write-Host "$exe signed successfully" |
| 150 | + } |
| 151 | + } else { |
| 152 | + Write-Host "No cert in store, using smctl sign with keypair alias..." |
| 153 | + foreach ($exe in @('spacetimedb-update.exe','spacetimedb-cli.exe','spacetimedb-standalone.exe')) { |
| 154 | + $path = Join-Path $targetDir $exe |
| 155 | + Write-Host "Signing $exe..." |
| 156 | + & smctl sign --verbose --keypair-alias $env:DIGICERT_KEYPAIR_ALIAS --input $path |
| 157 | + if ($LASTEXITCODE -ne 0) { throw "Signing failed for $exe (exit code $LASTEXITCODE)" } |
| 158 | + Write-Host "$exe signed successfully" |
| 159 | + } |
150 | 160 | } |
151 | 161 |
|
152 | 162 | - name: Verify signatures |
|
0 commit comments