77
88param (
99 [string ]$Version ,
10- [switch ]$Help
10+ [switch ]$Help ,
11+ [switch ]$SkipBuild
1112)
1213
1314# Colors for PowerShell output
@@ -19,10 +20,10 @@ function Write-ColorOutput {
1920 Write-Host $Message - ForegroundColor $Color
2021}
2122
22- function Write-Success { param ([string ]$Message ) Write-ColorOutput " ✓ $Message " " Green" }
23- function Write-Warning { param ([string ]$Message ) Write-ColorOutput " ⚠ $Message " " Yellow" }
23+ function Write-Success { param ([string ]$Message ) Write-ColorOutput " [OK] $Message " " Green" }
24+ function Write-Warning { param ([string ]$Message ) Write-ColorOutput " [WARN] $Message " " Yellow" }
2425function Write-Error { param ([string ]$Message ) Write-ColorOutput " ✗ $Message " " Red" }
25- function Write-Info { param ([string ]$Message ) Write-ColorOutput " ℹ $Message " " Cyan" }
26+ function Write-Info { param ([string ]$Message ) Write-ColorOutput " [INFO] $Message " " Cyan" }
2627function Write-Step { param ([string ]$Message ) Write-ColorOutput " 🚀 $Message " " Magenta" }
2728
2829# Show help
@@ -36,6 +37,7 @@ It is designed to run AFTER the macOS release script has created the release.
3637Usage:
3738 .\scripts\release-windows.ps1 # Use version from package.json
3839 .\scripts\release-windows.ps1 1.4.0 # Use specific version
40+ .\scripts\release-windows.ps1 -SkipBuild # Skip build, use existing artifacts
3941 .\scripts\release-windows.ps1 -Help # Show this help
4042
4143Requirements:
@@ -62,6 +64,9 @@ Environment Variables:
6264
6365Write-Step " Starting VoiceTypr Windows Release Process"
6466
67+ # Remember initial directory so we can return even on errors
68+ $InitialDir = Get-Location
69+
6570# Error handling
6671$ErrorActionPreference = " Stop"
6772
@@ -154,6 +159,9 @@ Write-Success "Created output directory: $OutputDir"
154159$HasSigningKey = $false
155160$keyPath = " $env: USERPROFILE \.tauri\voicetypr.key"
156161
162+ # If needed you can export TAURI_SIGNING_PRIVATE_KEY_PATH before running this script
163+ # $env:TAURI_SIGNING_PRIVATE_KEY_PATH = "C:\Users\moinu\.tauri\voicetypr.key"
164+
157165# Auto-detect and set key path if file exists
158166if (Test-Path $keyPath ) {
159167 $env: TAURI_SIGNING_PRIVATE_KEY_PATH = $keyPath
@@ -171,25 +179,36 @@ if (Test-Path $keyPath) {
171179}
172180
173181# Build Windows NSIS installer
174- Write-Step " Building Windows NSIS installer..."
175- try {
176- Set-Location " src-tauri"
177- $buildOutput = cargo tauri build -- target x86_64- pc- windows- msvc 2>&1
178- Set-Location " .."
179-
180- if ($LASTEXITCODE -ne 0 ) {
181- Write-Error " Build failed. Output: $buildOutput "
182+ if (-not $SkipBuild ) {
183+ Write-Step " Building Windows NSIS installer..."
184+ try {
185+ # Run Tauri build with verbose output
186+ Write-Info " Building Tauri application (this may take several minutes)..."
187+
188+ # Set environment to skip signing if no key
189+ if (-not $HasSigningKey ) {
190+ $env: TAURI_SIGNING_PRIVATE_KEY = " "
191+ $env: TAURI_SIGNING_PRIVATE_KEY_PATH = " "
192+ }
193+
194+ # Run build with full output
195+ & pnpm tauri build -- verbose
196+
197+ if ($LASTEXITCODE -ne 0 ) {
198+ Write-Error " Tauri build failed with exit code: $LASTEXITCODE "
199+ exit 1
200+ }
201+ Write-Success " NSIS build completed"
202+ } catch {
203+ Write-Error " Failed to build: $ ( $_.Exception.Message ) "
182204 exit 1
183205 }
184- Write-Success " NSIS build completed"
185- } catch {
186- Set-Location " .." - ErrorAction SilentlyContinue
187- Write-Error " Failed to build NSIS: $ ( $_.Exception.Message ) "
188- exit 1
206+ } else {
207+ Write-Info " Skipping build step (using existing artifacts)"
189208}
190209
191210# Find the built NSIS installer
192- $NsisPath = Get-ChildItem - Path " src-tauri\target\x86_64-pc-windows-msvc\ release\bundle\nsis" - Filter " * -setup.exe" | Select-Object - First 1
211+ $NsisPath = Get-ChildItem - Path " src-tauri\target\release\bundle\nsis" - Filter " VoiceTypr_ ${Version} _x64 -setup.exe" | Select-Object - First 1
193212if (-not $NsisPath ) {
194213 Write-Error " NSIS installer not found in build output"
195214 exit 1
@@ -220,35 +239,43 @@ $NsisZipSignature = "SIGNATURE_PLACEHOLDER"
220239if ($HasSigningKey ) {
221240 Write-Info " Signing update artifacts..."
222241 try {
223- Set-Location " src-tauri"
242+ # Get absolute path for the zip file
243+ $zipFullPath = (Get-Item $NsisZipPath ).FullName
224244
225- # Sign the .msi.zip file
226- $signArgs = @ ( " tauri " , " signer " , " sign " )
245+ # Try multiple approaches to make signing work on Windows
246+ $keyContent = Get-Content $ env: TAURI_SIGNING_PRIVATE_KEY_PATH - Raw
227247
228- if ( $ env: TAURI_SIGNING_PRIVATE_KEY_PATH ) {
229- $signArgs += @ ( " -f " , $ env: TAURI_SIGNING_PRIVATE_KEY_PATH )
230- }
248+ # Approach 1: Use -f flag with key file path (most reliable)
249+ Write-Info " Attempting to sign with: pnpm tauri signer sign -f $keyPath -p '' <file> "
250+ $signOutput = & pnpm tauri signer sign -f $keyPath $zipFullPath 2>&1
231251
232- # No password for the key
233- $signArgs += @ (" -p" , " " )
234-
235- $signArgs += $NsisZipPath
252+ if ($LASTEXITCODE -ne 0 ) {
253+ # Approach 2: Set environment variables (npm version uses TAURI_PRIVATE_KEY)
254+ Write-Warning " Direct signing failed, trying with environment variables..."
255+ $env: TAURI_PRIVATE_KEY = $keyContent
256+ $env: TAURI_PRIVATE_KEY_PATH = $env: TAURI_SIGNING_PRIVATE_KEY_PATH
257+ $env: TAURI_SIGNING_PRIVATE_KEY = $keyContent
258+
259+ $signOutput = & pnpm tauri signer sign $zipFullPath 2>&1
260+ }
236261
237- $signOutput = & cargo @signArgs 2>&1
238- Set-Location " .."
262+ if ($LASTEXITCODE -ne 0 ) {
263+ Write-Error " Failed to sign. Output: $signOutput "
264+ exit 1
265+ }
239266
240267 if ($LASTEXITCODE -eq 0 -and (Test-Path " $NsisZipPath .sig" )) {
241268 $NsisZipSignature = Get-Content " $NsisZipPath .sig" - Raw
242269 $NsisZipSignature = $NsisZipSignature.Trim ()
243270 Write-Success " Update artifact signed successfully"
244271 } else {
245- Write-Warning " Failed to sign update artifact. Output: $signOutput "
246- Write-Warning " Proceeding without signature "
272+ Write-Error " Failed to sign update artifact. Output: $signOutput "
273+ exit 1
247274 }
248275 } catch {
249- Set-Location " .. " - ErrorAction SilentlyContinue
250- Write-Warning " Error during signing: $ ( $_.Exception.Message ) "
251- Write-Warning " Proceeding without signature "
276+ Set-Location $InitialDir - ErrorAction SilentlyContinue
277+ Write-Error " Error during signing: $ ( $_.Exception.Message ) "
278+ exit 1
252279 }
253280} else {
254281 Write-Warning " Skipping signature generation (no signing key configured)"
@@ -327,26 +354,26 @@ try {
327354Write-Step " Windows Release Complete!"
328355Write-Success " Successfully created and uploaded Windows release artifacts for v$Version "
329356Write-Host " "
330- Write-Info " 📦 Windows Release Artifacts:"
357+ Write-Info " Windows Release Artifacts:"
331358Get-ChildItem $OutputDir | ForEach-Object {
332359 $size = if ($_.Length -gt 1 MB ) { " {0:N2} MB" -f ($_.Length / 1 MB ) } else { " {0:N2} KB" -f ($_.Length / 1 KB ) }
333360 Write-Host " $ ( $_.Name ) ($size )" - ForegroundColor White
334361}
335362
336363Write-Host " "
337- Write-Info " 🔗 Release URL: https://github.com/moinulmoin/voicetypr/releases/tag/$ReleaseTag "
364+ Write-Info " Release URL: https://github.com/moinulmoin/voicetypr/releases/tag/$ReleaseTag "
338365
339366if ($HasSigningKey ) {
340- Write-Success " ✓ Update signatures generated - auto-updater ready"
367+ Write-Success " Update signatures generated - auto-updater ready"
341368} else {
342- Write-Warning " ⚠ No update signatures - auto-updater won't work"
369+ Write-Warning " No update signatures - auto-updater won` ' t work"
343370}
344371
345372Write-Host " "
346- Write-Info " 📋 Next Steps:"
373+ Write-Info " Next Steps:"
347374Write-Host " 1. Test the MSI installer on a clean Windows machine" - ForegroundColor Yellow
348375Write-Host " 2. Verify the Tauri updater works with the new artifacts" - ForegroundColor Yellow
349376Write-Host " 3. Update release notes if needed" - ForegroundColor Yellow
350377Write-Host " 4. Publish the release when ready" - ForegroundColor Yellow
351378
352- Write-Success " 🎉 Windows release process completed successfully!"
379+ Write-Success " Windows release process completed successfully!"
0 commit comments