2019-10-29 20:27:08 +03:00
#!/usr/bin/env bash
set -o errexit
if [ [ -z ${ BINARY } ] ] || [ [ -z ${ VERSION } ] ] ; then
echo " Missing required env var: BINARY=X VERSION=X $( basename $0 ) "
exit 1
fi
2017-11-20 22:35:59 +03:00
2023-09-08 19:18:20 +03:00
ARCHS = (
darwin-amd64
darwin-arm64
linux-amd64
linux-arm64
linux-armv5
linux-armv6
linux-armv7
linux-ppc64le
2024-08-23 10:02:02 +03:00
linux-s390x
2023-09-08 19:18:20 +03:00
freebsd-amd64
windows-amd64
)
2019-10-29 20:27:08 +03:00
mkdir -p release
# Create architecture specific release dirs
for ARCH in " ${ ARCHS [@] } " ; do
2020-08-25 18:41:14 +03:00
mkdir -p release/${ BINARY } -${ VERSION } .${ ARCH }
2019-10-29 20:27:08 +03:00
GO_OS = $( echo $ARCH | awk -F- '{print $1}' )
GO_ARCH = $( echo $ARCH | awk -F- '{print $2}' )
# Create architecture specific binaries
2023-09-08 19:18:20 +03:00
if [ [ ${ GO_ARCH } = = armv* ] ] ; then
GO_ARM = $( echo $GO_ARCH | awk -Fv '{print $2}' )
2024-07-14 23:09:17 +03:00
GO111MODULE = on GOOS = ${ GO_OS } GOARCH = arm GOARM = ${ GO_ARM } CGO_ENABLED = 0 go build \
-ldflags= " -X github.com/oauth2-proxy/oauth2-proxy/v7/pkg/version.VERSION= ${ VERSION } " \
2021-02-07 02:19:33 +03:00
-o release/${ BINARY } -${ VERSION } .${ ARCH } /${ BINARY } .
2019-10-29 20:27:08 +03:00
else
2024-07-14 23:09:17 +03:00
GO111MODULE = on GOOS = ${ GO_OS } GOARCH = ${ GO_ARCH } CGO_ENABLED = 0 go build \
-ldflags= " -X github.com/oauth2-proxy/oauth2-proxy/v7/pkg/version.VERSION= ${ VERSION } " \
2021-02-07 02:19:33 +03:00
-o release/${ BINARY } -${ VERSION } .${ ARCH } /${ BINARY } .
2019-10-29 20:27:08 +03:00
fi
cd release
# Create tar file for architecture specific binary
2020-08-25 18:41:14 +03:00
tar -czvf ${ BINARY } -${ VERSION } .${ ARCH } .tar.gz ${ BINARY } -${ VERSION } .${ ARCH }
2019-10-29 20:27:08 +03:00
2024-01-20 22:18:54 +03:00
# Create sha256sum for architecture-specific tar
sha256sum ${ BINARY } -${ VERSION } .${ ARCH } .tar.gz > ${ BINARY } -${ VERSION } .${ ARCH } .tar.gz-sha256sum.txt
# Create sha256sum for architecture specific binary
sha256sum ${ BINARY } -${ VERSION } .${ ARCH } /${ BINARY } > ${ BINARY } -${ VERSION } .${ ARCH } -sha256sum.txt
2019-10-29 20:27:08 +03:00
cd ..
2017-11-20 22:35:59 +03:00
done