-
Notifications
You must be signed in to change notification settings - Fork 4
/
build-all.sh
41 lines (33 loc) · 939 Bytes
/
build-all.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
#!/bin/bash
set -e
VERSION=${1:-0.0.0}
declare -a os=("linux" "windows" "darwin")
declare -a arch=("386" "amd64" "arm" "arm64")
for (( j=0; j<${#os[@]}; j++ ));
do
GOOS="${os[$j]}"
for (( i=0; i<${#arch[@]}; i++ ));
do
GOARCH="${arch[$i]}"
EXT=""
if [ $GOOS == 'darwin' ] && [ $GOARCH == '386' ]; then
continue
fi
if [ $GOOS == 'darwin' ] && [ $GOARCH == 'arm' ]; then
continue
fi
if [ $GOOS == 'windows' ]; then
EXT=".exe"
fi
BINARY="scalr-cli_${VERSION}_${GOOS}_${GOARCH}${EXT}"
CGO_ENABLED=0 GOOS=$GOOS GOARCH=$GOARCH go build -ldflags="-s -w" -o bin/$BINARY -a -ldflags '-extldflags "-static"' .
cd bin
chmod +x $BINARY
mv $BINARY "scalr${EXT}"
PACKAGE="scalr-cli_${VERSION}_${GOOS}_${GOARCH}.zip"
zip -9 $PACKAGE "scalr${EXT}"
sha256sum $PACKAGE >> "scalr-cli_${VERSION}_SHA256SUMS"
rm "scalr${EXT}"
cd ..
done
done