-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.sh
29 lines (21 loc) · 795 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
#!/bin/bash
distPath="./bin"
mkdir -p ${distPath}
platforms=("linux/amd64" "linux/arm64" "windows/amd64" "darwin/amd64" "darwin/arm64")
export CGO_ENABLED=0
for platform in "${platforms[@]}"; do
operationalSystem=${platform%/*}
isa=${platform#*/}
binaryName="poc-${operationalSystem}-${isa}"
if [ "${operationalSystem}" == "windows" ]; then
binaryName+=".exe"
fi
echo "Building for: ${operationalSystem}/${isa}"
if ! GOOS="${operationalSystem}" GOARCH="${isa}" go build -o "${distPath}/${binaryName}" ./main.go; then
echo "An error has occurred! Aborting the script execution..."
exit 1
fi
zip -j "${distPath}/${binaryName}.zip" "${distPath}/${binaryName}"
rm -f "${distPath}/${binaryName}"
done
echo "Building completed!"