github.com/pusher/oauth2_proxy@v3.2.0+incompatible/dist.sh (about)

     1  #!/bin/bash
     2  # build binary distributions for linux/amd64 and darwin/amd64
     3  set -e
     4  
     5  DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
     6  echo "working dir $DIR"
     7  mkdir -p $DIR/dist
     8  dep ensure || exit 1
     9  
    10  os=$(go env GOOS)
    11  arch=$(go env GOARCH)
    12  version=$(cat $DIR/version.go | grep "const VERSION" | awk '{print $NF}' | sed 's/"//g')
    13  goversion=$(go version | awk '{print $3}')
    14  sha256sum=()
    15  
    16  echo "... running tests"
    17  ./test.sh
    18  
    19  for 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
    35  done
    36  
    37  checksum_file="sha256sum.txt"
    38  cd $DIR/dist
    39  if [ -f $checksum_file ]; then
    40      rm $checksum_file
    41  fi
    42  touch $checksum_file
    43  for checksum in "${sha256sum[@]}"; do
    44      echo "$checksum" >> $checksum_file
    45  done