#!/bin/sh # Checks and builds lc-agent for all platforms in a throwaway Go container. # Output: dist/. Usage: ./build.sh (needs only Docker on the host) set -eu cd "$(dirname "$0")" VERSION="$(git describe --tags --always --dirty 2>/dev/null || echo dev)" docker run --rm -v "$PWD":/src -w /src \ -e GOMODCACHE=/src/.cache/mod -e GOCACHE=/src/.cache/build \ -e GOFLAGS=-buildvcs=false -e CGO_ENABLED=0 -e VERSION="$VERSION" \ golang:1.26-alpine sh -euc ' test -z "$(gofmt -l .)" || { gofmt -l .; echo "gofmt: Dateien nicht formatiert"; exit 1; } for os in linux windows darwin; do GOOS=$os go vet ./...; done go test ./... rm -rf dist && mkdir dist build() { GOOS=$1 GOARCH=$2 go build -trimpath -ldflags "-s -w -X main.version=$VERSION ${4:-}" -o "dist/$3" ./cmd/lc-agent; } build linux amd64 lc-agent-linux-amd64 build linux arm64 lc-agent-linux-arm64 build darwin amd64 lc-agent-macos-intel build darwin arm64 lc-agent-macos-apple build windows amd64 lc-agent.exe # No console window; for autostart (log with -log) build windows amd64 lc-agentw.exe "-H=windowsgui" cd dist && sha256sum * > SHA256SUMS ' ls -l dist