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>
This commit is contained in:
1 parent
90f663ed54
commit
8e3db472fa
19 files changed
+1110
-86
No files matched your search
Executable
+63
@@ -0,0 +1,63 @@
|
||||
#!/usr/bin/env bash
|
||||
# The Windows installer (plan P15 unit C1), from the release program already
|
||||
# built at target/release/wanderbooks.exe (`cargo build --release -p
|
||||
# ledger-cli`). Run from the repository root, in Git Bash on Windows (CI:
|
||||
# the `windows` job of .github/workflows/release.yml) or anywhere makensis
|
||||
# is:
|
||||
#
|
||||
# build-windows.sh [VERSION]
|
||||
#
|
||||
# Puts Wanderbooks-VERSION-windows-x64-setup.exe into target/packages/VERSION/.
|
||||
# VERSION defaults to the program's own (deploy/packaging/version.sh).
|
||||
# WB_PROGRAM names another program file; WB_MAKENSIS another makensis.
|
||||
#
|
||||
# Unsigned: signing is a separate, optional step (sign-windows.ps1) that
|
||||
# runs when the release workflow has the certificate's secrets.
|
||||
set -euo pipefail
|
||||
|
||||
here=$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd)
|
||||
root=$(CDPATH='' cd -- "$here/../../.." && pwd)
|
||||
cd "$root"
|
||||
own=$(sh deploy/packaging/version.sh)
|
||||
version=${1:-$own}
|
||||
case "$version" in
|
||||
[0-9]*.[0-9]*.[0-9]*) ;;
|
||||
*) echo "build-windows: '$version' is not an x.y.z version" >&2; exit 1 ;;
|
||||
esac
|
||||
program=${WB_PROGRAM:-target/release/wanderbooks.exe}
|
||||
out="target/packages/$version"
|
||||
installer="Wanderbooks-$version-windows-x64-setup.exe"
|
||||
|
||||
fail() { echo "build-windows: $*" >&2; exit 1; }
|
||||
test -f "$program" || fail "the release program is not at $program: run cargo build --release -p ledger-cli first"
|
||||
for f in LICENSE-MIT LICENSE-APACHE THIRD-PARTY-NOTICES.txt deploy/packaging/icons/wanderbooks.ico deploy/packaging/windows/wanderbooks.nsi; do
|
||||
test -f "$f" || fail "$f is missing from the repository"
|
||||
done
|
||||
|
||||
makensis=${WB_MAKENSIS:-}
|
||||
if [ -z "$makensis" ]; then
|
||||
if command -v makensis >/dev/null 2>&1; then
|
||||
makensis=makensis
|
||||
elif [ -x "/c/Program Files (x86)/NSIS/makensis.exe" ]; then
|
||||
makensis="/c/Program Files (x86)/NSIS/makensis.exe"
|
||||
else
|
||||
fail "makensis (NSIS) is not installed: choco install nsis, or apt install nsis"
|
||||
fi
|
||||
fi
|
||||
|
||||
# NSIS is a Windows program; Git Bash must neither rewrite its options
|
||||
# (-D...) nor hand it a Unix path, so paths are made native here.
|
||||
export MSYS2_ARG_CONV_EXCL='*'
|
||||
native() { if command -v cygpath >/dev/null 2>&1; then cygpath -w "$1"; else printf '%s\n' "$1"; fi; }
|
||||
|
||||
rm -rf "${out:?}"
|
||||
mkdir -p "$out"
|
||||
"$makensis" -V2 \
|
||||
"-DVERSION=$version" \
|
||||
"-DPROGRAM=$(native "$program")" \
|
||||
"-DICON=$(native deploy/packaging/icons/wanderbooks.ico)" \
|
||||
"-DLICENSES=$(native "$root")" \
|
||||
"-DOUTFILE=$(native "$out/$installer")" \
|
||||
"$(native deploy/packaging/windows/wanderbooks.nsi)"
|
||||
test -s "$out/$installer" || fail "makensis finished but $out/$installer is missing or empty"
|
||||
ls -l "$out"
|
||||
@@ -0,0 +1,36 @@
|
||||
# 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
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
; The Wanderbooks installer for Windows (plan P15 unit C1; WB-pkg-1, WB-pkg-2,
|
||||
; WB-pkg-7). Built by deploy/packaging/windows/build-windows.sh with NSIS
|
||||
; (https://nsis.sourceforge.io, free software, zlib licence).
|
||||
;
|
||||
; makensis -DVERSION=0.1.0 -DPROGRAM=...\wanderbooks.exe -DICON=...\wanderbooks.ico ^
|
||||
; -DLICENSES=<folder> -DOUTFILE=...\Wanderbooks-0.1.0-windows-x64-setup.exe wanderbooks.nsi
|
||||
;
|
||||
; What it does, and the rules it keeps:
|
||||
; * Per user: RequestExecutionLevel user, so double-clicking it shows no
|
||||
; administrator prompt. Everything goes under the person's own profile
|
||||
; and HKEY_CURRENT_USER.
|
||||
; * One program file, wanderbooks.exe. It is the window, the books
|
||||
; server's child and the assistants' bridge; an assistant is registered
|
||||
; with this installed path, which an update keeps (the same folder, the
|
||||
; same file name, replaced in place).
|
||||
; * A Start Menu entry named Wanderbooks, with the icon, and an entry in
|
||||
; Settings > Apps (the uninstaller).
|
||||
; * The uninstaller removes the files this installer put in the install
|
||||
; folder, the Start Menu entry and its two registry keys. It NEVER
|
||||
; removes the person's books, keys, backups or settings: they live in
|
||||
; the data folder (%LOCALAPPDATA%\wanderbooks), which this script
|
||||
; names nowhere, and no command below deletes a folder's contents or
|
||||
; uses a wildcard (a test, crates/ledger-cli/tests/packaging.rs, reads
|
||||
; this file and fails if one appears).
|
||||
; * It asks the person to quit Wanderbooks fully before it replaces or
|
||||
; removes the program (a running program cannot be replaced).
|
||||
; * Unsigned until the owner has a code-signing certificate: Windows
|
||||
; SmartScreen says so on the first run (docs/install.md).
|
||||
|
||||
Unicode true
|
||||
SetCompressor /SOLID lzma
|
||||
!include "MUI2.nsh"
|
||||
!include "LogicLib.nsh"
|
||||
|
||||
!ifndef VERSION
|
||||
!error "pass -DVERSION=x.y.z (deploy/packaging/version.sh)"
|
||||
!endif
|
||||
!ifndef PROGRAM
|
||||
!error "pass -DPROGRAM=<path to wanderbooks.exe>"
|
||||
!endif
|
||||
!ifndef ICON
|
||||
!error "pass -DICON=<path to wanderbooks.ico>"
|
||||
!endif
|
||||
!ifndef LICENSES
|
||||
!error "pass -DLICENSES=<folder with LICENSE-MIT, LICENSE-APACHE and THIRD-PARTY-NOTICES.txt>"
|
||||
!endif
|
||||
!ifndef OUTFILE
|
||||
!error "pass -DOUTFILE=<the installer to write>"
|
||||
!endif
|
||||
|
||||
!define NAME "Wanderbooks"
|
||||
!define PUBLISHER "Wanderbooks"
|
||||
!define UNINSTALL_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\Wanderbooks"
|
||||
!define APP_KEY "Software\Wanderbooks"
|
||||
|
||||
Name "${NAME}"
|
||||
OutFile "${OUTFILE}"
|
||||
RequestExecutionLevel user
|
||||
InstallDir "$LOCALAPPDATA\Programs\Wanderbooks"
|
||||
InstallDirRegKey HKCU "${APP_KEY}" "InstallDir"
|
||||
BrandingText "${NAME} ${VERSION}"
|
||||
ShowInstDetails nevershow
|
||||
ShowUninstDetails nevershow
|
||||
|
||||
VIProductVersion "${VERSION}.0"
|
||||
VIAddVersionKey "ProductName" "${NAME}"
|
||||
VIAddVersionKey "FileDescription" "${NAME} installer"
|
||||
VIAddVersionKey "FileVersion" "${VERSION}"
|
||||
VIAddVersionKey "ProductVersion" "${VERSION}"
|
||||
VIAddVersionKey "LegalCopyright" "MIT OR Apache-2.0"
|
||||
|
||||
!define MUI_ICON "${ICON}"
|
||||
!define MUI_UNICON "${ICON}"
|
||||
!define MUI_ABORTWARNING
|
||||
!define MUI_FINISHPAGE_RUN "$INSTDIR\wanderbooks.exe"
|
||||
!define MUI_FINISHPAGE_RUN_TEXT "Start ${NAME}"
|
||||
|
||||
!insertmacro MUI_PAGE_INSTFILES
|
||||
!insertmacro MUI_PAGE_FINISH
|
||||
!insertmacro MUI_UNPAGE_CONFIRM
|
||||
!insertmacro MUI_UNPAGE_INSTFILES
|
||||
!insertmacro MUI_LANGUAGE "English"
|
||||
|
||||
; A program that is running cannot be replaced or removed. Try to open the
|
||||
; installed file for writing; if it is in use, ask the person to quit
|
||||
; Wanderbooks (its window, which closes the books and the server) and retry.
|
||||
!macro WaitUntilNotRunning
|
||||
${Do}
|
||||
ClearErrors
|
||||
${If} ${FileExists} "$INSTDIR\wanderbooks.exe"
|
||||
FileOpen $0 "$INSTDIR\wanderbooks.exe" a
|
||||
${IfNot} ${Errors}
|
||||
FileClose $0
|
||||
${Break}
|
||||
${EndIf}
|
||||
MessageBox MB_RETRYCANCEL|MB_ICONEXCLAMATION "${NAME} is open. Quit it fully (close its window), then choose Retry." IDRETRY +2
|
||||
Abort "${NAME} is still open."
|
||||
${Else}
|
||||
${Break}
|
||||
${EndIf}
|
||||
${Loop}
|
||||
!macroend
|
||||
|
||||
Section "Install"
|
||||
SetOutPath "$INSTDIR"
|
||||
!insertmacro WaitUntilNotRunning
|
||||
File "/oname=wanderbooks.exe" "${PROGRAM}"
|
||||
File "/oname=wanderbooks.ico" "${ICON}"
|
||||
File "/oname=LICENSE-MIT" "${LICENSES}\LICENSE-MIT"
|
||||
File "/oname=LICENSE-APACHE" "${LICENSES}\LICENSE-APACHE"
|
||||
File "/oname=THIRD-PARTY-NOTICES.txt" "${LICENSES}\THIRD-PARTY-NOTICES.txt"
|
||||
WriteUninstaller "$INSTDIR\Uninstall Wanderbooks.exe"
|
||||
|
||||
CreateShortCut "$SMPROGRAMS\${NAME}.lnk" "$INSTDIR\wanderbooks.exe" "" "$INSTDIR\wanderbooks.ico" 0
|
||||
|
||||
WriteRegStr HKCU "${APP_KEY}" "InstallDir" "$INSTDIR"
|
||||
WriteRegStr HKCU "${UNINSTALL_KEY}" "DisplayName" "${NAME}"
|
||||
WriteRegStr HKCU "${UNINSTALL_KEY}" "DisplayVersion" "${VERSION}"
|
||||
WriteRegStr HKCU "${UNINSTALL_KEY}" "Publisher" "${PUBLISHER}"
|
||||
WriteRegStr HKCU "${UNINSTALL_KEY}" "DisplayIcon" "$INSTDIR\wanderbooks.ico"
|
||||
WriteRegStr HKCU "${UNINSTALL_KEY}" "InstallLocation" "$INSTDIR"
|
||||
WriteRegStr HKCU "${UNINSTALL_KEY}" "URLInfoAbout" "https://wanderbooks.ai"
|
||||
WriteRegStr HKCU "${UNINSTALL_KEY}" "UninstallString" '"$INSTDIR\Uninstall Wanderbooks.exe"'
|
||||
WriteRegStr HKCU "${UNINSTALL_KEY}" "QuietUninstallString" '"$INSTDIR\Uninstall Wanderbooks.exe" /S'
|
||||
WriteRegDWORD HKCU "${UNINSTALL_KEY}" "NoModify" 1
|
||||
WriteRegDWORD HKCU "${UNINSTALL_KEY}" "NoRepair" 1
|
||||
SectionEnd
|
||||
|
||||
Section "Uninstall"
|
||||
!insertmacro WaitUntilNotRunning
|
||||
Delete "$INSTDIR\wanderbooks.exe"
|
||||
Delete "$INSTDIR\wanderbooks.ico"
|
||||
Delete "$INSTDIR\LICENSE-MIT"
|
||||
Delete "$INSTDIR\LICENSE-APACHE"
|
||||
Delete "$INSTDIR\THIRD-PARTY-NOTICES.txt"
|
||||
Delete "$INSTDIR\Uninstall Wanderbooks.exe"
|
||||
; Only if empty: a folder the person put something in stays.
|
||||
RMDir "$INSTDIR"
|
||||
Delete "$SMPROGRAMS\${NAME}.lnk"
|
||||
DeleteRegKey HKCU "${UNINSTALL_KEY}"
|
||||
DeleteRegKey HKCU "${APP_KEY}"
|
||||
; The person's books, keys, backups and settings are not here: they are
|
||||
; in the data folder, which an uninstall leaves exactly as it is.
|
||||
SectionEnd
|
||||
Reference in new issue
Block a user