2014-11-10 04:48:09 +02:00
|
|
|
#!/bin/bash
|
|
|
|
# build binary distributions for linux/amd64 and darwin/amd64
|
2017-03-28 00:16:39 +02:00
|
|
|
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
|
2017-12-04 16:54:31 +02:00
|
|
|
dep ensure || exit 1
|
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}')
|
2017-11-20 21:35:59 +02:00
|
|
|
sha256sum=()
|
2014-11-10 04:48:09 +02:00
|
|
|
|
|
|
|
echo "... running tests"
|
2017-03-28 00:16:39 +02:00
|
|
|
./test.sh
|
2014-11-10 04:48:09 +02:00
|
|
|
|
2015-06-08 05:52:28 +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
|
2016-05-26 18:34:58 +02:00
|
|
|
BUILD=$(mktemp -d ${TMPDIR:-/tmp}/oauth2_proxy.XXXXXX)
|
2015-05-21 08:50:21 +02:00
|
|
|
TARGET="oauth2_proxy-$version.$os-$arch.$goversion"
|
2017-11-20 21:35:59 +02:00
|
|
|
FILENAME="oauth2_proxy-$version.$os-$arch$EXT"
|
2017-04-24 22:04:36 +02:00
|
|
|
GOOS=$os GOARCH=$arch CGO_ENABLED=0 \
|
2017-11-20 21:35:59 +02:00
|
|
|
go build -ldflags="-s -w" -o $BUILD/$TARGET/$FILENAME || exit 1
|
|
|
|
pushd $BUILD/$TARGET
|
|
|
|
sha256sum+=("$(shasum -a 256 $FILENAME || exit 1)")
|
|
|
|
cd .. && tar czvf $TARGET.tar.gz $TARGET
|
2014-11-10 04:48:09 +02:00
|
|
|
mv $TARGET.tar.gz $DIR/dist
|
|
|
|
popd
|
|
|
|
done
|
2017-11-20 21:35:59 +02:00
|
|
|
|
|
|
|
checksum_file="sha256sum.txt"
|
|
|
|
cd $DIR/dist
|
|
|
|
if [ -f $checksum_file ]; then
|
|
|
|
rm $checksum_file
|
|
|
|
fi
|
|
|
|
touch $checksum_file
|
|
|
|
for checksum in "${sha256sum[@]}"; do
|
|
|
|
echo "$checksum" >> $checksum_file
|
|
|
|
done
|