on main help sign in
chore: embed version in build/install tasks (#1278)
7eef0b1Amolith
Taskfile.yaml+10−2
@@ -2,6 +2,10 @@
2
2
3version: "3"
3version: "3"
4
4
5+vars:
6+ VERSION:
7+ sh: git describe --long 2>/dev/null || echo ""
8+
5env:
9env:
6 CGO_ENABLED: 0
10 CGO_ENABLED: 0
7 GOEXPERIMENT: greenteagc
11 GOEXPERIMENT: greenteagc
@@ -30,8 +34,10 @@ tasks:
30
34
31 build:
35 build:
32 desc: Run build
36 desc: Run build
37+ vars:
38+ LDFLAGS: '{{if .VERSION}}-ldflags="-X github.com/charmbracelet/crush/internal/version.Version={{.VERSION}}"{{end}}'
33 cmds:
39 cmds:
34− - go build .
40+ - go build {{.LDFLAGS}} .
35 generates:
41 generates:
36 - crush
42 - crush
37
43
@@ -59,8 +65,10 @@ tasks:
59
65
60 install:
66 install:
61 desc: Install the application
67 desc: Install the application
68+ vars:
69+ LDFLAGS: '{{if .VERSION}}-ldflags="-X github.com/charmbracelet/crush/internal/version.Version={{.VERSION}}"{{end}}'
62 cmds:
70 cmds:
63− - go install -v .
71+ - go install {{.LDFLAGS}} -v .
64
72
65 profile:cpu:
73 profile:cpu:
66 desc: 10s CPU profile
74 desc: 10s CPU profile