2020-01-08 05:33:48 +03:00
|
|
|
#! /bin/bash
|
2021-04-19 17:04:37 +03:00
|
|
|
#set -x
|
|
|
|
NAME="pingtunnel"
|
2020-03-01 03:25:57 +03:00
|
|
|
|
2021-04-21 16:08:30 +03:00
|
|
|
export GO111MODULE=off
|
|
|
|
|
2021-04-21 16:06:22 +03:00
|
|
|
#go tool dist list
|
|
|
|
build_list=$(go tool dist list)
|
|
|
|
|
|
|
|
rm pack -rf
|
|
|
|
rm pack.zip -f
|
|
|
|
mkdir pack
|
|
|
|
|
|
|
|
go get -u -v github.com/esrrhs/pingtunnel/...
|
2020-01-08 05:33:48 +03:00
|
|
|
|
2021-04-19 17:04:37 +03:00
|
|
|
for line in $build_list; do
|
|
|
|
os=$(echo "$line" | awk -F"/" '{print $1}')
|
|
|
|
arch=$(echo "$line" | awk -F"/" '{print $2}')
|
|
|
|
echo "os="$os" arch="$arch" start build"
|
|
|
|
if [ $os == "android" ]; then
|
|
|
|
continue
|
|
|
|
fi
|
2021-04-21 16:06:22 +03:00
|
|
|
if [ $os == "ios" ]; then
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
CGO_ENABLED=0 GOOS=$os GOARCH=$arch go build -ldflags="-s -w"
|
2021-04-19 17:04:37 +03:00
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "os="$os" arch="$arch" build fail"
|
|
|
|
exit 1
|
|
|
|
fi
|
2021-04-21 16:06:22 +03:00
|
|
|
if [ $os = "windows" ]; then
|
|
|
|
zip ${NAME}_"${os}"_"${arch}"".zip" $NAME".exe"
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "os="$os" arch="$arch" zip fail"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
mv ${NAME}_"${os}"_"${arch}"".zip" pack/
|
|
|
|
rm $NAME".exe" -f
|
|
|
|
else
|
|
|
|
zip ${NAME}_"${os}"_"${arch}"".zip" $NAME
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "os="$os" arch="$arch" zip fail"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
mv ${NAME}_"${os}"_"${arch}"".zip" pack/
|
|
|
|
rm $NAME -f
|
2021-04-19 17:04:37 +03:00
|
|
|
fi
|
|
|
|
echo "os="$os" arch="$arch" done build"
|
|
|
|
done
|
2020-01-08 05:33:48 +03:00
|
|
|
|
2021-04-21 16:06:22 +03:00
|
|
|
zip pack.zip pack/ -r
|
2020-09-03 04:26:40 +03:00
|
|
|
|
2021-04-21 16:06:22 +03:00
|
|
|
echo "all done"
|