Skip to content

Commit bbe2dd0

Browse files
committed
Improve PowerShell signing workflow
- Better certificate detection using thumbprint - Enhanced error handling and logging - More robust signing process
1 parent 63a3a14 commit bbe2dd0

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

.github/workflows/sign-ps1.yml

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,30 @@ jobs:
3030
$cert | Export-Certificate -FilePath cert.cer -Type CERT
3131
Write-Host "Certificate exported to cert.cer"
3232
33+
# Store thumbprint for next step
34+
$cert.Thumbprint | Out-File -FilePath cert_thumbprint.txt
35+
Write-Host "Thumbprint saved to cert_thumbprint.txt"
36+
3337
- name: Sign PowerShell script
3438
shell: powershell
3539
run: |
3640
Write-Host "Signing setup_venv.ps1..."
37-
$cert = Get-ChildItem Cert:\CurrentUser\My -CodeSigningCert | Select-Object -First 1
41+
$thumbprint = Get-Content cert_thumbprint.txt
42+
Write-Host "Using certificate thumbprint: $thumbprint"
43+
44+
$cert = Get-ChildItem Cert:\CurrentUser\My\$thumbprint
3845
if (-not $cert) {
39-
throw "No code signing certificate found"
46+
Write-Host "Certificate not found. Available certificates:"
47+
Get-ChildItem Cert:\CurrentUser\My | Where-Object { $_.HasPrivateKey } | Format-Table Subject, Thumbprint
48+
throw "Code signing certificate not found"
4049
}
4150
42-
Set-AuthenticodeSignature -FilePath "setup_venv.ps1" -Certificate $cert
51+
Write-Host "Using certificate: $($cert.Subject)"
52+
$result = Set-AuthenticodeSignature -FilePath "setup_venv.ps1" -Certificate $cert
53+
Write-Host "Signature result: $($result.Status)"
54+
if ($result.Status -ne "Valid") {
55+
throw "Failed to sign script: $($result.StatusMessage)"
56+
}
4357
Write-Host "Script signed successfully"
4458
4559
- name: Verify signature

0 commit comments

Comments
 (0)