roulette/build.sh

26 lines
647 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"
)
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'
if [ "${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