1
0
mirror of https://github.com/oauth2-proxy/oauth2-proxy.git synced 2024-11-24 08:52:25 +02:00
oauth2-proxy/dist.sh

35 lines
960 B
Bash
Raw Normal View History

2014-11-10 04:48:09 +02:00
#!/bin/bash
# build binary distributions for linux/amd64 and darwin/amd64
set -e
2014-11-10 04:48:09 +02:00
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
echo "working dir $DIR"
mkdir -p $DIR/dist
mkdir -p $DIR/.godeps
export GOPATH=$DIR/.godeps:$GOPATH
GOPATH=$DIR/.godeps gpm install
2014-11-10 04:48:09 +02:00
os=$(go env GOOS)
arch=$(go env GOARCH)
version=$(cat $DIR/version.go | grep "const VERSION" | awk '{print $NF}' | sed 's/"//g')
goversion=$(go version | awk '{print $3}')
echo "... running tests"
./test.sh
2014-11-10 04:48:09 +02:00
for os in windows linux darwin; do
2014-11-10 04:48:09 +02:00
echo "... building v$version for $os/$arch"
2017-03-27 20:35:28 +02:00
EXT=
if [ $os = windows ]; then
EXT=".exe"
fi
BUILD=$(mktemp -d ${TMPDIR:-/tmp}/oauth2_proxy.XXXXXX)
2015-05-21 08:50:21 +02:00
TARGET="oauth2_proxy-$version.$os-$arch.$goversion"
GOOS=$os GOARCH=$arch CGO_ENABLED=0 \
go build -ldflags="-s -w" -o $BUILD/$TARGET/oauth2_proxy$EXT || exit 1
2014-11-10 04:48:09 +02:00
pushd $BUILD
tar czvf $TARGET.tar.gz $TARGET
mv $TARGET.tar.gz $DIR/dist
popd
done