-
Notifications
You must be signed in to change notification settings - Fork 95
/
Copy pathdist.sh
executable file
·33 lines (26 loc) · 930 Bytes
/
dist.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
#!/bin/bash
# build binary distributions for linux/amd64 and darwin/amd64
set -e
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
echo "working dir $DIR"
echo "... running tests"
go test ./... || exit 1
arch=$(go env GOARCH)
version=$(cat $DIR/version.go | grep "const VERSION" | awk '{print $NF}' | sed 's/"//g')
goversion=$(go version | awk '{print $3}')
for os in linux darwin; do
echo "... building v$version for $os/$arch"
BUILD=$(mktemp -d -t json2csv)
TARGET="json2csv-$version.$os-$arch.$goversion"
mkdir -p $BUILD/$TARGET
GOOS=$os GOARCH=$arch CGO_ENABLED=0 go build -o $BUILD/$TARGET/json2csv
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
mkdir -p $DIR/dist
mv $TARGET.tar.gz $DIR/dist/
echo "... built dist/$TARGET.tar.gz"
popd >/dev/null
done