2022-05-11 22:47:31 +00:00
|
|
|
|
#!/bin/bash -e
|
|
|
|
|
|
|
|
|
|
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
|
|
|
. "$DIR/.common.sh"
|
|
|
|
|
|
|
|
|
|
export GOOS=linux
|
|
|
|
|
|
|
|
|
|
# Determine the correct binary file for the architecture given
|
|
|
|
|
case ${TARGETPLATFORM:-} in
|
|
|
|
|
linux/arm64)
|
|
|
|
|
export GOARCH=arm64
|
|
|
|
|
;;
|
|
|
|
|
|
|
|
|
|
linux/arm/v7)
|
|
|
|
|
export GOARCH=arm
|
|
|
|
|
;;
|
|
|
|
|
|
|
|
|
|
linux/amd64)
|
|
|
|
|
export GOARCH=amd64
|
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
|
2023-05-11 23:40:45 +00:00
|
|
|
|
echo -e "${BLUE}❯ ${CYAN}Building binaries for ${YELLOW}${GOARCH} (${TARGETPLATFORM:-})${RESET}"
|
2022-05-11 22:47:31 +00:00
|
|
|
|
|
2023-05-11 23:40:45 +00:00
|
|
|
|
# server
|
2022-05-11 22:47:31 +00:00
|
|
|
|
go build \
|
2023-05-26 01:04:43 +00:00
|
|
|
|
-tags 'json1' \
|
2023-02-24 11:21:14 +00:00
|
|
|
|
-buildvcs=false \
|
2023-07-24 04:41:46 +00:00
|
|
|
|
-ldflags "-w -s -X main.commit=${BUILD_COMMIT:-notset} -X main.version=${BUILD_VERSION}" \
|
2022-05-11 22:47:31 +00:00
|
|
|
|
-o "${1:-/dist/server}" \
|
|
|
|
|
./cmd/server
|
|
|
|
|
|
2023-05-11 23:40:45 +00:00
|
|
|
|
# ipranges
|
|
|
|
|
go build \
|
|
|
|
|
-buildvcs=false \
|
2023-07-24 04:41:46 +00:00
|
|
|
|
-ldflags "-w -s -X main.commit=${BUILD_COMMIT:-notset} -X main.version=${BUILD_VERSION}" \
|
2023-05-11 23:58:50 +00:00
|
|
|
|
-o "${2:-/dist/ipranges}" \
|
2023-05-11 23:40:45 +00:00
|
|
|
|
./cmd/ipranges
|
|
|
|
|
|
|
|
|
|
# test binaries
|
2022-05-11 22:47:31 +00:00
|
|
|
|
/dist/server --version
|
2023-05-11 23:40:45 +00:00
|
|
|
|
/dist/ipranges --version
|
2022-05-11 22:47:31 +00:00
|
|
|
|
|
2023-05-11 23:40:45 +00:00
|
|
|
|
echo -e "${BLUE}❯ ${CYAN}Build binaries complete${RESET}"
|