-
Notifications
You must be signed in to change notification settings - Fork 6
/
build.sh
executable file
·48 lines (41 loc) · 1.19 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
47
48
#!/bin/bash
importpath="github.com/scutrobotlab/asuwave/internal/helper"
build_prefix="asuwave_"
os_list=("linux" "darwin" "windows")
arch_list=("amd64" "arm64")
if [ -v $1 ];
then
echo "No"
gittag=`git describe --tags --abbrev=0`
else
echo "Yes"
gittag=$1
fi
echo ${gittag}
sed -i "s/VUE_APP_GITTAG=.*/VUE_APP_GITTAG=${gittag}/g" .env
cat .env
npm ci
npm run build
build_dir="build"
if [[ ! -d $build_dir ]]; then
mkdir $build_dir
else
rm -rf $build_dir
fi
flags="-w -s -X '${importpath}.GitTag=${gittag}' -X '${importpath}.GitHash=$(git describe --tags --long)' -X '${importpath}.BuildTime=$(date +'%Y-%m-%d %H:%M')' -X '${importpath}.GoVersion=$(go version)'"
for os in ${os_list[@]}; do
for arch in ${arch_list[@]}; do
suffix=""
if [ "$os" == "windows" ] ; then
if [ "$arch" == "arm64" ]; then
continue
else
suffix=".exe"
fi
fi
file=$build_dir/$build_prefix${gittag}_${os}_${arch}
out=$build_dir/$build_prefix${os}_${arch}$suffix
CGO_ENABLED=0 GOOS=${os} GOARCH=${arch} go build -tags release -ldflags="$flags" -o $out
zip -j -9 $file.zip $out
done
done