This commit is contained in:
esrrhs 2021-04-21 21:06:22 +08:00
parent 6e8c975859
commit 780f75ae7c

74
pack.sh
View File

@ -1,45 +1,15 @@
#! /bin/bash #! /bin/bash
#set -x #set -x
NAME="pingtunnel" NAME="pingtunnel"
rm *.zip -f
build_list="aix/ppc64 #go tool dist list
darwin/386 build_list=$(go tool dist list)
darwin/amd64
dragonfly/amd64 rm pack -rf
freebsd/386 rm pack.zip -f
freebsd/amd64 mkdir pack
freebsd/arm
freebsd/arm64 go get -u -v github.com/esrrhs/pingtunnel/...
illumos/amd64
js/wasm
linux/386
linux/amd64
linux/arm
linux/arm64
linux/mips
linux/mips64
linux/mips64le
linux/mipsle
linux/ppc64
linux/ppc64le
linux/riscv64
linux/s390x
netbsd/386
netbsd/amd64
netbsd/arm
netbsd/arm64
openbsd/386
openbsd/amd64
openbsd/arm
openbsd/arm64
plan9/386
plan9/amd64
plan9/arm
solaris/amd64
windows/386
windows/amd64
windows/arm"
for line in $build_list; do for line in $build_list; do
os=$(echo "$line" | awk -F"/" '{print $1}') os=$(echo "$line" | awk -F"/" '{print $1}')
@ -48,18 +18,34 @@ for line in $build_list; do
if [ $os == "android" ]; then if [ $os == "android" ]; then
continue continue
fi fi
CGO_ENABLED=0 GOOS=$os GOARCH=$arch go build if [ $os == "ios" ]; then
continue
fi
CGO_ENABLED=0 GOOS=$os GOARCH=$arch go build -ldflags="-s -w"
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "os="$os" arch="$arch" build fail" echo "os="$os" arch="$arch" build fail"
exit 1 exit 1
fi fi
zip ${NAME}_"${os}"_"${arch}"".zip" $NAME if [ $os = "windows" ]; then
if [ $? -ne 0 ]; then zip ${NAME}_"${os}"_"${arch}"".zip" $NAME".exe"
echo "os="$os" arch="$arch" zip fail" if [ $? -ne 0 ]; then
exit 1 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
fi fi
echo "os="$os" arch="$arch" done build" echo "os="$os" arch="$arch" done build"
done done
echo "all done" zip pack.zip pack/ -r
echo "all done"