forked from oauth2-proxy/oauth2-proxy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dist.sh
executable file
·56 lines (44 loc) · 1.56 KB
/
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/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
ARCHS=(
darwin-amd64
darwin-arm64
linux-amd64
linux-arm64
linux-armv5
linux-armv6
linux-armv7
linux-ppc64le
freebsd-amd64
windows-amd64
)
mkdir -p release
# Create architecture specific release dirs
for ARCH in "${ARCHS[@]}"; do
mkdir -p release/${BINARY}-${VERSION}.${ARCH}
GO_OS=$(echo $ARCH | awk -F- '{print $1}')
GO_ARCH=$(echo $ARCH | awk -F- '{print $2}')
# Create architecture specific binaries
if [[ ${GO_ARCH} == armv* ]]; then
GO_ARM=$(echo $GO_ARCH | awk -Fv '{print $2}')
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}" \
-o release/${BINARY}-${VERSION}.${ARCH}/${BINARY} .
else
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}" \
-o release/${BINARY}-${VERSION}.${ARCH}/${BINARY} .
fi
cd release
# Create tar file for architecture specific binary
tar -czvf ${BINARY}-${VERSION}.${ARCH}.tar.gz ${BINARY}-${VERSION}.${ARCH}
# 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
cd ..
done