build: add release build tasks with linker flags (#239)

* fix(container): prevent data race in State.Get and State.All

Return copies of Container structs instead of pointers to the map
entries. This prevents data races when containers are modified
concurrently by waitForExit and Stop.

Fixes #76

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* fix(updater): resolve PkgVersion duplicate declaration

Remove var PkgVersion from updater.go since go generate creates
const PkgVersion in version.go. Track version.go in git to ensure
builds work without running go generate first.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* build: add release build tasks with linker flags for smaller binary

Add -s -w linker flags to strip debug info and symbol table:
- cli:build:release - release build to ./bin/core
- cli:install:release - release install to system PATH

Binary size reduced from 19MB to 14MB (26% reduction).

Fixes #226

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Snider 2026-02-02 04:22:00 +00:00 committed by GitHub
parent 234bfd17f8
commit 549e0c6035

View file

@ -3,20 +3,35 @@ version: '3'
vars:
VERSION:
sh: git describe --tags --exact-match 2>/dev/null || echo "dev"
LDFLAGS: "-X github.com/host-uk/core/pkg/cli.AppVersion={{.VERSION}}"
# Base ldflags for version injection
LDFLAGS_BASE: "-X github.com/host-uk/core/pkg/cli.AppVersion={{.VERSION}}"
# Development build: includes debug info
LDFLAGS: "{{.LDFLAGS_BASE}}"
# Release build: strips debug info and symbol table for smaller binary
LDFLAGS_RELEASE: "-s -w {{.LDFLAGS_BASE}}"
tasks:
# --- CLI Management ---
cli:build:
desc: "Build core CLI to ./bin/core"
desc: "Build core CLI to ./bin/core (dev build with debug info)"
cmds:
- go build -ldflags '{{.LDFLAGS}}' -o ./bin/core .
cli:build:release:
desc: "Build core CLI for release (smaller binary, no debug info)"
cmds:
- go build -ldflags '{{.LDFLAGS_RELEASE}}' -o ./bin/core .
cli:install:
desc: "Install core CLI to system PATH"
desc: "Install core CLI to system PATH (dev build)"
cmds:
- go install -ldflags '{{.LDFLAGS}}' .
cli:install:release:
desc: "Install core CLI for release (smaller binary)"
cmds:
- go install -ldflags '{{.LDFLAGS_RELEASE}}' .
# --- Development ---
test:
desc: "Run all tests"