Skip to content

Commit ea883a3

Browse files
authored
fix: add diagnostic logging to Windows sign script (#45)
* fix: resolve absolute paths in Windows signCommand for Tauri bundler * fix: add diagnostic logging to Windows sign script for Tauri bundler Tauri's bundler output_ok() discards subprocess stdout/stderr when the sign command exits non-zero, making failures invisible. The sign script has been running and failing silently for three releases. Changes: - sign-windows.ps1: Add Start-Transcript file logging, validate all prerequisites (java, jsign jar, certificate, env vars) with explicit error messages before attempting to sign - release.yml: Add RUST_LOG=debug for bundler-side logging, add post-failure step to dump the sign script transcript log
1 parent 9368ee0 commit ea883a3

2 files changed

Lines changed: 96 additions & 5 deletions

File tree

.github/workflows/release.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,9 @@ jobs:
110110
- uses: tauri-apps/tauri-action@v0
111111
env:
112112
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
113+
# Enable bundler debug logging — sign command stdout/stderr is
114+
# swallowed on failure; RUST_LOG surfaces the command invocation.
115+
RUST_LOG: tauri_bundler=debug
113116
# macOS signing & notarization (optional — skipped if not set)
114117
APPLE_CERTIFICATE: ${{ secrets.MACOS_CERTIFICATE }}
115118
APPLE_CERTIFICATE_PASSWORD: ${{ secrets.MACOS_CERTIFICATE_PWD }}
@@ -132,3 +135,27 @@ jobs:
132135
releaseDraft: true
133136
prerelease: false
134137
args: ${{ matrix.args }} ${{ env.SIGNING_ARGS }}
138+
139+
# Dump sign script log on failure — Tauri bundler swallows subprocess
140+
# stdout/stderr when the sign command exits non-zero, making failures
141+
# invisible. The script writes a transcript to $RUNNER_TEMP/sign-windows.log.
142+
- name: Dump signing log on failure
143+
if: failure() && matrix.platform == 'windows-latest'
144+
shell: pwsh
145+
run: |
146+
$logFile = Join-Path $env:RUNNER_TEMP "sign-windows.log"
147+
if (Test-Path $logFile) {
148+
Write-Host "=== sign-windows.log ==="
149+
Get-Content $logFile
150+
Write-Host "=== end sign-windows.log ==="
151+
} else {
152+
Write-Host "No sign-windows.log found at $logFile"
153+
Write-Host "Sign script may not have been invoked, or RUNNER_TEMP differs."
154+
Write-Host "Checking TEMP fallback..."
155+
$fallback = Join-Path $env:TEMP "sign-windows.log"
156+
if (Test-Path $fallback) {
157+
Get-Content $fallback
158+
} else {
159+
Write-Host "No log file found at $fallback either."
160+
}
161+
}

scripts/sign-windows.ps1

Lines changed: 69 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
#
44
# Called by Tauri as: pwsh -File scripts/sign-windows.ps1 <file_path>
55
#
6+
# NOTE: Tauri's bundler swallows stdout/stderr from sign commands on failure
7+
# (output_ok() discards output on non-zero exit). All diagnostic output is
8+
# tee'd to a log file so a post-failure workflow step can dump it.
9+
#
610
# Required environment variables:
711
# JSIGN_PATH - Path to jsign JAR file
812
# EV_KEYSTORE - GCP Cloud KMS keystore URL
@@ -16,9 +20,20 @@ param(
1620
[string]$FilePath
1721
)
1822

23+
# Log to file since Tauri bundler discards subprocess output on failure
24+
$logDir = if ($env:RUNNER_TEMP) { $env:RUNNER_TEMP } else { $env:TEMP }
25+
$logFile = Join-Path $logDir "sign-windows.log"
26+
Start-Transcript -Path $logFile -Append -Force | Out-Null
27+
28+
Write-Host "=== sign-windows.ps1 started at $(Get-Date -Format o) ==="
29+
Write-Host "FilePath: $FilePath"
30+
Write-Host "PID: $PID"
31+
Write-Host "PowerShell: $($PSVersionTable.PSVersion)"
32+
1933
# Check if signing is configured
2034
if (-not $env:JSIGN_PATH -or -not $env:EV_KEYSTORE) {
2135
Write-Host "Windows code signing not configured - skipping $FilePath"
36+
Stop-Transcript | Out-Null
2237
exit 0
2338
}
2439

@@ -33,10 +48,47 @@ $requiredVars = @(
3348
)
3449

3550
foreach ($varName in $requiredVars) {
36-
if (-not [System.Environment]::GetEnvironmentVariable($varName)) {
51+
$val = [System.Environment]::GetEnvironmentVariable($varName)
52+
if (-not $val) {
3753
Write-Error "Missing required environment variable: $varName"
54+
Stop-Transcript | Out-Null
3855
exit 1
3956
}
57+
# Log presence without leaking secrets
58+
$display = if ($varName -eq "GCLOUD_ACCESS_TOKEN") { "***($($val.Length) chars)" } else { $val }
59+
Write-Host "${varName}: $display"
60+
}
61+
62+
# Verify file exists
63+
if (-not (Test-Path $FilePath)) {
64+
Write-Error "File not found: $FilePath"
65+
Stop-Transcript | Out-Null
66+
exit 1
67+
}
68+
Write-Host "File exists: $FilePath ($($(Get-Item $FilePath).Length) bytes)"
69+
70+
# Verify java is available
71+
$javaCmd = Get-Command java -ErrorAction SilentlyContinue
72+
if (-not $javaCmd) {
73+
Write-Error "java not found in PATH"
74+
Write-Host "PATH: $env:PATH"
75+
Stop-Transcript | Out-Null
76+
exit 1
77+
}
78+
Write-Host "Java: $($javaCmd.Source)"
79+
80+
# Verify jsign jar exists
81+
if (-not (Test-Path $env:JSIGN_PATH)) {
82+
Write-Error "jsign jar not found: $env:JSIGN_PATH"
83+
Stop-Transcript | Out-Null
84+
exit 1
85+
}
86+
87+
# Verify certificate exists
88+
if (-not (Test-Path $env:EV_CERTIFICATE_PATH)) {
89+
Write-Error "Certificate file not found: $env:EV_CERTIFICATE_PATH"
90+
Stop-Transcript | Out-Null
91+
exit 1
4092
}
4193

4294
Write-Host "Signing $FilePath with EV certificate..."
@@ -53,10 +105,22 @@ $jsignArgs = @(
53105
$FilePath
54106
)
55107

56-
& java @jsignArgs
57-
if ($LASTEXITCODE -ne 0) {
58-
Write-Error "Failed to sign $FilePath (exit code: $LASTEXITCODE)"
59-
exit 1
108+
# Log the command (mask the access token)
109+
$displayArgs = $jsignArgs.Clone()
110+
$storepassIdx = [Array]::IndexOf($displayArgs, "--storepass")
111+
if ($storepassIdx -ge 0 -and ($storepassIdx + 1) -lt $displayArgs.Length) {
112+
$displayArgs[$storepassIdx + 1] = "***"
113+
}
114+
Write-Host "Running: java $($displayArgs -join ' ')"
115+
116+
& java @jsignArgs 2>&1 | ForEach-Object { Write-Host $_ }
117+
$exitCode = $LASTEXITCODE
118+
119+
if ($exitCode -ne 0) {
120+
Write-Error "Failed to sign $FilePath (exit code: $exitCode)"
121+
Stop-Transcript | Out-Null
122+
exit $exitCode
60123
}
61124

62125
Write-Host "Successfully signed $FilePath"
126+
Stop-Transcript | Out-Null

0 commit comments

Comments
 (0)