Repository navigation
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·75 lines (67 loc) · 3.28 KB
/
Copy pathbuild.sh
File metadata and controls
executable file
·75 lines (67 loc) · 3.28 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
#!/bin/bash
# Builds "Easy Write.app" in this folder.
#
# Signing, in order of preference:
# 1. $EW_SIGN_IDENTITY, if set
# 2. a "Developer ID Application" identity in your keychain (hardened runtime; this is what
# release.sh notarizes)
# 3. the "Easy Write Self-Signed" identity from ./setup-signing.sh
# 4. ad-hoc
# Any stable identity (1–3) keeps the Accessibility permission across rebuilds.
set -euo pipefail
cd "$(dirname "$0")"
APP="${EW_APP_PATH:-Easy Write.app}"
if [ -n "${EW_APP_PATH:-}" ]; then
[ "$(basename "$APP")" = "Easy Write.app" ] && [ ! -e "$APP" ] && [ ! -L "$APP" ] \
|| { echo "EW_APP_PATH must name a new Easy Write.app, never an existing bundle." >&2; exit 1; }
fi
TIMESTAMP="${EW_TIMESTAMP:---timestamp=none}" # release.sh passes --timestamp
echo "▶ Building (release)…"
swift build -c release
if [ -z "${EW_APP_PATH:-}" ]; then
rm -rf "Easy Write.app" "EasyWrite.app"
fi
mkdir -p "$APP/Contents/MacOS" "$APP/Contents/Resources" "$APP/Contents/Frameworks"
cp ".build/release/EasyWrite" "$APP/Contents/MacOS/EasyWrite"
cp "Info.plist" "$APP/Contents/Info.plist"
if [ "${EW_ENABLE_UPDATES:-0}" != "1" ]; then
/usr/libexec/PlistBuddy -c 'Delete :SUFeedURL' "$APP/Contents/Info.plist"
/usr/libexec/PlistBuddy -c 'Delete :SUPublicEDKey' "$APP/Contents/Info.plist"
fi
[ -f AppIcon.icns ] && cp AppIcon.icns "$APP/Contents/Resources/AppIcon.icns"
cp Resources/Studio/*.png "$APP/Contents/Resources/" # Studio page tiles (make-studio-icons.py output)
# Interface text: English and German. Compiles the string catalog into en.lproj and de.lproj.
xcrun xcstringstool compile Resources/Localizable.xcstrings --output-directory "$APP/Contents/Resources" >/dev/null
# Sparkle (updates). The app isn't sandboxed, so Sparkle's XPC services aren't needed.
SPARKLE=".build/release/Sparkle.framework" # .build/release links to the real product folder
if [ -d "$SPARKLE" ]; then
cp -R "$SPARKLE" "$APP/Contents/Frameworks/"
rm -rf "$APP/Contents/Frameworks/Sparkle.framework/Versions/B/XPCServices"
fi
[ -z "$(ls -A "$APP/Contents/Frameworks")" ] && rmdir "$APP/Contents/Frameworks"
IDENTITY="${EW_SIGN_IDENTITY:-}"
RUNTIME=()
if [ -z "$IDENTITY" ]; then
DEVID=$(security find-identity -v -p codesigning 2>/dev/null | grep "Developer ID Application" | head -1 | awk '{print $2}' || true)
if [ -n "$DEVID" ]; then
IDENTITY="$DEVID"
elif security find-identity -p codesigning 2>/dev/null | grep -q "Easy Write Self-Signed"; then
IDENTITY="Easy Write Self-Signed"
else
IDENTITY="-"
fi
fi
if [ "$IDENTITY" != "-" ] && security find-identity -v -p codesigning 2>/dev/null | grep "$IDENTITY" | grep -q "Developer ID"; then
RUNTIME=(--options runtime)
fi
sign() { codesign --force "${RUNTIME[@]+"${RUNTIME[@]}"}" $TIMESTAMP --sign "$IDENTITY" "$@"; }
if [ -d "$APP/Contents/Frameworks/Sparkle.framework" ]; then
FW="$APP/Contents/Frameworks/Sparkle.framework/Versions/B"
sign "$FW/Autoupdate"
sign "$FW/Updater.app"
sign "$APP/Contents/Frameworks/Sparkle.framework"
fi
echo "▶ Code signing with: $( [ "$IDENTITY" = "-" ] && echo ad-hoc || security find-identity -v -p codesigning | grep "$IDENTITY" | sed 's/.*"\(.*\)"/\1/' | head -1 )"
sign "$APP"
echo "✅ Built $APP"
echo " Open it with: open \"$APP\""