-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·120 lines (104 loc) · 3.8 KB
/
build.sh
File metadata and controls
executable file
·120 lines (104 loc) · 3.8 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#!/bin/bash
set -euo pipefail
# Load signing config from .env.local (not committed to repo)
[ -f .env.local ] && source .env.local
# ── Config ────────────────────────────────────────────────
APP_NAME="AiRephrase"
BUNDLE_ID="com.malikov.ai-rephrase"
DISPLAY_NAME="AI Rephrase"
MIN_OS="26.0"
LSUIELEMENT="true"
EXTRA_BUNDLES="KeyboardShortcuts_KeyboardShortcuts.bundle" # space-separated resource bundles to copy
# ── Signing identity (loaded from .env.local) ─
IDENTITY="${IDENTITY:?Set IDENTITY in .env.local}"
NOTARY_PROFILE="${NOTARY_PROFILE:-notarytool}"
# ───────────────────────────────────────────────────────────
APP="${APP_NAME}.app"
DMG="${APP_NAME}.dmg"
BINARY=".build/apple/Products/Release/${APP_NAME}"
step() { echo ""; echo "── $1"; }
SELF="$(cd "$(dirname "$0")" && pwd)/$(basename "$0")"
case "${1:-release}" in
build)
step "Building universal binary"
swift build -c release --arch arm64 --arch x86_64
;;
app)
bash "${SELF}" build
step "Creating ${APP}"
rm -rf "${APP}"
mkdir -p "${APP}/Contents/MacOS" "${APP}/Contents/Resources"
cp "${BINARY}" "${APP}/Contents/MacOS/"
[ -f AppIcon.icns ] && cp AppIcon.icns "${APP}/Contents/Resources/"
# Copy extra resource bundles (e.g. KeyboardShortcuts)
for bundle in ${EXTRA_BUNDLES}; do
src=".build/apple/Products/Release/${bundle}"
[ -d "${src}" ] && cp -R "${src}" "${APP}/Contents/Resources/"
done
cat > "${APP}/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>CFBundleExecutable</key><string>${APP_NAME}</string>
<key>CFBundleIdentifier</key><string>${BUNDLE_ID}</string>
<key>CFBundleName</key><string>${DISPLAY_NAME}</string>
<key>CFBundlePackageType</key><string>APPL</string>
<key>CFBundleShortVersionString</key><string>1.0</string>
<key>CFBundleIconFile</key><string>AppIcon</string>
<key>LSUIElement</key><${LSUIELEMENT}/>
<key>LSMinimumSystemVersion</key><string>${MIN_OS}</string>
<key>NSHighResolutionCapable</key><true/>
</dict>
</plist>
PLIST
echo "✓ ${APP} created"
;;
sign)
bash "${SELF}" app
step "Signing ${APP}"
# Sign any embedded bundles first
find "${APP}/Contents/Resources" -name "*.bundle" -exec \
codesign --force --options runtime --timestamp --sign "${IDENTITY}" {} \;
# Sign the app
codesign --force --options runtime --timestamp \
--sign "${IDENTITY}" "${APP}"
codesign --verify --verbose=2 "${APP}"
echo "✓ Signed"
;;
notarize)
bash "${SELF}" sign
step "Notarizing"
ditto -c -k --keepParent "${APP}" "/tmp/${APP_NAME}.zip"
xcrun notarytool submit "/tmp/${APP_NAME}.zip" \
--keychain-profile "${NOTARY_PROFILE}" --wait
xcrun stapler staple "${APP}"
rm "/tmp/${APP_NAME}.zip"
echo "✓ Notarized & stapled"
;;
dmg)
bash "${SELF}" notarize
step "Creating ${DMG}"
rm -f "${DMG}"
STAGING="$(mktemp -d)"
cp -R "${APP}" "${STAGING}/"
ln -s /Applications "${STAGING}/Applications"
hdiutil create -volname "${DISPLAY_NAME}" -srcfolder "${STAGING}" -ov -format UDZO "${DMG}"
rm -rf "${STAGING}"
echo "✓ ${DMG} ready"
;;
release)
bash "${SELF}" dmg
step "Done"
echo "Upload ${DMG} to GitHub Releases"
echo " gh release create vX.Y.Z ${DMG} --title '${DISPLAY_NAME} vX.Y.Z'"
;;
clean)
rm -rf .build "${APP}" "${DMG}"
echo "✓ Cleaned"
;;
*)
echo "Usage: $0 {build|app|sign|notarize|dmg|release|clean}"
exit 1
;;
esac