param([switch]$Publish) $ErrorActionPreference = 'Stop' Push-Location (Split-Path $PSScriptRoot -Parent) try { # Invalidate any older result even if npm ci or tests fail. Remove-Item -LiteralPath 'dist/release/release-ready.json' -Force -ErrorAction SilentlyContinue npm ci if ($LASTEXITCODE -ne 0) { throw 'Dependency installation failed.' } npm run release:win if ($LASTEXITCODE -ne 0) { throw 'Signed release build failed.' } if ($Publish) { npm run publish:release -- --upload } else { npm run publish:release } if ($LASTEXITCODE -ne 0) { throw 'Release verification or publication failed.' } } finally { Pop-Location }