forked from aurora-develop/aurora
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
40 lines (34 loc) · 918 Bytes
/
build.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
#!/bin/bash
export GOPROXY=https://goproxy.io
go get
export CGO_ENABLED=0
PKG=aurora
targets=(
"windows/amd64"
"linux/amd64"
"darwin/amd64"
"windows/386"
"linux/386"
"darwin/386"
"linux/arm"
"linux/arm64"
)
upxPath=$(command -v upx)
for target in "${targets[@]}"; do
GOOS=${target%/*}
GOARCH=${target#*/}
outputDir="bin/${GOOS}_${GOARCH}"
outputFile="${outputDir}/${PKG}"
archiveName="${PKG}-${GOOS}-${GOARCH}.tar.gz"
mkdir -p $(dirname ${outputFile})
GOOS=$GOOS GOARCH=$GOARCH go build -ldflags="-s -w -extldflags '-static'" -o ${outputFile} *.go
if [ -n "$upxPath" ]; then
$upxPath -9 ${outputFile}
fi
# Archive the binary
if [ "$GOOS" = "windows" ]; then
zip -j "${outputDir}/${PKG}-${GOOS}-${GOARCH}.zip" "${outputFile}"
else
tar -C "${outputDir}" -czf "${outputDir}/${archiveName}" "${PKG}"
fi
done