From 7eef0b18d2548c1db74550914d38e2541d6b36d7 Mon Sep 17 00:00:00 2001 From: Amolith Date: Wed, 22 Oct 2025 08:23:25 -0600 Subject: [PATCH] chore: embed version in build/install tasks (#1278) --- Taskfile.yaml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Taskfile.yaml b/Taskfile.yaml index 65a7e2d42fe8dcb307bced7c1fa9a0326b35ccc1..9e0f214fb1f7081ffb90d53e7a62eab120950b0d 100644 --- a/Taskfile.yaml +++ b/Taskfile.yaml @@ -2,6 +2,10 @@ version: "3" +vars: + VERSION: + sh: git describe --long 2>/dev/null || echo "" + env: CGO_ENABLED: 0 GOEXPERIMENT: greenteagc @@ -30,8 +34,10 @@ tasks: build: desc: Run build + vars: + LDFLAGS: '{{if .VERSION}}-ldflags="-X github.com/charmbracelet/crush/internal/version.Version={{.VERSION}}"{{end}}' cmds: - - go build . + - go build {{.LDFLAGS}} . generates: - crush @@ -59,8 +65,10 @@ tasks: install: desc: Install the application + vars: + LDFLAGS: '{{if .VERSION}}-ldflags="-X github.com/charmbracelet/crush/internal/version.Version={{.VERSION}}"{{end}}' cmds: - - go install -v . + - go install {{.LDFLAGS}} -v . profile:cpu: desc: 10s CPU profile