-
Notifications
You must be signed in to change notification settings - Fork 0
/
package.sh
executable file
·83 lines (66 loc) · 1.22 KB
/
package.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
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
set -x
while getopts "a:v:h" opt; do
case $opt in
a)
ARCH=$OPTARG
;;
v)
VERSION=$OPTARG
;;
h)
cat <<EOF
Usage: $0 [-a build_arch] [-v version]
Support Arch: windows, linux
EOF
exit 0
;;
esac
done
if [ "$ARCH"x = "x" ];then
ARCH=linux
fi
if [ "$VERSION"x = "x" ];then
VERSION=latest
fi
#force clean befor package
rm -f bin/*
# build
go mod vendor
GOOS=$ARCH GOARCH=amd64 go build --ldflags '-w -s'
rm -f applegu/bin/.gitkeep
if [ -f "appLegu" ];then
cp appLegu bin/
elif [ -f "appLegu.exe" ];then
cp appLegu.exe bin/
else
echo "appLegu build artificat not found , run `go build` for debug."
exit -1
fi
mkdir -p applegu
cp -rf conf/ applegu
cp -rf bin/ applegu
cp -rf lib/ applegu
cp -rf pkgs/ applegu
rm -f applegu/pkgs/.gitkeep
if [ "$(hash upx)x" = "x" ];then
upx bin/appLegu*
fi
chmod u+x applegu/lib/zipalign
if [ -f "applegu/bin/appLegu" ];then
chmod u+x applegu/bin/appLegu
fi
if [ "$ARCH"x = "windowsx" ];then
tar vczf applegu-windows-${VERSION}.tar.gz applegu
else
tar vczf applegu-${VERSION}.tar.gz applegu
fi
# clean
rm -f appLegu
rm -f appLegu.exe
rm -f bin/*
rm -rf applegu
# install
# tar vxzf applegu-latest.tar.gz -C /usr/local/
# run
# /usr/local/applegu/bin/appLegu