diff --git a/.gitignore b/.gitignore index 91f70e5..9bf96a5 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,5 @@ config.yaml docker-compose.yml notes.md roadmap.md + +binaries/ diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ca921a6..c3e46c6 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -293,6 +293,14 @@ git push origin main --tags ``` 7. Publish release notes on GitHub against the new tag +8. Build release binaries and attach them to the GitHub release: + +```bash +./build-release.sh +``` + +The script reads the version from the git tag automatically. Upload the +resulting files from `binaries/` as release assets on GitHub. ## Recognition diff --git a/build-release.sh b/build-release.sh new file mode 100755 index 0000000..518dbb8 --- /dev/null +++ b/build-release.sh @@ -0,0 +1,50 @@ +#!/usr/bin/env bash +# Copyright 2026 Beacon Contributors +# SPDX-License-Identifier: AGPL-3.0-or-later +# +# build-release.sh — cross-compile Beacon for all supported platforms. +# Output binaries are written to ./binaries/. + +set -euo pipefail + +PACKAGE="./cmd/beacon" +OUTPUT_DIR="binaries" +VERSION=$(git describe --tags --always --dirty 2>/dev/null || echo "dev") + +mkdir -p "$OUTPUT_DIR" + +targets=( + "linux/amd64/" + "linux/arm64/" + "linux/arm/7" + "darwin/amd64/" + "darwin/arm64/" + "windows/amd64/" +) + +echo "Building Beacon $VERSION" + +for target in "${targets[@]}"; do + GOOS=$(echo "$target" | cut -d/ -f1) + GOARCH=$(echo "$target" | cut -d/ -f2) + GOARM=$(echo "$target" | cut -d/ -f3) + + NAME="beacon-${VERSION}-${GOOS}-${GOARCH}" + if [[ -n "$GOARM" ]]; then + NAME="${NAME}v${GOARM}" + fi + + if [[ "$GOOS" == "windows" ]]; then + NAME="${NAME}.exe" + fi + + printf " %-40s" "${GOOS}/${GOARCH}${GOARM:+v$GOARM}" + + env GOOS="$GOOS" GOARCH="$GOARCH" ${GOARM:+GOARM="$GOARM"} \ + go build -trimpath -ldflags="-s -w -X main.version=${VERSION}" \ + -o "${OUTPUT_DIR}/${NAME}" "$PACKAGE" + + echo "→ ${OUTPUT_DIR}/${NAME}" +done + +echo "Done." diff --git a/cmd/beacon/main.go b/cmd/beacon/main.go index abffeaa..a8a2323 100644 --- a/cmd/beacon/main.go +++ b/cmd/beacon/main.go @@ -33,6 +33,10 @@ import ( "github.com/joho/godotenv" ) +// version is set at build time via -ldflags "-X main.version=vX.Y.Z". +// Falls back to "dev" when built without the flag. +var version = "dev" + // @title MeshCore Beacon API // @version 1.4.0 // @description MeshCore network observation backend. Ingests LoRa packets from MQTT brokers, stores in PostgreSQL, and streams live events via WebSocket. @@ -67,6 +71,7 @@ import ( // @tag.name Stats // @tag.description Network statistics and time series func main() { + log.Printf("beacon version %s", version) _ = godotenv.Load() addr := os.Getenv("LISTEN_ADDR") if addr == "" {