-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·83 lines (73 loc) · 2.61 KB
/
Copy pathbuild.sh
File metadata and controls
executable file
·83 lines (73 loc) · 2.61 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
#!/bin/bash
# Builds ScreenBox.app into ./build/
#
# The version comes from the latest git tag (`v1.2.0` -> `1.2.0`), so tagging a
# release is the only thing that changes it. Set VERSION= to override.
set -euo pipefail
cd "$(dirname "$0")"
APP="build/ScreenBox.app"
# Marketing version: the tag without its leading v. Untagged builds are marked
# as such rather than borrowing a release number they aren't.
if [ -z "${VERSION:-}" ]; then
if TAG=$(git describe --tags --abbrev=0 2>/dev/null); then
VERSION="${TAG#v}"
git describe --tags --exact-match >/dev/null 2>&1 || VERSION="$VERSION-dev"
else
VERSION="0.0.0-dev"
fi
fi
# Build number: commit count, which only ever goes up. Falls back to 1 outside
# a checkout (a source tarball, say).
BUILD=$(git rev-list --count HEAD 2>/dev/null || echo 1)
rm -rf "$APP"
mkdir -p "$APP/Contents/MacOS" "$APP/Contents/Resources"
# The icon is checked in prebuilt: iconutil needs a whole .iconset directory,
# and regenerating it on every build would only ever produce the same file.
cp design/ScreenBox.icns "$APP/Contents/Resources/ScreenBox.icns"
# Universal binary. CI runs on Apple Silicon, so building for the host alone
# would ship releases that Intel Macs refuse to launch ("bad CPU type").
SOURCES=(Sources/Prefs.swift Sources/Tool.swift Sources/Shortcuts.swift Sources/Toolbar.swift Sources/main.swift)
SLICES=()
for ARCH in arm64 x86_64; do
SLICE="build/$ARCH-ScreenBox"
swiftc -O \
-target "$ARCH-apple-macos13.0" \
-framework Cocoa -framework Carbon \
-o "$SLICE" \
"${SOURCES[@]}"
SLICES+=("$SLICE")
done
lipo -create -output "$APP/Contents/MacOS/ScreenBox" "${SLICES[@]}"
rm -f "${SLICES[@]}"
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>CFBundleName</key>
<string>ScreenBox</string>
<key>CFBundleIdentifier</key>
<string>local.screenbox</string>
<key>CFBundleVersion</key>
<string>${BUILD}</string>
<key>CFBundleShortVersionString</key>
<string>${VERSION}</string>
<key>CFBundleExecutable</key>
<string>ScreenBox</string>
<key>CFBundleIconFile</key>
<string>ScreenBox</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>LSMinimumSystemVersion</key>
<string>13.0</string>
<key>LSUIElement</key>
<true/>
<key>NSHumanReadableCopyright</key>
<string>MIT licence. Copyright © 2026 Orva Studio Limited.</string>
<key>NSHighResolutionCapable</key>
<true/>
</dict>
</plist>
PLIST
codesign --force --deep --sign - "$APP"
echo "Built $APP ($VERSION, build $BUILD)"