Skip to content

Commit

Permalink
dist.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
jehiah committed Jun 26, 2017
1 parent 5ca44a6 commit f6b4150
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
vendor
pkg
bin
dist
36 changes: 36 additions & 0 deletions dist.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash

# build binary distributions for linux/amd64 and darwin/amd64
set -e

DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
echo "working dir $DIR"

rm -rf $DIR/vendor
echo "... refreshing vendor directory"
./vendor.sh

echo "... running tests"
gb test || exit 1

arch=$(go env GOARCH)
version=$(cat $DIR/src/cmd/git-open-pull/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"
GOOS=$os GOARCH=$arch CGO_ENABLED=0 gb build
mkdir -p $BUILD/$TARGET
cp bin/git-open-pull-$os-$arch $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

0 comments on commit f6b4150

Please sign in to comment.