-
Notifications
You must be signed in to change notification settings - Fork 129
Expand file tree
/
Copy pathdist.sh
More file actions
executable file
·32 lines (27 loc) · 901 Bytes
/
dist.sh
File metadata and controls
executable file
·32 lines (27 loc) · 901 Bytes
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
#!/bin/sh
# build binary distributions for linux/amd64 and darwin/amd64
set -eu
cd "$(dirname "$0")"
DIR=$(pwd)
echo "working dir $DIR"
mkdir -p $DIR/dist
arch=$(go env GOARCH)
version=$(awk '/const VERSION/ {print $NF}' $DIR/version.go | sed 's/"//g')
goversion=$(go version | awk '{print $3}')
echo "... running tests"
./test.sh
for os in linux darwin freebsd; do
echo "... building v$version for $os/$arch"
BUILD=$(mktemp -d ${TMPDIR:-/tmp}/statsdaemon.XXXXXX)
TARGET="statsdaemon-$version.$os-$arch.$goversion"
GOOS=$os GOARCH=$arch CGO_ENABLED=0 go build -o $BUILD/$TARGET/statsdaemon
pushd $BUILD >/dev/null
tar czvf $TARGET.tar.gz $TARGET
if [ -e $DIR/dist/$TARGET.tar.gz ]; then
echo "... WARNING overwriting dist/$TARGET.tar.gz"
fi
mv $TARGET.tar.gz $DIR/dist
echo "... built dist/$TARGET.tar.gz"
popd >/dev/null
rm -r $BUILD
done