forked from Mygod/dnstt
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild-release.sh
More file actions
executable file
·57 lines (49 loc) · 1.2 KB
/
build-release.sh
File metadata and controls
executable file
·57 lines (49 loc) · 1.2 KB
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
#!/bin/bash
sum="sha1sum"
if ! hash sha1sum 2>/dev/null; then
if ! hash shasum 2>/dev/null; then
echo "I can't see 'sha1sum' or 'shasum'"
echo "Please install one of them!"
exit
fi
sum="shasum"
fi
[[ -z $upx ]] && upx="echo pending"
if [[ $upx == "echo pending" ]] && hash upx 2>/dev/null; then
upx="upx -9"
fi
VERSION=$(git describe --tags)
LDFLAGS="-s -w"
GCFLAGS=""
OSES=(linux darwin freebsd windows)
ARCHS=(amd64 arm64 386)
mkdir bin
for os in ${OSES[@]}; do
for arch in ${ARCHS[@]}; do
if [ "$os" == "darwin" ] && [ "$arch" == "386" ]; then
continue
fi
suffix=""
if [ "$os" == "windows" ]
then
suffix=".exe"
fi
build () {
mkdir build
pushd build
env CGO_ENABLED=0 GOOS=$os GOARCH=$arch go build -v -ldflags "$LDFLAGS" -gcflags "$GCFLAGS" -o "$1${suffix}" "../$1"
$upx "$1${suffix}" >/dev/null
local archive_name="../bin/$1-plugin-${os}-${arch}-$VERSION.tar.gz"
if [[ "$1" == "dnstt-server" ]]; then
tar -zcf "$archive_name" "$1${suffix}" -C ".." "$1-plugin"
else
tar -zcf "$archive_name" "$1${suffix}"
fi
$sum ../bin/$1-plugin-${os}-${arch}-$VERSION.tar.gz
popd
rm -rf build
}
build 'dnstt-client'
build 'dnstt-server'
done
done