Files
wanderbooks/deploy/packaging/windows/sign-windows.ps1
T
swaitsandClaude Fable 5.2 8e3db472fa feat(packaging): a per-user Windows installer, a universal macOS app and dmg, desktop entries with the icon (P15 C1)
Windows: a hand-written NSIS script (per user, no administrator prompt,
installs under the profile's Programs folder; one program file; a Start
Menu entry named Wanderbooks with the icon; an uninstaller listed in
Settings > Apps that removes only what the installer put in its own
folder and never names the data folder). The installer asks the person to
quit the app fully before it replaces or removes the program. An optional
Authenticode signing step runs only when its secrets exist.

macOS: the .app is assembled by a script (Info.plist with the bundle
identifier, version, name, Documents-folder purpose string; the one
program at Contents/MacOS/wanderbooks; the licences), signed with the
hardened runtime and an empty entitlements file that says why, put in a
dmg with an Applications shortcut, notarized and stapled when the
owner's Apple identity is given and skipped with a notice when not. The
program is one universal binary (lipo of the two release builds).

Linux: both desktop entries name the window's app id and the icon; the
rpm now installs the icon; the deb, the pacman tarball and the rpm all
carry LICENSE-MIT and LICENSE-APACHE beside the notices.

One version: deploy/packaging/version.sh reads crates/ledger-cli's
Cargo.toml; every script takes it from there. Tests read the scripts and
build a bundle with a stand-in program.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-21 15:41:22 -07:00

37 lines
1.9 KiB
PowerShell

# Sign Windows files with an Authenticode code-signing certificate (plan P15
# unit C1). The release workflow runs this only when its secrets exist
# (WINDOWS_CERTIFICATE_PFX_BASE64 and WINDOWS_CERTIFICATE_PASSWORD); with none
# it prints a notice and the installer stays unsigned (SmartScreen warns).
#
# sign-windows.ps1 FILE [FILE...]
#
# The certificate is written to a temporary file for the signing and
# removed. Nothing here prints a secret. A failure is loud: a signature that
# was asked for and did not happen stops the release.
param([Parameter(Mandatory = $true, ValueFromRemainingArguments = $true)][string[]]$Files)
$ErrorActionPreference = 'Stop'
if (-not $env:WINDOWS_CERTIFICATE_PFX_BASE64 -or -not $env:WINDOWS_CERTIFICATE_PASSWORD) {
Write-Host "::notice title=Windows signing skipped::no WINDOWS_CERTIFICATE_PFX_BASE64 / WINDOWS_CERTIFICATE_PASSWORD secret: the installer is unsigned and Windows SmartScreen will warn on the first run."
exit 0
}
$signtool = Get-ChildItem "${env:ProgramFiles(x86)}\Windows Kits\10\bin" -Recurse -Filter signtool.exe -ErrorAction SilentlyContinue |
Where-Object { $_.FullName -match '\\x64\\' } |
Sort-Object FullName -Descending | Select-Object -First 1
if (-not $signtool) { throw "signtool.exe was not found in the Windows SDK on this runner" }
$pfx = Join-Path $env:RUNNER_TEMP 'wanderbooks-codesign.pfx'
[IO.File]::WriteAllBytes($pfx, [Convert]::FromBase64String($env:WINDOWS_CERTIFICATE_PFX_BASE64))
try {
foreach ($file in $Files) {
& $signtool.FullName sign /fd sha256 /f $pfx /p $env:WINDOWS_CERTIFICATE_PASSWORD /tr http://timestamp.digicert.com /td sha256 $file
if ($LASTEXITCODE -ne 0) { throw "signtool failed on $file" }
& $signtool.FullName verify /pa $file
if ($LASTEXITCODE -ne 0) { throw "the signature on $file does not verify" }
Write-Host "signed $file"
}
} finally {
Remove-Item $pfx -Force -ErrorAction SilentlyContinue
}