PrintToVeraeTimeStamp/platform/macos/menubar/build-menubar-app.sh
George Lambert 48da24a661 feat: 2026 brand UI — statuslang, tray/menubar, CERT pdf, site kit
- Brand receipt status strings (statuslang) for notify/queue
- Windows tray + Start Menu/Startup install; macOS menubar helper
- CERT-01 plum/gold PDF + multihash/blake3 when present
- printit.verae.ai brand kit, queue page, customer-auth helper
- verae-print pending/tray-status/menubar commands
2026-10-13 21:11:32 -04:00

133 lines
4.4 KiB
Shell
Executable file

#!/bin/bash
# Build an unsigned .app that runs the Verae menu-bar status item (PT-06).
# Not notarized — for local / dev login items. Prefer LaunchAgent for headless.
# See README.txt for codesign + notarization steps when Apple certs are available.
#
# Usage:
# ./build-menubar-app.sh
# ./build-menubar-app.sh /path/to/Verae\ Menubar.app
# VERAE_IPP_ADDR=127.0.0.1:8631 ./build-menubar-app.sh
# VERSION=0.3.6 ./build-menubar-app.sh
set -euo pipefail
DIR="$(cd "$(dirname "$0")" && pwd)"
ROOT="$(cd "$DIR/../../.." && pwd)"
ADDR="${VERAE_IPP_ADDR:-127.0.0.1:8631}"
OUT="${1:-$DIR/Verae Menubar.app}"
SRC="$DIR/verae-menubar.swift"
RUN_SH="$DIR/run-menubar.sh"
# Package version = internal/job.HelperVersion (single source of truth).
if [[ -z "${VERSION:-}" ]]; then
if [[ -f "$ROOT/internal/job/job.go" ]]; then
VERSION="$(grep -E 'HelperVersion[[:space:]]*=' "$ROOT/internal/job/job.go" | head -1 | sed -E 's/.*"([^"]+)".*/\1/')"
fi
VERSION="${VERSION:-0.3.6}"
fi
BUNDLE_ID="ai.verae.timestamping.menubar"
ENTITLEMENTS_SRC="$DIR/../pkg/entitlements.plist"
if [[ ! -f "$SRC" ]]; then
echo "missing $SRC" >&2
exit 1
fi
# Fresh bundle so stale binaries / plists do not linger.
rm -rf "$OUT"
CONTENTS="$OUT/Contents"
MACOS="$CONTENTS/MacOS"
RES="$CONTENTS/Resources"
mkdir -p "$MACOS" "$RES"
# Prefer a compiled binary inside the bundle (no runtime swift dependency).
BIN="$MACOS/verae-menubar"
if command -v swiftc >/dev/null 2>&1; then
echo "compiling $SRC → $BIN"
swiftc -O -o "$BIN" "$SRC"
chmod 755 "$BIN"
else
echo "swiftc not found — bundling interpreter launcher" >&2
cp -f "$SRC" "$RES/verae-menubar.swift"
cat >"$BIN" <<'EOBIN'
#!/bin/bash
DIR="$(cd "$(dirname "$0")/.." && pwd)"
SRC="$DIR/Resources/verae-menubar.swift"
ADDR="${VERAE_IPP_ADDR:-127.0.0.1:8631}"
if [[ $# -ge 1 && -n "${1:-}" ]]; then ADDR="$1"; fi
export VERAE_IPP_ADDR="$ADDR"
exec /usr/bin/swift "$SRC" "$ADDR"
EOBIN
chmod 755 "$BIN"
fi
# Thin wrapper so open -a / double-click sets VERAE_IPP_ADDR and stays AppKit.
LAUNCHER="$MACOS/Verae Menubar"
cat >"$LAUNCHER" <<EOF_LAUNCH
#!/bin/bash
export VERAE_IPP_ADDR="\${VERAE_IPP_ADDR:-$ADDR}"
exec "\$(cd "\$(dirname "\$0")" && pwd)/verae-menubar" "\$VERAE_IPP_ADDR"
EOF_LAUNCH
chmod 755 "$LAUNCHER"
# Keep run-menubar.sh for LaunchAgent parity (optional).
if [[ -f "$RUN_SH" ]]; then
cp -f "$RUN_SH" "$RES/run-menubar.sh"
chmod 755 "$RES/run-menubar.sh"
fi
# Copy entitlements next to the app for optional codesign (document only — not applied).
if [[ -f "$ENTITLEMENTS_SRC" ]]; then
cp -f "$ENTITLEMENTS_SRC" "$RES/entitlements.plist"
fi
# Stamp HelperVersion / package version into the bundle (A4 packaging metadata).
printf '%s\n' "$VERSION" >"$RES/VERSION"
printf 'helper_version=%s\npackage_version=%s\nsource=internal/job.HelperVersion\n' \
"$VERSION" "$VERSION" >"$RES/packaging-metadata.txt"
# Classic Mac package type marker (APPL).
printf 'APPL????' >"$CONTENTS/PkgInfo"
cat >"$CONTENTS/Info.plist" <<PLIST
<?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">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>Verae Menubar</string>
<key>CFBundleIdentifier</key>
<string>$BUNDLE_ID</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>Verae Menubar</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>$VERSION</string>
<key>CFBundleVersion</key>
<string>$VERSION</string>
<key>LSMinimumSystemVersion</key>
<string>12.0</string>
<key>LSUIElement</key>
<true/>
<key>NSHighResolutionCapable</key>
<true/>
<key>CFBundleDisplayName</key>
<string>Verae Menubar</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © Verae Inc.</string>
</dict>
</plist>
PLIST
# LSUIElement = menu-bar only (no Dock icon).
echo "Built unsigned app: $OUT"
echo " Bundle id: $BUNDLE_ID version: $VERSION"
echo " Run: open \"$OUT\""
echo " Login item: System Settings → General → Login Items → + → select the .app"
echo " Or LaunchAgent: verae-print menubar --install"
echo " Codesign/notarize: see $DIR/README.txt (requires Apple Developer ID — not applied here)"
echo "Polls http://$ADDR/status · Open queue → /queue"
echo "Only a final receipt is evidence — hold ids are local queue handles, not proof."