Download this file
| 1 | #!/usr/bin/env sh |
| 2 | # Build the linux lchat binary for the router box, stamped with a build id |
| 3 | # (the git short sha, or $1) so `lchat stage`/`deploy --version` can identify and |
| 4 | # health-check it. Prints the build id and the output path. |
| 5 | # |
| 6 | # ./deploy/build-linux.sh # linux/amd64, id = git short sha |
| 7 | # ./deploy/build-linux.sh test-scroll # id = test-scroll (e.g. a canary label) |
| 8 | # ARCH=arm64 ./deploy/build-linux.sh # linux/arm64 (self-hosters on ARM) |
| 9 | # OS=darwin ARCH=arm64 ./deploy/build-linux.sh # macOS (the `lchat try` download) |
| 10 | # OUT=/tmp/lchat ./deploy/build-linux.sh |
| 11 | set -eu |
| 12 | |
| 13 | VER="${1:-$(git rev-parse --short HEAD)}" |
| 14 | if [ -z "$VER" ]; then |
| 15 | echo "build-linux: could not determine a build id (pass one as \$1)" >&2 |
| 16 | exit 1 |
| 17 | fi |
| 18 | OS="${OS:-linux}" |
| 19 | ARCH="${ARCH:-amd64}" |
| 20 | OUT="${OUT:-lchat-$OS-$ARCH}" |
| 21 | |
| 22 | GOOS="$OS" GOARCH="$ARCH" CGO_ENABLED=0 \ |
| 23 | go build -ldflags "-X main.buildVersion=${VER}" -o "$OUT" . |
| 24 | |
| 25 | echo "built ${VER} (${OS}/${ARCH}) -> ${OUT}" |
| 26 | |