on main help sign in
chore: embed version in build/install tasks (#1278)
commit7eef0b18d2548c1db74550914d38e2541d6b36d7 authorAmolith <amolith@secluded.site> dateWed 22 Oct 2025, 08:23 (1 year ago) parent23417aa
1 file changed+10−2
Taskfile.yaml+10−2
Taskfile.yaml+10−2
@@ -2,6 +2,10 @@
22
33version: "3"
44
5+vars:
6+ VERSION:
7+ sh: git describe --long 2>/dev/null || echo ""
8+
59env:
610 CGO_ENABLED: 0
711 GOEXPERIMENT: greenteagc
@@ -30,8 +34,10 @@ tasks:
3034
3135 build:
3236 desc: Run build
37+ vars:
38+ LDFLAGS: '{{if .VERSION}}-ldflags="-X github.com/charmbracelet/crush/internal/version.Version={{.VERSION}}"{{end}}'
3339 cmds:
34− - go build .
40+ - go build {{.LDFLAGS}} .
3541 generates:
3642 - crush
3743
@@ -59,8 +65,10 @@ tasks:
5965
6066 install:
6167 desc: Install the application
68+ vars:
69+ LDFLAGS: '{{if .VERSION}}-ldflags="-X github.com/charmbracelet/crush/internal/version.Version={{.VERSION}}"{{end}}'
6270 cmds:
63− - go install -v .
71+ - go install {{.LDFLAGS}} -v .
6472
6573 profile:cpu:
6674 desc: 10s CPU profile