1# https://taskfile.dev
2
3version: "3"
4
5vars:
6 VERSION:
7 sh: git describe --long 2>/dev/null || echo ""
8
9env:
10 CGO_ENABLED: 0
11 GOEXPERIMENT: greenteagc
12
13tasks:
14 lint:install:
15 desc: Install golangci-lint
16 cmds:
17 - go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest
18 env:
19 GOTOOLCHAIN: go1.25.0
20
21 lint:
22 desc: Run base linters
23 cmds:
24 - golangci-lint run --path-mode=abs --config=".golangci.yml" --timeout=5m
25 env:
26 GOEXPERIMENT: null
27
28 lint:fix:
29 desc: Run base linters and fix issues
30 cmds:
31 - golangci-lint run --path-mode=abs --config=".golangci.yml" --timeout=5m --fix
32 env:
33 GOEXPERIMENT: null
34
35 build:
36 desc: Run build
37 vars:
38 LDFLAGS: '{{if .VERSION}}-ldflags="-X git.secluded.site/crush/internal/version.Version={{.VERSION}}"{{end}}'
39 cmds:
40 - go build {{.LDFLAGS}} .
41 generates:
42 - crush
43
44 run:
45 desc: Run build
46 cmds:
47 - go run . {{.CLI_ARGS}}
48
49 test:
50 desc: Run tests
51 cmds:
52 - go test ./... {{.CLI_ARGS}}
53
54 fmt:
55 desc: Run gofumpt
56 cmds:
57 - gofumpt -w .
58
59 dev:
60 desc: Run with profiling enabled
61 env:
62 CRUSH_PROFILE: true
63 cmds:
64 - go run .
65
66 install:
67 desc: Install the application
68 vars:
69 LDFLAGS: '{{if .VERSION}}-ldflags="-X git.secluded.site/crush/internal/version.Version={{.VERSION}}"{{end}}'
70 cmds:
71 - go install {{.LDFLAGS}} -v .
72
73 profile:cpu:
74 desc: 10s CPU profile
75 cmds:
76 - go tool pprof -http :6061 'http://localhost:6060/debug/pprof/profile?seconds=10'
77
78 profile:heap:
79 desc: Heap profile
80 cmds:
81 - go tool pprof -http :6061 'http://localhost:6060/debug/pprof/heap'
82
83 profile:allocs:
84 desc: Allocations profile
85 cmds:
86 - go tool pprof -http :6061 'http://localhost:6060/debug/pprof/allocs'
87
88 schema:
89 desc: Generate JSON schema for configuration
90 cmds:
91 - go run main.go schema > schema.json
92 - echo "Generated schema.json"
93 generates:
94 - schema.json
95
96 release:
97 desc: Create and push a new tag following semver
98 vars:
99 NEXT:
100 sh: svu next --always || go run github.com/caarlos0/svu/v3@latest next --always
101 prompt: "This will release {{.NEXT}}. Continue?"
102 preconditions:
103 - sh: '[ $(git symbolic-ref --short HEAD) = "main" ]'
104 msg: Not on main branch
105 - sh: "[ $(git status --porcelain=2 | wc -l) = 0 ]"
106 msg: "Git is dirty"
107 cmds:
108 - task: fetch-tags
109 - git commit --allow-empty -m "{{.NEXT}}"
110 - git tag --annotate --sign -m "{{.NEXT}}" {{.NEXT}} {{.CLI_ARGS}}
111 - echo "Pushing {{.NEXT}}..."
112 - git push origin main --follow-tags
113
114 fetch-tags:
115 cmds:
116 - git tag -d nightly || true
117 - git fetch --tags
118
119 release:fork:
120 desc: Create and push a fork release tag
121 vars:
122 UPSTREAM_VERSION:
123 sh: git describe --tags --abbrev=0 upstream/main 2>/dev/null || echo "v0.0.0"
124 EXISTING_FORK_TAGS:
125 sh: git tag -l "{{.UPSTREAM_VERSION}}-fork.*" | wc -l
126 NEXT_NUM:
127 sh: echo $(({{.EXISTING_FORK_TAGS}} + 1))
128 TAG: "{{.UPSTREAM_VERSION}}-fork.{{.NEXT_NUM}}"
129 prompt: "Create fork release {{.TAG}}?"
130 preconditions:
131 - sh: '[ $(git symbolic-ref --short HEAD) = "dev" ]'
132 msg: Not on dev branch
133 - sh: "[ $(git status --porcelain=2 | wc -l) = 0 ]"
134 msg: "Git is dirty"
135 cmds:
136 - git tag -d nightly || true
137 - git fetch upstream --tags
138 - git tag -a {{.TAG}}
139 - git push soft {{.TAG}}
140 - echo "Released {{.TAG}}"
141 - go list -m git.secluded.site/crush@{{.TAG}} > /dev/null
142 - echo "Module proxy notified"