Repository navigation
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·70 lines (63 loc) · 2.63 KB
/
Copy pathbuild.sh
File metadata and controls
executable file
·70 lines (63 loc) · 2.63 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
#!/bin/bash
# Builds GitHubFloat.app.
# ./build.sh build and install into ~/Applications
# ./build.sh --dist build a universal (arm64 + x86_64) app into dist/ and zip it for a release
set -euo pipefail
cd "$(dirname "$0")"
VERSION="${VERSION:-$(git describe --tags --abbrev=0 2>/dev/null | sed 's/^v//' || true)}"
VERSION="${VERSION:-1.0.0}"
BUILD_NUMBER="${BUILD_NUMBER:-$(git rev-list --count HEAD 2>/dev/null || echo 1)}"
if [ "${1:-}" = "--dist" ]; then
swift build -c release --arch arm64 --arch x86_64
BIN=".build/apple/Products/Release/GitHubFloat"
APP="dist/GitHubFloat.app"
mkdir -p dist
else
swift build -c release
BIN="$(swift build -c release --show-bin-path)/GitHubFloat"
APP="$HOME/Applications/GitHubFloat.app"
mkdir -p "$HOME/Applications"
fi
rm -rf "$APP"
mkdir -p "$APP/Contents/MacOS" "$APP/Contents/Resources"
cp "$BIN" "$APP/Contents/MacOS/GitHubFloat"
"$BIN" --render-sounds "$APP/Contents/Resources"
# App icon: convert the 1024px master PNG into an .icns.
TMP="$(mktemp -d)"
ICONSET="$TMP/AppIcon.iconset"
mkdir -p "$ICONSET"
for s in 16 32 128 256 512; do
sips -z $s $s Icon/AppIcon.png --out "$ICONSET/icon_${s}x${s}.png" >/dev/null
sips -z $((s*2)) $((s*2)) Icon/AppIcon.png --out "$ICONSET/icon_${s}x${s}@2x.png" >/dev/null
done
iconutil -c icns "$ICONSET" -o "$APP/Contents/Resources/AppIcon.icns"
cp "$ICONSET/icon_128x128@2x.png" "$APP/Contents/Resources/NotificationIcon.png"
rm -rf "$TMP"
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>GitHubFloat</string>
<key>CFBundleDisplayName</key><string>GitHub Float</string>
<key>CFBundleIdentifier</key><string>com.vinimcorrea.githubfloat</string>
<key>CFBundleExecutable</key><string>GitHubFloat</string>
<key>CFBundleIconFile</key><string>AppIcon</string>
<key>CFBundlePackageType</key><string>APPL</string>
<key>CFBundleShortVersionString</key><string>${VERSION}</string>
<key>CFBundleVersion</key><string>${BUILD_NUMBER}</string>
<key>LSMinimumSystemVersion</key><string>13.0</string>
<key>LSUIElement</key><true/>
<key>NSHighResolutionCapable</key><true/>
<key>NSHumanReadableCopyright</key><string>MIT License</string>
</dict>
</plist>
PLIST
codesign --force --deep --sign - "$APP"
if [ "${1:-}" = "--dist" ]; then
(cd dist && rm -f GitHubFloat.zip && ditto -c -k --keepParent GitHubFloat.app GitHubFloat.zip)
shasum -a 256 dist/GitHubFloat.zip
echo "Built dist/GitHubFloat.zip (v${VERSION})"
else
echo "Installed $APP (v${VERSION})"
fi