-
Notifications
You must be signed in to change notification settings - Fork 20
/
dist.sh
executable file
·35 lines (29 loc) · 981 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
34
35
#!/bin/bash
# build binary distributions for linux/amd64 and darwin/amd64
set -e
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
echo "working dir $DIR"
if [ -e vendor ]; then
rm -rf $DIR/vendor
fi
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}')
mkdir -p dist
for os in linux darwin; do
echo "... building v$version for $os/$arch"
BUILD=$(mktemp -d -t git-open-pull)
TARGET="git-open-pull-$version.$os-$arch.$goversion"
mkdir -p $BUILD/$TARGET
GOOS=$os GOARCH=$arch CGO_ENABLED=0 go build -o $BUILD/$TARGET/git-open-pull
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
done