feat(build): inject version from git tag at build time

- Taskfile now injects AppVersion via ldflags
- Shows git tag (e.g., v1.0.0) when built from a tag
- Shows "dev" when built from non-tagged commit
- Add dist/ to .gitignore for build artifacts

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Snider 2026-02-01 10:55:57 +00:00
parent 0072650fd9
commit 1afa35d3c6
2 changed files with 8 additions and 2 deletions

1
.gitignore vendored
View file

@ -13,6 +13,7 @@ coverage.html
*.cache *.cache
/coverage.txt /coverage.txt
bin/ bin/
dist/
tasks tasks
/core /core

View file

@ -1,16 +1,21 @@
version: '3' 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}}"
tasks: tasks:
# --- CLI Management --- # --- CLI Management ---
cli:build: cli:build:
desc: "Build core CLI to ./bin/core" desc: "Build core CLI to ./bin/core"
cmds: cmds:
- go build -o ./bin/core . - go build -ldflags '{{.LDFLAGS}}' -o ./bin/core .
cli:install: cli:install:
desc: "Install core CLI to system PATH" desc: "Install core CLI to system PATH"
cmds: cmds:
- go install . - go install -ldflags '{{.LDFLAGS}}' .
# --- Development --- # --- Development ---
test: test: