| 1 | #!/usr/bin/env bash |
| 2 | |
| 3 | set -euo pipefail |
| 4 | root=$(cd "$(dirname "$0")/.." && pwd) |
| 5 | [[ $# == 3 && $3 == /* ]] || { echo 'Usage: build-tailnet.sh OS ARCH /absolute/output' >&2; exit 2; } |
| 6 | os=$1 arch=$2 destination=$3 |
| 7 | case "$os/$arch" in linux/amd64|linux/arm64|darwin/arm64|windows/amd64) ;; *) exit 2 ;; esac |
| 8 | mkdir -p "$(dirname "$destination")" |
| 9 | cd "$root/tools/tailnet" |
| 10 | GOOS=$os GOARCH=$arch CGO_ENABLED=0 GOFLAGS= go build -trimpath -ldflags '-s -w' -o "$destination" . |
| 11 | if [[ $os == darwin ]]; then codesign -f -s "${CAGE_SIGNING_IDENTITY:--}" "$destination"; fi |