From f49155745a4c92855a1966ab0dc07b2c839c814e Mon Sep 17 00:00:00 2001 From: Snider Date: Mon, 2 Feb 2026 04:20:26 +0000 Subject: [PATCH] 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 --- Taskfile.yml | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/Taskfile.yml b/Taskfile.yml index de548953..d4379901 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -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"