forked from bitly/oauth2_proxy
-
Notifications
You must be signed in to change notification settings - Fork 9
/
dist.sh
executable file
·33 lines (30 loc) · 959 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 most popular operating systems
set -eu
cd "$(dirname "$0")"
DIR="$(pwd)"
checksum_file="sha256sum.txt"
arch=$(go env GOARCH)
version=$(awk '/const VERSION/ {print $NF}' <version.go | sed 's/"//g')
goversion=$(go version | awk '{print $3}')
rm -rf dist
mkdir -p dist
echo "... running tests"
./test.sh
for os in windows linux darwin freebsd; do
echo "... building v$version for $os/$arch"
EXT=
if [ $os = windows ]; then
EXT=".exe"
fi
BUILD=$(mktemp -d ${TMPDIR:-/tmp}/oauth2_proxy.XXXXXX)
TARGET="oauth2_proxy-$version.$os-$arch.$goversion"
FILENAME="oauth2_proxy-$version.$os-$arch$EXT"
GOOS=$os GOARCH=$arch CGO_ENABLED=0 \
go build -ldflags="-s -w" -o $BUILD/$TARGET/$FILENAME || exit 1
pushd $BUILD/$TARGET
shasum -a 256 $FILENAME >>"$DIR/dist/$checksum_file"
cd .. && tar czvf $TARGET.tar.gz $TARGET
mv $TARGET.tar.gz $DIR/dist
popd
done