-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathbuild-release.sh
executable file
·49 lines (41 loc) · 956 Bytes
/
build-release.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
49
#!/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)
ARCHS=(amd64 386)
mkdir bin
for os in ${OSES[@]}; do
for arch in ${ARCHS[@]}; do
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 ../$1
$upx $1 >/dev/null
tar -zcf ../bin/$1-plugin-${os}-${arch}-$VERSION.tar.gz $1 -C .. $1-plugin
$sum ../bin/$1-plugin-${os}-${arch}-$VERSION.tar.gz
popd
rm -rf build
}
build 'dnstt-client'
build 'dnstt-server'
done
done