#!/usr/bin/env sh # Build the linux lchat binary for the router box, stamped with a build id # (the git short sha, or $1) so `lchat stage`/`deploy --version` can identify and # health-check it. Prints the build id and the output path. # # ./deploy/build-linux.sh # linux/amd64, id = git short sha # ./deploy/build-linux.sh test-scroll # id = test-scroll (e.g. a canary label) # ARCH=arm64 ./deploy/build-linux.sh # linux/arm64 (self-hosters on ARM) # OS=darwin ARCH=arm64 ./deploy/build-linux.sh # macOS (the `lchat try` download) # OUT=/tmp/lchat ./deploy/build-linux.sh set -eu VER="${1:-$(git rev-parse --short HEAD)}" if [ -z "$VER" ]; then echo "build-linux: could not determine a build id (pass one as \$1)" >&2 exit 1 fi OS="${OS:-linux}" ARCH="${ARCH:-amd64}" OUT="${OUT:-lchat-$OS-$ARCH}" GOOS="$OS" GOARCH="$ARCH" CGO_ENABLED=0 \ go build -ldflags "-X main.buildVersion=${VER}" -o "$OUT" . echo "built ${VER} (${OS}/${ARCH}) -> ${OUT}"