git.iko.soy/typeable/oauth2-proxy
on v3.2.0 help sign in
45 lines 1.2 kB history raw
1#!/bin/bash
2# build binary distributions for linux/amd64 and darwin/amd64
3set -e
5DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
6echo "working dir $DIR"
7mkdir -p $DIR/dist
8dep ensure || exit 1
10os=$(go env GOOS)
11arch=$(go env GOARCH)
12version=$(cat $DIR/version.go | grep "const VERSION" | awk '{print $NF}' | sed 's/"//g')
13goversion=$(go version | awk '{print $3}')
14sha256sum=()
16echo "... running tests"
17./test.sh
19for os in windows linux darwin; do
20 echo "... building v$version for $os/$arch"
21 EXT=
22 if [ $os = windows ]; then
23 EXT=".exe"
24 fi
25 BUILD=$(mktemp -d ${TMPDIR:-/tmp}/oauth2_proxy.XXXXXX)
26 TARGET="oauth2_proxy-$version.$os-$arch.$goversion"
27 FILENAME="oauth2_proxy-$version.$os-$arch$EXT"
28 GOOS=$os GOARCH=$arch CGO_ENABLED=0 \
29 go build -ldflags="-s -w" -o $BUILD/$TARGET/$FILENAME || exit 1
30 pushd $BUILD/$TARGET
31 sha256sum+=("$(shasum -a 256 $FILENAME || exit 1)")
32 cd .. && tar czvf $TARGET.tar.gz $TARGET
33 mv $TARGET.tar.gz $DIR/dist
34 popd
35done
37checksum_file="sha256sum.txt"
38cd $DIR/dist
39if [ -f $checksum_file ]; then
40 rm $checksum_file
41fi
42touch $checksum_file
43for checksum in "${sha256sum[@]}"; do
44 echo "$checksum" >> $checksum_file
45done