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:
swaitsandClaude Fable 5.2 committed 2026-11-21 15:41:22 -07:00
1 parent 90f663ed54
commit 8e3db472fa
19 files changed
+1110 -86

No files matched your search

+48
View File
@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<!-- The Info.plist of Wanderbooks.app (plan P15 unit C1; WB-pkg-1, WB-pkg-6).
build-macos.sh replaces @VERSION@ with the program's version
(deploy/packaging/version.sh) and @BUNDLE_ID@ with the bundle
identifier. -->
<plist version="1.0">
<dict>
<key>CFBundleName</key>
<string>Wanderbooks</string>
<key>CFBundleDisplayName</key>
<string>Wanderbooks</string>
<key>CFBundleIdentifier</key>
<string>@BUNDLE_ID@</string>
<key>CFBundleExecutable</key>
<string>wanderbooks</string>
<key>CFBundleIconFile</key>
<string>wanderbooks</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleShortVersionString</key>
<string>@VERSION@</string>
<key>CFBundleVersion</key>
<string>@VERSION@</string>
<key>LSMinimumSystemVersion</key>
<string>11.0</string>
<key>LSApplicationCategoryType</key>
<string>public.app-category.finance</string>
<key>NSHighResolutionCapable</key>
<true/>
<!-- One Wanderbooks at a time: it holds the books open. -->
<key>LSMultipleInstancesProhibited</key>
<true/>
<!-- The discrete GPU is not woken for a ledger. -->
<key>NSSupportsAutomaticGraphicsSwitching</key>
<true/>
<key>NSHumanReadableCopyright</key>
<string>MIT OR Apache-2.0</string>
<!-- macOS asks the person once before an app reads their Documents folder,
and shows this sentence. Wanderbooks makes a folder there for each
company's assistant (Documents/Wanderbooks) and for the Claude
extension; it never reads anything else of theirs there. -->
<key>NSDocumentsFolderUsageDescription</key>
<string>Wanderbooks keeps a small folder in Documents for each company, where an assistant such as Claude Code works, and the extension file for the Claude app.</string>
</dict>
</plist>
+143
View File
@@ -0,0 +1,143 @@
#!/usr/bin/env bash
# The macOS app and its .dmg (plan P15 unit C1; WB-pkg-1). Run on a Mac from
# the repository root (CI: the `macos` job of .github/workflows/release.yml):
#
# build-macos.sh [VERSION]
#
# Puts Wanderbooks-VERSION-macos-universal.dmg into target/packages/VERSION/.
#
# One UNIVERSAL program (Apple silicon and Intel in one file, `lipo`ed from
# the two release builds): one download for everyone. The program is
# WB_PROGRAM if set (any program file), else the lipo of
# target/aarch64-apple-darwin/release/wanderbooks and
# target/x86_64-apple-darwin/release/wanderbooks.
#
# Signing and notarization need the owner's Apple Developer identity and run
# only when it is given, in the environment (the release workflow sets these
# from secrets; nothing here is a secret and nothing prints one):
# WB_SIGN_IDENTITY the signing identity, e.g.
# "Developer ID Application: Name (TEAMID)", already in
# the keychain (import-certificate.sh does that in CI)
# WB_NOTARY_APPLE_ID, WB_NOTARY_TEAM_ID, WB_NOTARY_PASSWORD
# for `xcrun notarytool` (an app-specific password)
# Without WB_SIGN_IDENTITY the app is signed ad hoc ("-"): Apple silicon
# will not start an unsigned program at all, so it runs, but Gatekeeper
# still refuses a download of it (right-click > Open once, docs/install.md).
# Without the notarization variables the .dmg is signed but not notarized.
#
# WB_NO_ICNS=1 skips the icon (no `iconutil` off a Mac): the structure
# tests build the bundle that way on Linux; a release never does.
# WB_BUNDLE_ONLY=1 stops after the .app (the structure tests).
set -euo pipefail
here=$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd)
root=$(CDPATH='' cd -- "$here/../../.." && pwd)
cd "$root"
fail() { echo "build-macos: $*" >&2; exit 1; }
notice() { echo "::notice title=$1::$2"; echo "build-macos: $2"; }
own=$(sh deploy/packaging/version.sh)
version=${1:-$own}
case "$version" in
[0-9]*.[0-9]*.[0-9]*) ;;
*) fail "'$version' is not an x.y.z version" ;;
esac
bundle_id=${WB_BUNDLE_ID:-ai.wanderbooks.app}
out="target/packages/$version"
stage="target/packages/.stage-macos-$version"
app="$stage/Wanderbooks.app"
dmg="Wanderbooks-$version-macos-universal.dmg"
for f in LICENSE-MIT LICENSE-APACHE THIRD-PARTY-NOTICES.txt deploy/packaging/icons/512x512.png \
deploy/packaging/macos/Info.plist.in deploy/packaging/macos/entitlements.plist; do
test -f "$f" || fail "$f is missing from the repository"
done
# 1. The program: universal, or the one given.
rm -rf "${stage:?}"
mkdir -p "$stage" "$out"
program=${WB_PROGRAM:-}
if [ -z "$program" ]; then
arm=target/aarch64-apple-darwin/release/wanderbooks
intel=target/x86_64-apple-darwin/release/wanderbooks
test -f "$arm" || fail "$arm is missing: cargo build --release -p ledger-cli --target aarch64-apple-darwin"
test -f "$intel" || fail "$intel is missing: cargo build --release -p ledger-cli --target x86_64-apple-darwin"
lipo -create -output "$stage/wanderbooks-universal" "$arm" "$intel"
archs=$(lipo -archs "$stage/wanderbooks-universal")
case "$archs" in
*arm64*x86_64*|*x86_64*arm64*) ;;
*) fail "the universal program holds '$archs', not both arm64 and x86_64" ;;
esac
program="$stage/wanderbooks-universal"
fi
test -f "$program" || fail "the program is not at $program"
# 2. The bundle. The program's path inside it,
# /Applications/Wanderbooks.app/Contents/MacOS/wanderbooks, is the one an
# assistant is registered with: it does not change when the app is
# replaced by a newer one dragged over it.
mkdir -p "$app/Contents/MacOS" "$app/Contents/Resources"
cp "$program" "$app/Contents/MacOS/wanderbooks"
chmod 755 "$app/Contents/MacOS/wanderbooks"
sed -e "s/@VERSION@/$version/g" -e "s/@BUNDLE_ID@/$bundle_id/g" \
deploy/packaging/macos/Info.plist.in > "$app/Contents/Info.plist"
printf 'APPL????' > "$app/Contents/PkgInfo"
cp LICENSE-MIT LICENSE-APACHE THIRD-PARTY-NOTICES.txt "$app/Contents/Resources/"
if [ "${WB_NO_ICNS:-}" = 1 ]; then
notice "no icon" "WB_NO_ICNS=1: the bundle has no icon (a test build, never a release)"
else
command -v iconutil >/dev/null || fail "iconutil is not here: build the icon on a Mac, or set WB_NO_ICNS=1 for a test bundle"
iconset="$stage/wanderbooks.iconset"
mkdir -p "$iconset"
src=deploy/packaging/icons/512x512.png
for size in 16 32 128 256 512; do
sips -z "$size" "$size" "$src" --out "$iconset/icon_${size}x${size}.png" >/dev/null
done
for size in 16 32 128 256; do
double=$((size * 2))
sips -z "$double" "$double" "$src" --out "$iconset/icon_${size}x${size}@2x.png" >/dev/null
done
iconutil -c icns "$iconset" -o "$app/Contents/Resources/wanderbooks.icns"
fi
if [ "${WB_BUNDLE_ONLY:-}" = 1 ]; then
echo "build-macos: bundle at $app (WB_BUNDLE_ONLY=1)"
exit 0
fi
# 3. Sign: hardened runtime, the entitlements, a secure timestamp.
identity=${WB_SIGN_IDENTITY:-}
if [ -z "$identity" ]; then
notice "macOS signing skipped" "no WB_SIGN_IDENTITY: the app is signed ad hoc, so it runs here, but macOS Gatekeeper will refuse a download of it until it is signed with a Developer ID and notarized"
identity=-
timestamp=--timestamp=none
else
timestamp=--timestamp
fi
codesign --force --options runtime "$timestamp" \
--entitlements deploy/packaging/macos/entitlements.plist \
--sign "$identity" "$app"
codesign --verify --deep --strict --verbose=2 "$app"
# 4. The .dmg: the app and a shortcut to Applications (drag to install).
mkdir -p "$stage/dmg"
cp -R "$app" "$stage/dmg/"
ln -s /Applications "$stage/dmg/Applications"
rm -f "${out:?}/${dmg:?}"
hdiutil create -volname "Wanderbooks" -srcfolder "$stage/dmg" -ov -format UDZO "$out/$dmg"
if [ "$identity" != "-" ]; then
codesign --force --timestamp --sign "$identity" "$out/$dmg"
fi
# 5. Notarize and staple (the Developer ID signature and Apple's ticket).
if [ "$identity" != "-" ] && [ -n "${WB_NOTARY_APPLE_ID:-}" ] && [ -n "${WB_NOTARY_TEAM_ID:-}" ] && [ -n "${WB_NOTARY_PASSWORD:-}" ]; then
xcrun notarytool submit "$out/$dmg" \
--apple-id "$WB_NOTARY_APPLE_ID" --team-id "$WB_NOTARY_TEAM_ID" \
--password "$WB_NOTARY_PASSWORD" --wait
xcrun stapler staple "$out/$dmg"
xcrun stapler validate "$out/$dmg"
spctl --assess --type open --context context:primary-signature --verbose=2 "$out/$dmg"
else
notice "macOS notarization skipped" "no signing identity or no WB_NOTARY_APPLE_ID / WB_NOTARY_TEAM_ID / WB_NOTARY_PASSWORD: the .dmg is not notarized, and macOS will warn on the first open"
fi
rm -rf "${stage:?}"
ls -l "$out"
+29
View File
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<!-- The hardened-runtime entitlements of Wanderbooks.app (plan P15 unit C1).
The app is signed with the hardened runtime (codesign --options
runtime), which Apple's notarization requires. It is NOT sandboxed
(the App Sandbox would forbid what the product is: it starts a copy of
itself as the books server, runs the system's git for backups, and
reads and writes the person's data folder and the folders they pick
for backups). Outside the sandbox, none of that needs an entitlement:
* starting itself as a child process and git as another: none;
* outgoing network connections (the relay, the update look, a git
remote): none (com.apple.security.network.client is a SANDBOX
entitlement);
* reading and writing its data folder, Application Support/wanderbooks:
none (the Documents folder is a privacy prompt, answered by
NSDocumentsFolderUsageDescription in Info.plist, not an entitlement);
* the window's graphics (Metal through wgpu): none;
* no JIT, no unsigned executable memory, no DYLD variables, no
library validation exception: the program loads only system
frameworks and its own code.
So the set below is empty on purpose. If the first notarized build
fails to start, the log names the entitlement it needs; add exactly
that one here, with the reason, and not a broader exception. -->
<plist version="1.0">
<dict/>
</plist>
+24
View File
@@ -0,0 +1,24 @@
#!/usr/bin/env bash
# Put the owner's Developer ID certificate into a temporary keychain on a CI
# macOS runner, so `codesign` can use it (plan P15 unit C1). Run by the
# release workflow only when the secrets exist. Takes the certificate (a .p12,
# base64) and its password from the environment, never the command line:
# APPLE_CERTIFICATE_P12_BASE64, APPLE_CERTIFICATE_PASSWORD
# Prints no secret. The keychain lives in RUNNER_TEMP and goes with the
# runner.
set -euo pipefail
: "${APPLE_CERTIFICATE_P12_BASE64:?the certificate secret is empty}"
: "${APPLE_CERTIFICATE_PASSWORD:?the certificate password secret is empty}"
: "${RUNNER_TEMP:?not on a GitHub runner}"
keychain="$RUNNER_TEMP/wanderbooks-signing.keychain-db"
password=$(uuidgen)
p12="$RUNNER_TEMP/wanderbooks-signing.p12"
printf '%s' "$APPLE_CERTIFICATE_P12_BASE64" | base64 --decode > "$p12"
security create-keychain -p "$password" "$keychain"
security set-keychain-settings -lut 21600 "$keychain"
security unlock-keychain -p "$password" "$keychain"
security import "$p12" -k "$keychain" -P "$APPLE_CERTIFICATE_PASSWORD" -T /usr/bin/codesign
security set-key-partition-list -S apple-tool:,apple: -s -k "$password" "$keychain" >/dev/null
security list-keychains -d user -s "$keychain" login.keychain
rm -f "$p12"
security find-identity -v -p codesigning "$keychain"