#!/bin/bash set -euo pipefail cd "$(dirname "$0")" VERSION="${1:-0.2.2}" swift build -c release BIN=".build/release/SimpleTopBar" APP="SimpleTopBar.app" IDENT="" # Prefer a Developer ID Application identity so the app gets clean Gatekeeper # behavior; fall back to ad-hoc signing (no TCC-stable identity) otherwise. if command -v security >/dev/null 2>&1; then IDENT=$(security find-identity -v -p codesigning 2>/dev/null | awk '/Developer ID Application:/ { print $2; exit }') fi rm -rf "$APP" mkdir -p "$APP/Contents/MacOS" cp "$BIN" "$APP/Contents/MacOS/SimpleTopBar" cat > "$APP/Contents/Info.plist" < CFBundleExecutable SimpleTopBar CFBundleIdentifier dev.tzgyn.simpletopbar CFBundleInfoDictionaryVersion 6.0 CFBundleName SimpleTopBar CFBundlePackageType APPL CFBundleIconFile Icon CFBundleShortVersionString ${VERSION} CFBundleVersion ${VERSION} LSMinimumSystemVersion 13.0 LSUIElement NSHighResolutionCapable NSPrincipalClass NSApplication PLIST chmod +x scripts/make-icon.sh ./scripts/make-icon.sh if [ -n "$IDENT" ]; then security unlock-keychain "$HOME/Library/Keychains/login.keychain-db" 2>/dev/null || true codesign --force --options runtime --sign "$IDENT" "$APP" echo "Built $APP ${VERSION} (signed with Developer ID '$IDENT') — open $APP" else codesign --force --sign - "$APP" echo "Built $APP ${VERSION} (ad-hoc signed) — open $APP" fi