Prepare NetX 0.4.14 Windows release

This commit is contained in:
oliver 2026-10-12 15:54:53 +08:00
parent af8d5a8d37
commit a5c9a8f58d
10 changed files with 320 additions and 42 deletions

View file

@ -17,12 +17,20 @@ if (-not $Version) {
$tag = "v$Version"
$releaseDir = Join-Path $PSScriptRoot "release"
$setup = Join-Path $releaseDir "NetX-Setup-$Version.exe"
$checksum = "$setup.sha256"
$stage = Join-Path $releaseDir "netx-win64"
function Assert-NativeSuccess([string]$Operation) {
if ($LASTEXITCODE -ne 0) { throw "$Operation failed with exit code $LASTEXITCODE" }
}
Write-Host "==> NetX publish $tag"
if (-not $SkipBuild) {
if (Test-Path -LiteralPath $setup) { Remove-Item -LiteralPath $setup -Force }
& powershell -ExecutionPolicy Bypass -File (Join-Path $PSScriptRoot "build_release.ps1") `
-Version $Version -CreateVenv
Assert-NativeSuccess 'Build stage'
}
if (-not $SkipInstaller) {
@ -38,8 +46,10 @@ if (-not $SkipInstaller) {
throw "innosetup_not_found: install with winget install JRSoftware.InnoSetup"
}
Write-Host "==> Compiling installer: $iscc"
if (Test-Path -LiteralPath $setup) { Remove-Item -LiteralPath $setup -Force }
& $iscc "/DMyAppVersion=$Version" (Join-Path $PSScriptRoot "installer\netx.iss")
if (-not (Test-Path $setup)) {
Assert-NativeSuccess 'Inno Setup compilation'
if (-not (Test-Path -LiteralPath $setup) -or (Get-Item -LiteralPath $setup).Length -lt 1MB) {
throw "installer_build_failed: expected $setup"
}
Write-Host "==> Setup.exe: $setup" -ForegroundColor Green
@ -49,11 +59,26 @@ if (-not (Test-Path $setup)) {
throw "missing_setup: $setup"
}
$stageVersionPath = Join-Path $stage 'version.json'
if (-not (Test-Path -LiteralPath $stageVersionPath)) { throw "missing_release_stage: $stageVersionPath" }
$stageVersion = (Get-Content -LiteralPath $stageVersionPath -Raw | ConvertFrom-Json).version
if ([string]$stageVersion -ne $Version) {
throw "release_version_mismatch: requested=$Version stage=$stageVersion"
}
if ((Get-Item -LiteralPath $setup).LastWriteTimeUtc -lt (Get-Item -LiteralPath $stageVersionPath).LastWriteTimeUtc) {
throw "stale_installer: $setup predates the release stage; rebuild or recompile before publishing"
}
if ($Sign) {
Write-Host "==> Signing release artifacts"
& powershell -ExecutionPolicy Bypass -File (Join-Path $PSScriptRoot "sign_release.ps1") -Files @($setup)
Assert-NativeSuccess 'Code signing'
}
$hash = (Get-FileHash -LiteralPath $setup -Algorithm SHA256).Hash.ToLowerInvariant()
Set-Content -LiteralPath $checksum -Value $hash -Encoding ascii -NoNewline
Write-Host "==> SHA-256 $hash"
if ($SkipGitHub) {
Write-Host "==> Skip GitHub release (-SkipGitHub)"
exit 0
@ -72,7 +97,8 @@ $viewCode = $LASTEXITCODE
$ErrorActionPreference = $prevEap
if ($viewCode -eq 0) {
Write-Host "==> Release $tag exists; uploading assets"
gh release upload $tag $setup --clobber
gh release upload $tag $setup $checksum --clobber
Assert-NativeSuccess 'GitHub asset upload'
} else {
$notes = @"
## NetX $Version
@ -99,8 +125,11 @@ See [packaging/README.md](https://github.com/hansjone/netx/blob/main/packaging/R
$args = @("release", "create", $tag, "--title", "NetX $Version", "--notes", $notes)
if ($Draft) { $args += "--draft" }
$args += $setup
$args += $checksum
& gh @args
Assert-NativeSuccess 'GitHub release creation'
}
Write-Host "==> Published $tag" -ForegroundColor Green
gh release view $tag --web 2>$null
Assert-NativeSuccess 'GitHub release verification'