forked from synthparadox/EggLedger
-
Notifications
You must be signed in to change notification settings - Fork 3
/
build-macos.sh
54 lines (53 loc) · 1.71 KB
/
build-macos.sh
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
#!/bin/bash -eu
app=dist/EggLedger.app
version=$(<VERSION)
echo "generating $app v${version}..."
rm -rf $app
mkdir -p $app/Contents/{MacOS,Resources}
GOOS=darwin GOARCH=amd64 \
CGO_ENABLED=1 CGO_FLAGS='-mmacosx-version-min=10.13' CGO_LDFLAGS='-mmacosx-version-min=10.13' \
go build -o $app/Contents/MacOS/EggLedger
cat > $app/Contents/Info.plist <<EOF
<?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>EggLedger</string>
<key>CFBundleIconFile</key>
<string>icon.icns</string>
<key>CFBundleIdentifier</key>
<string>sh.tcl.EggLedger</string>
<key>CFBundleVersion</key>
<string>$version</string>
<key>CFBundleShortVersionString</key>
<string>$version</string>
</dict>
</plist>
EOF
cp icons/icon.icns $app/Contents/Resources/icon.icns
echo "generated $app"
cd dist
rm -rf EggLedger-mac.zip EggLedger
mkdir EggLedger
cp -r EggLedger.app EggLedger/
cp ../README.macOS.html EggLedger/README.html
cat >>EggLedger/preflight <<'EOF'
#!/bin/zsh
setopt nounset errexit
promptexit () { read -sk1 '?[Press any key to exit]'; }
success () { echo $'\e[32m'$1$'\e[0m'; }
die () { echo $'\e[31m'"Error: $1"$'\e[0m' >&2; promptexit; exit 1; }
here=$0:A:h
app=$here/EggLedger.app
[[ -d $app ]] || die "EggLedger.app not found at $here"
echo "Removing com.apple.quarantine attribute from EggLedger.app..."
xattr -c $app || die "Failed to remove com.apple.quarantine from EggLedger.app"
success "Success! You can now launch EggLedger.app normally."
promptexit
EOF
chmod +x EggLedger/preflight
zip -r EggLedger-mac.zip EggLedger
rm -rf EggLedger
echo "generated dist/EggLedger-mac.zip"
cd ..