Skip to content

Commit f129110

Browse files
committed
add build-release.sh
1 parent aa0ce31 commit f129110

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

build-release.sh

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/bin/bash
2+
3+
BUILD_DIR=$(dirname "$0")/build
4+
mkdir -p $BUILD_DIR
5+
cd $BUILD_DIR
6+
7+
sum="sha1sum"
8+
9+
export GO111MODULE=on
10+
echo "BUILDING SAFEBOX"
11+
echo "Setting GO111MODULE to" $GO111MODULE
12+
13+
if ! hash sha1sum 2>/dev/null; then
14+
if ! hash shasum 2>/dev/null; then
15+
echo "I can't see 'sha1sum' or 'shasum'"
16+
echo "Please install one of them!"
17+
exit
18+
fi
19+
sum="shasum"
20+
fi
21+
22+
UPX=false
23+
if hash upx 2>/dev/null; then
24+
UPX=true
25+
fi
26+
27+
VERSION="1.0.1"
28+
LDFLAGS="-X main.VERSION=$VERSION -s -w"
29+
GCFLAGS=""
30+
31+
# AMD64
32+
OSES=(linux darwin windows freebsd openbsd)
33+
for os in ${OSES[@]}; do
34+
suffix=""
35+
if [ "$os" == "windows" ]
36+
then
37+
suffix=".exe"
38+
fi
39+
env CGO_ENABLED=0 GOOS=$os GOARCH=amd64 go build -mod=vendor -ldflags "$LDFLAGS" -gcflags "$GCFLAGS" -o safebox_${os}_amd64${suffix} github.com/xtaci/safebox
40+
if $UPX; then upx -9 safebox_${os}_amd64${suffix};fi
41+
tar -zcf safebox-${os}-amd64-$VERSION.tar.gz safebox_${os}_amd64${suffix}
42+
$sum safebox-${os}-amd64-$VERSION.tar.gz
43+
done
44+
45+
#Apple M1 device
46+
env CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -mod=vendor -ldflags "$LDFLAGS" -gcflags "$GCFLAGS" -o safebox_darwin_arm64$v github.com/xtaci/safebox
47+
tar -zcf safebox-darwin-arm64-$VERSION.tar.gz safebox_darwin_arm64
48+
$sum safebox-darwin-arm64-$VERSION.tar.gz
49+
50+
# ARM64
51+
env CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -mod=vendor -ldflags "$LDFLAGS" -gcflags "$GCFLAGS" -o safebox_linux_arm64 github.com/xtaci/safebox
52+
if $UPX; then upx -9 safebox_linux_arm64 ;fi
53+
tar -zcf safebox-linux-arm64-$VERSION.tar.gz safebox_linux_arm64
54+
$sum safebox-linux-arm64-$VERSION.tar.gz
File renamed without changes.

0 commit comments

Comments
 (0)