32 lines
701 B
Bash
Executable file
32 lines
701 B
Bash
Executable file
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
DIST_DIR="${ROOT_DIR}/dist"
|
|
|
|
mkdir -p "${DIST_DIR}"
|
|
: "${GOCACHE:=/tmp/go-build}"
|
|
mkdir -p "${GOCACHE}"
|
|
|
|
TARGETS=(
|
|
"darwin amd64"
|
|
"darwin arm64"
|
|
"linux amd64"
|
|
"linux arm64"
|
|
"windows amd64"
|
|
)
|
|
|
|
for target in "${TARGETS[@]}"; do
|
|
read -r goos goarch <<<"${target}"
|
|
|
|
ext=""
|
|
if [[ "${goos}" == "windows" ]]; then
|
|
ext=".exe"
|
|
fi
|
|
|
|
output="${DIST_DIR}/ztorrent-${goos}-${goarch}${ext}"
|
|
echo "Building ${output}"
|
|
GOCACHE="${GOCACHE}" CGO_ENABLED=0 GOOS="${goos}" GOARCH="${goarch}" go build -o "${output}" ./cmd/torrent-client
|
|
done
|
|
|
|
echo "Build complete. Artifacts are in ${DIST_DIR}"
|