diff --git a/crates/ledger-cli/Cargo.toml b/crates/ledger-cli/Cargo.toml index 7d8e19cd..ff19b180 100644 --- a/crates/ledger-cli/Cargo.toml +++ b/crates/ledger-cli/Cargo.toml @@ -82,5 +82,8 @@ assets = [ { source = "target/release/wanderbooks", dest = "/usr/bin/wanderbooks", mode = "0755" }, { source = "deploy/packaging/install-method-rpm", dest = "/usr/share/wanderbooks/install-method", mode = "0644" }, { source = "deploy/packaging/wanderbooks-static.desktop", dest = "/usr/share/applications/wanderbooks.desktop", mode = "0644" }, + { source = "deploy/packaging/icons/512x512.png", dest = "/usr/share/icons/hicolor/512x512/apps/wanderbooks.png", mode = "0644" }, + { source = "LICENSE-MIT", dest = "/usr/share/doc/wanderbooks/LICENSE-MIT", mode = "0644" }, + { source = "LICENSE-APACHE", dest = "/usr/share/doc/wanderbooks/LICENSE-APACHE", mode = "0644" }, { source = "THIRD-PARTY-NOTICES.txt", dest = "/usr/share/doc/wanderbooks/THIRD-PARTY-NOTICES.txt", mode = "0644" }, ] diff --git a/crates/ledger-cli/tests/packaging.rs b/crates/ledger-cli/tests/packaging.rs new file mode 100644 index 00000000..ad61926e --- /dev/null +++ b/crates/ledger-cli/tests/packaging.rs @@ -0,0 +1,570 @@ +//! The packages (plan P15 unit C1; WB-pkg-1 to WB-pkg-7): what can be checked +//! on Linux about the Windows installer, the macOS app, the Linux entries and +//! the one source of the version. For Windows and macOS the release workflow +//! is the real test (each packaging step fails loudly); these tests keep the +//! files it builds from true to the rules. +//! +//! ```text +//! GOAL: an installed Wanderbooks is one executable at a stable path, named +//! Wanderbooks everywhere a person sees it, with the licences beside +//! it; installing a newer one over it, or uninstalling it, never +//! touches the person's books. +//! SOURCE: WB-pkg-1 (installs like a normal program), WB-pkg-2 (one +//! executable, a stable bridge path), WB-pkg-6 (one version, one +//! name), WB-pkg-7 (the release carries the licences); D-77. +//! INVARIANTS: +//! 1. The version is written once (ledger-cli's Cargo.toml); the packaging +//! scripts read it through deploy/packaging/version.sh. +//! 2. The Windows installer is per user (no administrator), installs one +//! program, and its uninstaller names nothing but what the installer +//! put in its own folder: no recursive removal, no wildcard, no data +//! folder. +//! 3. The macOS bundle holds one program at Contents/MacOS/wanderbooks, an +//! Info.plist whose identifier, name, version and executable agree with +//! the scripts, and the licences. +//! 4. The Linux desktop entries launch plain `wanderbooks` (an AppImage's +//! launcher appends what it is given) with the icon, the name, and the +//! window's app id. +//! 5. Every package carries LICENSE-MIT, LICENSE-APACHE and +//! THIRD-PARTY-NOTICES.txt. +//! SCENARIOS: +//! 1. The bundle script run on Linux with a stand-in program makes a +//! bundle whose plist and files match the rules above. +//! ``` + +use std::path::{Path, PathBuf}; +use std::process::Command; + +fn root() -> PathBuf { + Path::new(env!("CARGO_MANIFEST_DIR")).join("../..") +} + +fn read(path: &str) -> String { + std::fs::read_to_string(root().join(path)).unwrap_or_else(|e| panic!("{path}: {e}")) +} + +/// The lines of `text` that are not comments (`;` for NSIS, `#` for shell +/// and TOML). +fn code(text: &str) -> Vec<&str> { + text.lines() + .map(str::trim) + .filter(|l| !l.is_empty() && !l.starts_with(';') && !l.starts_with('#')) + .collect() +} + +const LICENCE_FILES: [&str; 3] = ["LICENSE-MIT", "LICENSE-APACHE", "THIRD-PARTY-NOTICES.txt"]; + +// ---- the version, written once --------------------------------------------------- + +#[cfg(unix)] +#[test] +fn the_version_is_written_once_and_every_script_reads_it_from_there() { + let out = Command::new("sh") + .arg(root().join("deploy/packaging/version.sh")) + .output() + .unwrap(); + assert!(out.status.success(), "{out:?}"); + let said = String::from_utf8(out.stdout).unwrap(); + assert_eq!(said.trim(), env!("CARGO_PKG_VERSION")); + + // The Linux packager's own file carries a version the build script + // overwrites; it must not drift from the source. + let packager = read("deploy/packaging/packager.toml"); + let line = code(&packager) + .into_iter() + .find(|l| l.starts_with("version = ")) + .unwrap(); + assert_eq!(line, format!("version = \"{}\"", env!("CARGO_PKG_VERSION"))); + + // No packaging script or workflow assigns a literal version. + for file in [ + "deploy/packaging/windows/build-windows.sh", + "deploy/packaging/macos/build-macos.sh", + ".github/workflows/release.yml", + ] { + for line in code(&read(file)) { + let assigns = line.starts_with("version=") || line.starts_with("version:"); + let literal = line.split(['=', ':']).nth(1).is_some_and(|v| { + v.trim() + .trim_matches('"') + .chars() + .next() + .is_some_and(|c| c.is_ascii_digit()) + }); + assert!(!(assigns && literal), "{file}: a literal version: {line}"); + } + } + for file in [ + "deploy/packaging/windows/build-windows.sh", + "deploy/packaging/macos/build-macos.sh", + "deploy/packaging/build-linux.sh", + ] { + let text = read(file); + assert!( + text.contains("version.sh") || text.contains("ledger-cli/Cargo.toml"), + "{file} does not read the version from its one source" + ); + } +} + +#[cfg(unix)] +#[test] +fn a_version_that_is_not_three_numbers_is_refused() { + let dir = tempfile::tempdir().unwrap(); + std::fs::create_dir_all(dir.path().join("deploy/packaging")).unwrap(); + std::fs::create_dir_all(dir.path().join("crates/ledger-cli")).unwrap(); + std::fs::copy( + root().join("deploy/packaging/version.sh"), + dir.path().join("deploy/packaging/version.sh"), + ) + .unwrap(); + for (toml, ok) in [ + ("version = \"0.2.0\"\n", true), + ("version = \"0.2.0-rc1\"\n", false), + ("version = \"two\"\n", false), + ("", false), + ] { + std::fs::write(dir.path().join("crates/ledger-cli/Cargo.toml"), toml).unwrap(); + let out = Command::new("sh") + .arg(dir.path().join("deploy/packaging/version.sh")) + .output() + .unwrap(); + assert_eq!(out.status.success(), ok, "{toml:?}: {out:?}"); + } +} + +// ---- Windows -------------------------------------------------------------------- + +#[test] +fn the_windows_installer_is_per_user_and_installs_one_program() { + let nsi = read("deploy/packaging/windows/wanderbooks.nsi"); + let lines = code(&nsi); + let has = |needle: &str| lines.iter().any(|l| l.contains(needle)); + // No administrator prompt; everything in the person's own profile. + assert!(has("RequestExecutionLevel user")); + assert!(has(r#"InstallDir "$LOCALAPPDATA\Programs\Wanderbooks""#)); + assert!( + !lines.iter().any(|l| l.contains("HKLM")), + "per-machine registry" + ); + assert!(!has("SetShellVarContext all"), "all users' Start Menu"); + // A Start Menu entry named Wanderbooks, with the icon. + assert!(has( + r#"CreateShortCut "$SMPROGRAMS\${NAME}.lnk" "$INSTDIR\wanderbooks.exe""# + )); + assert!(has(r#"!define NAME "Wanderbooks""#)); + assert!(has("wanderbooks.ico")); + // An uninstaller, listed in Settings > Apps, whose name is the product's. + assert!(has("WriteUninstaller")); + assert!(has(r#""DisplayName" "${NAME}""#)); + assert!(has("UninstallString")); + // One program: the only .exe installed besides the uninstaller. + let programs: Vec<&&str> = lines + .iter() + .filter(|l| l.starts_with("File ") && l.contains(".exe")) + .collect(); + assert_eq!(programs.len(), 1, "{programs:?}"); + assert!(programs[0].contains("/oname=wanderbooks.exe")); + // The licences travel with it. + for file in LICENCE_FILES { + assert!(has(&format!("/oname={file}")), "{file} is not installed"); + } +} + +/// WB-pkg-1: the uninstaller removes what the installer put in its own +/// folder and nothing else; the books are in the data folder, which it never +/// names. +#[test] +fn the_uninstaller_never_removes_the_books() { + let nsi = read("deploy/packaging/windows/wanderbooks.nsi"); + let lines = code(&nsi); + let start = lines + .iter() + .position(|l| l.starts_with(r#"Section "Uninstall""#)) + .expect("an uninstall section"); + let section = &lines[start..]; + let mut removals = 0; + for line in section { + let word = line.split_whitespace().next().unwrap_or(""); + if matches!(word, "Delete" | "RMDir" | "DeleteRegKey" | "DeleteRegValue") { + removals += 1; + assert!(!line.contains("/r"), "a recursive removal: {line}"); + assert!( + !line.contains('*') && !line.contains('?'), + "a wildcard: {line}" + ); + let ok = line.contains("$INSTDIR") + || line.contains("$SMPROGRAMS") + || line.contains("${UNINSTALL_KEY}") + || line.contains("${APP_KEY}"); + assert!( + ok, + "removes something that is not the program's own: {line}" + ); + } + } + assert!(removals >= 6, "the uninstaller removes the installed files"); + // The data folder, the roaming settings and the keys are named nowhere + // in the script's code (the comments say where the books are). + for line in &lines { + for data in [ + "$LOCALAPPDATA\\wanderbooks", + "$APPDATA", + "\\link", + "legacy", + "books\\", + ] { + assert!(!line.contains(data), "{data} named: {line}"); + } + } + // Only the registry keys of its own. + let keys: Vec<&&str> = lines + .iter() + .filter(|l| l.starts_with("!define") && l.contains("_KEY")) + .collect(); + assert_eq!(keys.len(), 2, "{keys:?}"); + assert!(keys[0].contains(r"Software\Microsoft\Windows\CurrentVersion\Uninstall\Wanderbooks")); + assert!(keys[1].contains(r"Software\Wanderbooks")); +} + +/// If NSIS is installed here, the script compiles with stand-in files +/// (the release workflow compiles it for real on Windows). +#[test] +fn the_installer_script_compiles_when_nsis_is_here() { + let Some(makensis) = std::env::var_os("PATH").and_then(|p| { + std::env::split_paths(&p) + .map(|d| d.join("makensis")) + .find(|f| f.is_file()) + }) else { + eprintln!( + "makensis is not installed here: the Windows job of the release workflow compiles the installer" + ); + return; + }; + let dir = tempfile::tempdir().unwrap(); + let p = dir.path(); + std::fs::write(p.join("wanderbooks.exe"), b"MZ").unwrap(); + for f in LICENCE_FILES { + std::fs::write(p.join(f), b"x").unwrap(); + } + std::fs::copy( + root().join("deploy/packaging/icons/wanderbooks.ico"), + p.join("wanderbooks.ico"), + ) + .unwrap(); + let out = Command::new(makensis) + .arg("-V2") + .arg(format!("-DVERSION={}", env!("CARGO_PKG_VERSION"))) + .arg(format!("-DPROGRAM={}", p.join("wanderbooks.exe").display())) + .arg(format!("-DICON={}", p.join("wanderbooks.ico").display())) + .arg(format!("-DLICENSES={}", p.display())) + .arg(format!("-DOUTFILE={}", p.join("setup.exe").display())) + .arg(root().join("deploy/packaging/windows/wanderbooks.nsi")) + .output() + .unwrap(); + assert!( + out.status.success(), + "{}", + String::from_utf8_lossy(&out.stdout) + ); + assert!(p.join("setup.exe").metadata().unwrap().len() > 0); +} + +/// WB-pkg-2: on Windows the one executable is built for the GUI subsystem +/// (no console window for the app), and gives a terminal its words back. +#[test] +fn the_windows_program_opens_no_console_window_and_still_speaks_in_a_terminal() { + let main = read("crates/ledger-cli/src/main.rs"); + assert!( + main.contains( + r#"#![cfg_attr(all(windows, feature = "gui"), windows_subsystem = "windows")]"# + ) + ); + assert!(main.contains("console::attach_parent_console()")); + let console = read("crates/ledger-cli/src/console.rs"); + assert!(console.contains("AttachConsole(ATTACH_PARENT_PROCESS)")); + // The server child the app starts has no console window of its own. + assert!(read("crates/ledger-host/src/app_server.rs").contains("NO_WINDOW")); +} + +// ---- macOS ---------------------------------------------------------------------- + +/// The ``/value pairs of a plist's top-level dict, as text. Good enough +/// for the plain plists here (no nesting). +fn plist(text: &str) -> Vec<(String, String)> { + let mut pairs = Vec::new(); + let mut key: Option = None; + for line in text.lines().map(str::trim) { + if let Some(k) = line + .strip_prefix("") + .and_then(|l| l.strip_suffix("")) + { + assert!(key.is_none(), "a key with no value: {k}"); + key = Some(k.to_string()); + } else if let Some(k) = key.take_if(|_| line.starts_with('<') && !line.starts_with(" - - - LSMultipleInstancesProhibited - - NSSupportsAutomaticGraphicsSwitching - - - diff --git a/deploy/packaging/build-linux.sh b/deploy/packaging/build-linux.sh index ea84b556..88bad803 100755 --- a/deploy/packaging/build-linux.sh +++ b/deploy/packaging/build-linux.sh @@ -37,6 +37,7 @@ sed "s/^version = \".*\"/version = \"$version\"/ s#\"target/release\"#\"$PWD/$stage\"# s#\"deploy/packaging/#\"$PWD/deploy/packaging/# s#\"LICENSE-MIT\"#\"$PWD/LICENSE-MIT\"# + s#^\"LICENSE-APACHE\"#\"$PWD/LICENSE-APACHE\"# s#^\"THIRD-PARTY-NOTICES.txt\"#\"$PWD/THIRD-PARTY-NOTICES.txt\"#" \ deploy/packaging/packager.toml >"$config" # The AppImage tools are themselves AppImages; run them without FUSE. @@ -46,6 +47,9 @@ assets='assets = [ { source = "'$PWD/$stage'/wanderbooks", dest = "/usr/bin/wanderbooks", mode = "0755" }, { source = "deploy/packaging/install-method-rpm", dest = "/usr/share/wanderbooks/install-method", mode = "0644" }, { source = "deploy/packaging/wanderbooks-static.desktop", dest = "/usr/share/applications/wanderbooks.desktop", mode = "0644" }, + { source = "deploy/packaging/icons/512x512.png", dest = "/usr/share/icons/hicolor/512x512/apps/wanderbooks.png", mode = "0644" }, + { source = "LICENSE-MIT", dest = "/usr/share/doc/wanderbooks/LICENSE-MIT", mode = "0644" }, + { source = "LICENSE-APACHE", dest = "/usr/share/doc/wanderbooks/LICENSE-APACHE", mode = "0644" }, { source = "THIRD-PARTY-NOTICES.txt", dest = "/usr/share/doc/wanderbooks/THIRD-PARTY-NOTICES.txt", mode = "0644" }, ]' cargo generate-rpm -p crates/ledger-cli --set-metadata "version=\"$version\"" --set-metadata "$assets" -o "$out/" diff --git a/deploy/packaging/build-macos.sh b/deploy/packaging/build-macos.sh deleted file mode 100755 index f9e809f3..00000000 --- a/deploy/packaging/build-macos.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env bash -# The macOS bundle (P11a step 6), UNSIGNED, from the release program -# already built at target/release/wanderbooks (`cargo build --release -p -# ledger-cli`). Run on a Mac from the repository root: -# -# build-macos.sh [VERSION] -# -# Puts Wanderbooks_VERSION_.dmg into target/packages/VERSION/. It -# is not signed or notarized (step 5): Gatekeeper refuses it on a Mac -# that downloaded it, and the owner opens it with right-click > Open. -# Portable shell: macOS has BSD sed and no GNU mktemp options. -set -euo pipefail -own=$(sed -n 's/^version = "\(.*\)"/\1/p' crates/ledger-cli/Cargo.toml | head -n1) -version=${1:-$own} -out="target/packages/$version" -program=${WB_PROGRAM:-target/release/wanderbooks} -test -x "$program" || { echo "build the release program first: cargo build --release -p ledger-cli" >&2; exit 1; } -rm -rf "$out"; mkdir -p "$out" -stage="target/packages/.stage-$version" -rm -rf "$stage"; mkdir -p "$stage" -cp "$program" "$stage/wanderbooks" -config="$stage/packager.toml" -# cargo-packager reads paths relative to the config file, which is in the -# stage folder here, so they are made absolute. -sed -e "s/^version = \".*\"/version = \"$version\"/" \ - -e "s#^out-dir = .*#out-dir = \"$PWD/$out\"#" \ - -e "s#\"target/release\"#\"$PWD/$stage\"#" \ - -e "s#\"deploy/packaging/#\"$PWD/deploy/packaging/#" \ - -e "s#\"LICENSE-MIT\"#\"$PWD/LICENSE-MIT\"#" \ - deploy/packaging/packager-macos.toml >"$config" -cargo packager --config "$config" --formats dmg --release -rm -rf "$stage" -ls -l "$out" diff --git a/deploy/packaging/icons/wanderbooks.ico b/deploy/packaging/icons/wanderbooks.ico new file mode 100644 index 00000000..a2c72ed5 Binary files /dev/null and b/deploy/packaging/icons/wanderbooks.ico differ diff --git a/deploy/packaging/macos/Info.plist.in b/deploy/packaging/macos/Info.plist.in new file mode 100644 index 00000000..4f99388c --- /dev/null +++ b/deploy/packaging/macos/Info.plist.in @@ -0,0 +1,48 @@ + + + + + + CFBundleName + Wanderbooks + CFBundleDisplayName + Wanderbooks + CFBundleIdentifier + @BUNDLE_ID@ + CFBundleExecutable + wanderbooks + CFBundleIconFile + wanderbooks + CFBundlePackageType + APPL + CFBundleInfoDictionaryVersion + 6.0 + CFBundleShortVersionString + @VERSION@ + CFBundleVersion + @VERSION@ + LSMinimumSystemVersion + 11.0 + LSApplicationCategoryType + public.app-category.finance + NSHighResolutionCapable + + + LSMultipleInstancesProhibited + + + NSSupportsAutomaticGraphicsSwitching + + NSHumanReadableCopyright + MIT OR Apache-2.0 + + NSDocumentsFolderUsageDescription + 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. + + diff --git a/deploy/packaging/macos/build-macos.sh b/deploy/packaging/macos/build-macos.sh new file mode 100755 index 00000000..fc7e7f0b --- /dev/null +++ b/deploy/packaging/macos/build-macos.sh @@ -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" diff --git a/deploy/packaging/macos/entitlements.plist b/deploy/packaging/macos/entitlements.plist new file mode 100644 index 00000000..30dd36ee --- /dev/null +++ b/deploy/packaging/macos/entitlements.plist @@ -0,0 +1,29 @@ + + + + + + diff --git a/deploy/packaging/macos/import-certificate.sh b/deploy/packaging/macos/import-certificate.sh new file mode 100755 index 00000000..25bcecf0 --- /dev/null +++ b/deploy/packaging/macos/import-certificate.sh @@ -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" diff --git a/deploy/packaging/packager-macos.toml b/deploy/packaging/packager-macos.toml deleted file mode 100644 index 64ef6c00..00000000 --- a/deploy/packaging/packager-macos.toml +++ /dev/null @@ -1,36 +0,0 @@ -# cargo-packager's description of the macOS bundle (P11a step 6; D-24, -# D-25): the .app and its .dmg, UNSIGNED. `deploy/packaging/build-macos.sh` -# runs it on a Mac (CI: the `macos` job of .github/workflows/release.yml). -# Developer ID signing and notarization are step 5 (the owner's Apple -# certificate, Q-4): they add `signing-identity` under [macos] and the -# certificate and notarization credentials as CI secrets. -# Paths are relative to this file's copy that build-macos.sh writes. -name = "wanderbooks" -product-name = "Wanderbooks" -version = "0.1.0" -identifier = "ai.wanderbooks.app" -description = "Double-entry bookkeeping your agent keeps and you can read." -homepage = "https://wanderbooks.ai" -authors = ["Stephen Waits"] -license-file = "LICENSE-MIT" -category = "Finance" -binaries-dir = "target/release" -out-dir = "target/packages" -# A png is made into the .icns (cargo-packager does it); the 512 px -# placeholder is the owner's to replace. -icons = ["deploy/packaging/icons/512x512.png"] -formats = ["dmg"] -binaries = [{ path = "wanderbooks", main = true }] - -[macos] -# The oldest macOS Rust's tier-1 aarch64-apple-darwin and x86-64 targets -# run on; eframe's wgpu/Metal path needs 10.15 at least. -minimum-system-version = "11.0" -# Keys merged into the generated Info.plist: one viewer at a time, and the -# discrete GPU is not woken for a ledger. -info-plist-path = "deploy/packaging/Info.plist" - -[dmg] -window-size = { width = 540, height = 380 } -app-position = { x = 140, y = 180 } -application-folder-position = { x = 400, y = 180 } diff --git a/deploy/packaging/packager.toml b/deploy/packaging/packager.toml index 0974f661..b0307d5a 100644 --- a/deploy/packaging/packager.toml +++ b/deploy/packaging/packager.toml @@ -31,6 +31,8 @@ depends = ["libc6", "libgcc-s1"] # The notices the third-party licences ask to travel with the program # (`just notices`); `wanderbooks licenses` prints the same text. "THIRD-PARTY-NOTICES.txt" = "usr/share/doc/wanderbooks/THIRD-PARTY-NOTICES.txt" +"LICENSE-MIT" = "usr/share/doc/wanderbooks/LICENSE-MIT" +"LICENSE-APACHE" = "usr/share/doc/wanderbooks/LICENSE-APACHE" [pacman] depends = ["gcc-libs", "glibc"] @@ -38,3 +40,5 @@ depends = ["gcc-libs", "glibc"] [pacman.files] "deploy/packaging/install-method-aur" = "usr/share/wanderbooks/install-method" "THIRD-PARTY-NOTICES.txt" = "usr/share/doc/wanderbooks/THIRD-PARTY-NOTICES.txt" +"LICENSE-MIT" = "usr/share/doc/wanderbooks/LICENSE-MIT" +"LICENSE-APACHE" = "usr/share/doc/wanderbooks/LICENSE-APACHE" diff --git a/deploy/packaging/version.sh b/deploy/packaging/version.sh new file mode 100755 index 00000000..99304cd3 --- /dev/null +++ b/deploy/packaging/version.sh @@ -0,0 +1,21 @@ +#!/bin/sh +# The program's version: the one place it is written is `version = "..."` +# in crates/ledger-cli/Cargo.toml (plan P15 C1, WB-pkg-6). Every package, the +# release workflow and the installer take it from here; the program itself +# reports the same file's version through `CARGO_PKG_VERSION`. +# +# deploy/packaging/version.sh prints 0.1.0 +# +# A version that is not three plain numbers is refused: the Windows +# installer's file-version fields and the macOS bundle's both need them. +set -eu +here=$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd) +version=$(sed -n 's/^version = "\(.*\)"/\1/p' "$here/../../crates/ledger-cli/Cargo.toml" | head -n1) +case "$version" in + [0-9]*.[0-9]*.[0-9]*) ;; + *) echo "version.sh: no x.y.z version in crates/ledger-cli/Cargo.toml (found: '$version')" >&2; exit 1 ;; +esac +case "$version" in + *[!0-9.]*) echo "version.sh: '$version' is not three plain numbers" >&2; exit 1 ;; +esac +printf '%s\n' "$version" diff --git a/deploy/packaging/wanderbooks-static.desktop b/deploy/packaging/wanderbooks-static.desktop index ffa4bbe2..c6a9391a 100644 --- a/deploy/packaging/wanderbooks-static.desktop +++ b/deploy/packaging/wanderbooks-static.desktop @@ -1,7 +1,9 @@ [Desktop Entry] -Categories=Office;Finance; +Type=Application +Name=Wanderbooks Comment=Double-entry bookkeeping your agent keeps and you can read. Exec=wanderbooks -Name=Wanderbooks +Icon=wanderbooks Terminal=false -Type=Application +Categories=Office;Finance; +StartupWMClass=wanderbooks diff --git a/deploy/packaging/wanderbooks.desktop b/deploy/packaging/wanderbooks.desktop index 574cd598..5e3f2a8a 100644 --- a/deploy/packaging/wanderbooks.desktop +++ b/deploy/packaging/wanderbooks.desktop @@ -8,3 +8,4 @@ Icon={{icon}} Name={{name}} Terminal=false Type=Application +StartupWMClass=wanderbooks diff --git a/deploy/packaging/windows/build-windows.sh b/deploy/packaging/windows/build-windows.sh new file mode 100755 index 00000000..68ea948f --- /dev/null +++ b/deploy/packaging/windows/build-windows.sh @@ -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" diff --git a/deploy/packaging/windows/sign-windows.ps1 b/deploy/packaging/windows/sign-windows.ps1 new file mode 100644 index 00000000..6fce5ba0 --- /dev/null +++ b/deploy/packaging/windows/sign-windows.ps1 @@ -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 +} diff --git a/deploy/packaging/windows/wanderbooks.nsi b/deploy/packaging/windows/wanderbooks.nsi new file mode 100644 index 00000000..9d332144 --- /dev/null +++ b/deploy/packaging/windows/wanderbooks.nsi @@ -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= -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=" +!endif +!ifndef ICON + !error "pass -DICON=" +!endif +!ifndef LICENSES + !error "pass -DLICENSES=" +!endif +!ifndef OUTFILE + !error "pass -DOUTFILE=" +!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 diff --git a/justfile b/justfile index 8db57ebf..e524faad 100644 --- a/justfile +++ b/justfile @@ -591,10 +591,23 @@ package-linux version="" formats="deb,appimage,pacman": cargo build --release -p ledger-cli deploy/packaging/build-linux.sh {{version}} {{formats}} -# Build the unsigned macOS .dmg (on a Mac; CI does it on a tag or dispatch) +# The macOS app and its universal .dmg (on a Mac; CI does it on a tag or +# dispatch). Signs and notarizes only with WB_SIGN_IDENTITY and WB_NOTARY_* +# in the environment (deploy/packaging/macos/build-macos.sh says which). +# Build the universal macOS .dmg package-macos version="": + rustup target add aarch64-apple-darwin x86_64-apple-darwin + cargo build --release -p ledger-cli --target aarch64-apple-darwin + cargo build --release -p ledger-cli --target x86_64-apple-darwin + deploy/packaging/macos/build-macos.sh {{version}} + +# The per-user Windows installer (in Git Bash on Windows, with NSIS: choco +# install nsis; CI does it on a tag or dispatch). Unsigned unless the +# release workflow signs it. +# Build the Windows installer +package-windows version="": cargo build --release -p ledger-cli - deploy/packaging/build-macos.sh {{version}} + deploy/packaging/windows/build-windows.sh {{version}} # A release folder on this machine signed with a throwaway key; then # `wanderbooks update --feed file://DIR/manifest.json --trusted-key DIR/release.pub`