-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild-app.sh
More file actions
executable file
·82 lines (73 loc) · 2.93 KB
/
Copy pathbuild-app.sh
File metadata and controls
executable file
·82 lines (73 loc) · 2.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/usr/bin/env bash
#
# Build Hush into a signed menu-bar .app bundle using SwiftPM + Command Line
# Tools only (no full Xcode required).
#
# SwiftPM produces a bare executable; a menu-bar (accessory) app needs a real
# bundle with an Info.plist (LSUIElement, icon) and a stable code signature so
# the Accessibility grant survives rebuilds. Run ./setup-signing.sh once first.
#
set -euo pipefail
APP_NAME="Hush"
BUNDLE_ID="com.hush.app"
EXEC="Hush"
BUILD_DIR=".build/release"
OUT_DIR="build"
APP_DIR="${OUT_DIR}/${APP_NAME}.app"
SIGN_ID="Hush Self-Signed"
ENTITLEMENTS="Hush/Hush.entitlements"
# Version source of truth is the VERSION file; env vars override (used by build-dmg.sh).
if [ -f "VERSION" ]; then
# shellcheck disable=SC1091
source "./VERSION"
fi
SHORT_VERSION="${HUSH_MARKETING_VERSION:-${MARKETING_VERSION:-1.5.0}}"
BUILD_VERSION="${HUSH_BUILD_VERSION:-${BUILD_VERSION:-22}}"
echo "==> Building menu-bar app..."
swift build -c release --product "$EXEC"
echo "==> Assembling ${APP_DIR}..."
rm -rf "$APP_DIR"
mkdir -p "$APP_DIR/Contents/MacOS" "$APP_DIR/Contents/Resources"
cp "$BUILD_DIR/$EXEC" "$APP_DIR/Contents/MacOS/$EXEC"
# Ensure the .icns exists, then bundle it.
if [ ! -f "Resources/AppIcon.icns" ]; then
echo "==> AppIcon.icns missing; generating it..."
./make-icon.sh
fi
cp "Resources/AppIcon.icns" "$APP_DIR/Contents/Resources/AppIcon.icns"
cat > "$APP_DIR/Contents/Info.plist" <<EOF
<?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>CFBundleName</key><string>${APP_NAME}</string>
<key>CFBundleDisplayName</key><string>${APP_NAME}</string>
<key>CFBundleIdentifier</key><string>${BUNDLE_ID}</string>
<key>CFBundleExecutable</key><string>${EXEC}</string>
<key>CFBundleIconFile</key><string>AppIcon</string>
<key>CFBundlePackageType</key><string>APPL</string>
<key>CFBundleShortVersionString</key><string>${SHORT_VERSION}</string>
<key>CFBundleVersion</key><string>${BUILD_VERSION}</string>
<key>LSMinimumSystemVersion</key><string>13.0</string>
<key>LSUIElement</key><true/>
<key>NSPrincipalClass</key><string>NSApplication</string>
<key>NSHighResolutionCapable</key><true/>
<key>NSAccessibilityUsageDescription</key><string>Hush needs Accessibility access to detect open app windows.</string>
</dict>
</plist>
EOF
SIGN_ARGS=(--force --options runtime --identifier "$BUNDLE_ID")
if [ -f "$ENTITLEMENTS" ]; then
SIGN_ARGS+=(--entitlements "$ENTITLEMENTS")
fi
if security find-identity -v -p codesigning | grep -q "$SIGN_ID"; then
echo "==> Signing with stable identity: $SIGN_ID"
codesign "${SIGN_ARGS[@]}" --sign "$SIGN_ID" "$APP_DIR"
else
echo "==> No stable identity found; ad-hoc signing."
echo " (Run ./setup-signing.sh once so the Accessibility grant survives rebuilds.)"
codesign "${SIGN_ARGS[@]}" --sign - "$APP_DIR"
fi
echo
echo "Built: $APP_DIR"
echo "Install & run: ./install.sh"