-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmake-app.sh
More file actions
executable file
·63 lines (53 loc) · 2.31 KB
/
Copy pathmake-app.sh
File metadata and controls
executable file
·63 lines (53 loc) · 2.31 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
#!/bin/bash
# Assemble Ditto.app from the SwiftPM build product.
#
# There is no Xcode on this machine, so the bundle is put together by hand.
# CODESIGN_IDENTITY can point at a self-signed certificate if the ad-hoc
# signature keeps losing its Accessibility grant between rebuilds.
set -euo pipefail
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
CONFIG="${CONFIG:-release}"
# The git tag is the only place a version is written down. A local build with
# no VERSION set describes itself from the tags instead of hardcoding a number
# here, which would drift the moment a release goes out.
if [ -z "${VERSION:-}" ]; then
VERSION="$(git -C "$ROOT" describe --tags --match 'v[0-9]*' --dirty 2>/dev/null || true)"
VERSION="${VERSION:-0.0.0-dev}"
fi
IDENTIFIER="be.studiohyperdrive.mcditto"
APP="$ROOT/build/Ditto.app"
# A leading "v" is accepted so a git tag can be passed straight through.
# CFBundleShortVersionString may carry a suffix like 1.2.0-beta, but
# CFBundleVersion has to be plain dot-separated digits, so trim it down.
SHORT_VERSION="${VERSION#v}"
BUILD_VERSION="$(printf '%s' "$SHORT_VERSION" | sed -E 's/^([0-9]+(\.[0-9]+)*).*/\1/')"
case "$BUILD_VERSION" in
[0-9]*) ;;
*) echo "VERSION '$VERSION' does not start with a number" >&2; exit 1 ;;
esac
cd "$ROOT"
echo "==> swift build -c $CONFIG"
swift build -c "$CONFIG"
BIN="$(swift build -c "$CONFIG" --show-bin-path)/mcditto"
[ -x "$BIN" ] || { echo "build product missing: $BIN" >&2; exit 1; }
echo "==> assembling $APP (version $SHORT_VERSION, build $BUILD_VERSION)"
rm -rf "$APP"
mkdir -p "$APP/Contents/MacOS" "$APP/Contents/Resources"
cp "$BIN" "$APP/Contents/MacOS/mcditto"
sed -e "s/__SHORT_VERSION__/$SHORT_VERSION/g" -e "s/__BUILD_VERSION__/$BUILD_VERSION/g" \
"$ROOT/Resources/Info.plist" > "$APP/Contents/Info.plist"
printf 'APPL????' > "$APP/Contents/PkgInfo"
if [ -f "$ROOT/Resources/AppIcon.icns" ]; then
cp "$ROOT/Resources/AppIcon.icns" "$APP/Contents/Resources/AppIcon.icns"
fi
# SwiftPM may emit a bundle for target resources; carry it along if present.
for b in "$(dirname "$BIN")"/*.bundle; do
[ -e "$b" ] && cp -R "$b" "$APP/Contents/Resources/"
done
echo "==> codesigning"
codesign --force --deep --options runtime \
--sign "${CODESIGN_IDENTITY:--}" \
--identifier "$IDENTIFIER" \
"$APP"
codesign --verify --verbose=1 "$APP"
echo "==> built $APP"