Files
docker-updater/build.sh
2026-02-08 22:29:45 +01:00

55 lines
1.2 KiB
Bash
Executable File

#!/bin/bash
TARGET_CURRENT=true
usage() {
echo "Usage: $0 [OPTIONS]"
echo "Options:"
echo " --all-target Build for all target available"
}
# Function to handle options and arguments
handle_options() {
while [ $# -gt 0 ]; do
case $1 in
--all-target)
TARGET_CURRENT=false
;;
*)
echo "Invalid option: $1" >&2
usage
exit 1
;;
esac
shift
done
}
# Main script execution
handle_options "$@"
if [ ! -d "./build" ]; then
mkdir ./build
fi
if [ "$TARGET_CURRENT" == "true" ]; then
GOOS=$(go env GOOS)
GOARCH=$(go env GOARCH)
echo "* Compiling for $GOOS/$GOARCH..."
CGO_ENABLED=0 GOOS=$GOOS GOARCH=$GOARCH GORISCV64=rva22u64 GOAMD64=v3 GOARM64=v8.2 go build -o build/dockerupdater -a
exit 0
fi
platforms=("linux/amd64" "linux/arm64" "linux/riscv64" "linux/ppc64le" "windows/amd64")
for platform in "${platforms[@]}"; do
echo "* Compiling for $platform..."
platform_split=(${platform//\// })
CGO_ENABLED=0 GOOS=${platform_split[0]} GOARCH=${platform_split[1]} GORISCV64=rva22u64 GOAMD64=v3 GOARM64=v8.2 go build -o build/dockerupdater${platform_split[0]}_${platform_split[1]} -a
done