From 7d0a2fe7e518726c35052c38aae3fc9b367f5fa8 Mon Sep 17 00:00:00 2001 From: Snider Date: Sun, 1 Feb 2026 10:55:57 +0000 Subject: [PATCH] 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 --- .gitignore | 1 + Taskfile.yml | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index f36a48f..bfb8938 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,7 @@ coverage.html *.cache /coverage.txt bin/ +dist/ tasks /core diff --git a/Taskfile.yml b/Taskfile.yml index 12b4872..de54895 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -1,16 +1,21 @@ 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: # --- CLI Management --- cli:build: desc: "Build core CLI to ./bin/core" cmds: - - go build -o ./bin/core . + - go build -ldflags '{{.LDFLAGS}}' -o ./bin/core . cli:install: desc: "Install core CLI to system PATH" cmds: - - go install . + - go install -ldflags '{{.LDFLAGS}}' . # --- Development --- test: