roulette/build.sh

30 lines
745 B
Bash
Raw Normal View History

2022-09-08 15:12:06 +00:00
#!/usr/bin/env bash
package_name="roulette"
mkdir -p builds
platforms=(
"darwin/amd64"
"darwin/arm64"
"linux/386"
"linux/amd64"
"linux/arm"
"linux/arm64"
2022-10-23 21:49:32 +00:00
"windows/386"
"windows/amd64"
2022-09-08 15:12:06 +00:00
)
for platform in "${platforms[@]}"; do
IFS=" " read -r -a platform_split <<< "${platform//\// }"
2022-09-08 15:12:06 +00:00
GOOS="${platform_split[0]}"
GOARCH="${platform_split[1]}"
output_name="${package_name}-${GOOS}-${GOARCH}"
ld_flags='-s -w'
2022-10-23 21:49:32 +00:00
if [ "${GOOS}" == "windows" ]; then
output_name+=".exe"
elif [ "${GOOS}" == "linux" ] && [ "${GOARCH}" == "amd64" ]; then
2022-09-08 15:12:06 +00:00
ld_flags+=' -linkmode external -extldflags "-static"'
fi
env GOOS="${GOOS}" GOARCH="${GOARCH}" CC="musl-gcc" go build -ldflags "${ld_flags}" -o "builds/${output_name}"
done