-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathbuild.sh
executable file
·46 lines (38 loc) · 1.08 KB
/
build.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
#!/bin/sh
# https://xie.infoq.cn/article/4b954f196d6d4a288c8c6981c
NAME="macMineable"
OUT="out"
APP="$NAME.app"
VERSION=$(sed -n 's/.*"version": "\(.*\)",/\1/p' package.json)
rm -r $OUT/$APP
echo "Creating macOS app structure"
mkdir -p $OUT/$APP/Contents/{MacOS,Resources}
echo "Writing 'Info.plist'"
cat > $OUT/$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>$NAME</string>
<key>CFBundleIconFile</key>
<string>icon.icns</string>
<key>CFBundleIdentifier</key>
<string>io.2nthony.$NAME</string>
<key>NSHighResolutionCapable</key>
<true/>
<key>LSUIElement</key>
<string>1</string>
</dict>
</plist>
EOF
echo "Building Go app"
go build -o $OUT/$APP/Contents/MacOS/$NAME
echo "Copying files"
cp -r icon.icns $OUT/$APP/Contents/Resources
cp -r assets $OUT/$APP/Contents/Resources
cp -r dist $OUT/$APP/Contents/Resources
echo "Compressing '$APP'"
cd $OUT
zip -q -9 -r $NAME-$VERSION.zip $APP
echo "Done!"