git.iko.soy/typeable/oauth2-proxy
on master help sign in
64 lines 1.8 kB history raw
1#!/usr/bin/env bash
3set -o errexit
5if [[ -z ${BINARY} ]] || [[ -z ${VERSION} ]]; then
6 echo "Missing required env var: BINARY=X VERSION=X $(basename $0)"
7 exit 1
8fi
10ARCHS=(
11 darwin-amd64
12 darwin-arm64
13 linux-amd64
14 linux-arm64
15 linux-armv5
16 linux-armv6
17 linux-armv7
18 linux-ppc64le
19 linux-s390x
20 freebsd-amd64
21 windows-amd64
24mkdir -p release
26# Create architecture specific release dirs
27for ARCH in "${ARCHS[@]}"; do
28 mkdir -p release/${BINARY}-${VERSION}.${ARCH}
30 GO_OS=$(echo $ARCH | awk -F- '{print $1}')
31 GO_ARCH=$(echo $ARCH | awk -F- '{print $2}')
33 # Determine binary name based on OS
34 if [[ "${GO_OS}" == "windows" ]]; then
35 BINARY_NAME="${BINARY}.exe"
36 else
37 BINARY_NAME="${BINARY}"
38 fi
40 # Create architecture specific binaries
41 if [[ ${GO_ARCH} == armv* ]]; then
42 GO_ARM=$(echo $GO_ARCH | awk -Fv '{print $2}')
43 GO111MODULE=on GOOS=${GO_OS} GOARCH=arm GOARM=${GO_ARM} CGO_ENABLED=0 go build \
44 -ldflags="-X github.com/oauth2-proxy/oauth2-proxy/v7/pkg/version.VERSION=${VERSION}" \
45 -o release/${BINARY}-${VERSION}.${ARCH}/${BINARY_NAME} .
46 else
47 GO111MODULE=on GOOS=${GO_OS} GOARCH=${GO_ARCH} CGO_ENABLED=0 go build \
48 -ldflags="-X github.com/oauth2-proxy/oauth2-proxy/v7/pkg/version.VERSION=${VERSION}" \
49 -o release/${BINARY}-${VERSION}.${ARCH}/${BINARY_NAME} .
50 fi
52 cd release
54 # Create tar file for architecture specific binary
55 tar -czvf ${BINARY}-${VERSION}.${ARCH}.tar.gz ${BINARY}-${VERSION}.${ARCH}
57 # Create sha256sum for architecture-specific tar
58 sha256sum ${BINARY}-${VERSION}.${ARCH}.tar.gz > ${BINARY}-${VERSION}.${ARCH}.tar.gz-sha256sum.txt
60 # Create sha256sum for architecture specific binary
61 sha256sum ${BINARY}-${VERSION}.${ARCH}/${BINARY_NAME} > ${BINARY}-${VERSION}.${ARCH}-sha256sum.txt
63 cd ..
64done