-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTaskfile.dist.yaml
More file actions
258 lines (220 loc) · 6.71 KB
/
Copy pathTaskfile.dist.yaml
File metadata and controls
258 lines (220 loc) · 6.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
version: "3"
silent: true
env:
CGO_ENABLED: "0"
GO111MODULE: "on"
vars:
version: '{{.version | default "dev"}}'
tasks:
sign:
desc: 'Sign last version tag + origin/main and push signatures. Important vars: "refs".'
cmds:
- git fetch --tags -f
- git signatures pull {{.CLI_ARGS}}
- |
for ref in {{.refs | default "$(git tag --sort=v:refname | tail -n1) origin/main"}}; do
echo Signing $ref...
git signatures add {{.CLI_ARGS}} $ref
git signatures show {{.CLI_ARGS}} $ref
done
- git signatures push {{.CLI_ARGS}}
deps:install:
desc: "Install all dependencies."
deps:
- deps:install:golangci-lint
- deps:install:gofumpt
deps:install:golangci-lint:
desc: "Install golangci-lint binary."
cmd: go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@{{.golangcilintVersion | default "v2.13.2"}}
deps:install:gofumpt:
desc: "Install gofumpt binary."
cmd: go install mvdan.cc/gofumpt@v0.7.0
lint:
desc: "Run all linters"
cmds:
- task: lint:golangci-lint
- task: lint:prettier
lint:golangci-lint:
desc: "Lint with golangci-lint"
cmd: golangci-lint run -v --timeout 5m --config .golangci.yaml ./...
lint:prettier:
desc: "Lint with prettier"
cmds:
- docker run --rm -v $(pwd):/work tmknom/prettier -c "**/*.yaml" "**/*.yml"
format:
desc: "Run all formatters"
deps:
- format:gci
- format:gofumpt
- format:prettier
format:gofumpt:
desc: 'Format code with gofumpt. Important vars: "paths".'
cmd: gofumpt -extra -w {{.CLI_ARGS}} {{.paths | default "cmd/ internal/"}}
format:gci:
desc: 'Format code with gci. Important vars: "paths".'
cmds:
- gci write -s Standard -s Default -s "Prefix(trx)" {{.paths | default "cmd/ internal/"}}
format:prettier:
desc: "Format yaml files with prettier."
cmds:
- docker run --rm -v $(pwd):/work tmknom/prettier -w "**/*.yaml" "**/*.yml"
test:
desc: "Run unit tests"
cmd: go test -v ./...
build:dev:
desc: "Build all trx dev binaries."
cmds:
- task: build:dev:linux:amd64
- task: build:dev:linux:arm64
- task: build:dev:darwin:amd64
- task: build:dev:darwin:arm64
- task: build:dev:windows:amd64
build:dist:
desc: "Build all trx release binaries."
cmds:
- task: build:dist:linux:amd64
- task: build:dist:linux:arm64
- task: build:dist:darwin:amd64
- task: build:dist:darwin:arm64
- task: build:dist:windows:amd64
build:dev:linux:amd64:
desc: "Build trx dev binary for linux/amd64."
cmds:
- task: _build:go
vars:
targetOS: "linux"
targetArch: "amd64"
outputDir: "{{.outputDir}}"
build:dev:linux:arm64:
desc: "Build trx dev binary for linux/arm64."
cmds:
- task: _build:go
vars:
targetOS: "linux"
targetArch: "arm64"
outputDir: "{{.outputDir}}"
build:dev:darwin:amd64:
desc: "Build trx dev binary for darwin/amd64."
cmds:
- task: _build:go
vars:
targetOS: "darwin"
targetArch: "amd64"
outputDir: "{{.outputDir}}"
build:dev:darwin:arm64:
desc: "Build trx dev binary for darwin/arm64."
cmds:
- task: _build:go
vars:
targetOS: "darwin"
targetArch: "arm64"
outputDir: "{{.outputDir}}"
build:dev:windows:amd64:
desc: "Build trx dev binary for windows/amd64."
cmds:
- task: _build:go
vars:
targetOS: "windows"
targetArch: "amd64"
outputDir: "{{.outputDir}}"
build:dist:linux:amd64:
desc: "Build trx release binary for linux/amd64."
cmds:
- task: _build:go
vars:
targetOS: "linux"
targetArch: "amd64"
outputDir: "dist/{{.version}}/linux-amd64/bin/"
build:dist:linux:arm64:
desc: "Build trx release binary for linux/arm64."
cmds:
- task: _build:go
vars:
targetOS: "linux"
targetArch: "arm64"
outputDir: "dist/{{.version}}/linux-arm64/bin/"
build:dist:darwin:amd64:
desc: "Build trx release binary for darwin/amd64."
cmds:
- task: _build:go
vars:
targetOS: "darwin"
targetArch: "amd64"
outputDir: "dist/{{.version}}/darwin-amd64/bin/"
build:dist:darwin:arm64:
desc: "Build trx release binary for darwin/arm64."
cmds:
- task: _build:go
vars:
targetOS: "darwin"
targetArch: "arm64"
outputDir: "dist/{{.version}}/darwin-arm64/bin/"
build:dist:windows:amd64:
desc: "Build trx release binary for windows/amd64."
cmds:
- task: _build:go
vars:
targetOS: "windows"
targetArch: "amd64"
outputDir: "dist/{{.version}}/windows-amd64/bin/"
_build:go:
internal: true
cmds:
- |
go build -o {{.outputDir | default (printf "bin/%s/%s-%s" .version .targetOS .targetArch)}}/trx{{if (eq .targetOS "windows")}}.exe{{end}} \
{{.extraGoBuildArgs}} {{.CLI_ARGS}} ./cmd/trx
env:
GOOS: "{{.targetOS}}"
GOARCH: "{{.targetArch}}"
build:
desc: "Build trx dev binary."
run: once
cmds:
- task: build:dev:{{OS}}:{{ARCH}}
vars:
outputDir: '{{.outputDir | default "./bin"}}'
extraGoBuildArgs: "{{.extraGoBuildArgs}}"
_image:build:
cmds:
- docker build {{.CLI_ARGS}} -f "{{.dfilePath}}" -t "{{.imageName}}" "{{.context | default "."}}"
image:build:builder:
desc: 'Build main builder image. Important vars: "imageName".'
cmds:
- task: _image:build
vars:
dfilePath: scripts/builder/Dockerfile
imageName:
sh: "echo ghcr.io/flant/trx/builder:$(git rev-parse HEAD)"
_image:push:
cmds:
- docker push {{.CLI_ARGS}} "{{.imageName}}"
image:publish:builder:
desc: 'Build and publish main builder image. Important vars: "imageName".'
deps:
- image:build:builder
cmds:
- task: _image:push
vars:
imageName:
sh: "echo ghcr.io/flant/trx/builder:$(git rev-parse HEAD)"
clean:
desc: "Clean all temporary files and build artifacts."
deps:
- clean:binaries
clean:binaries:
desc: "Clean all built binaries."
deps:
- clean:binaries:dev
- clean:binaries:dist
clean:binaries:dev:
desc: "Clean built dev binaries."
cmds:
- rm -rf ./bin
clean:binaries:dist:
desc: "Clean built release binaries."
cmds:
- rm -rf ./dist
verify:dist:binaries:
desc: "Verify that the distributable binaries are built and have correct platform/arch."
cmds:
- ./scripts/verify-dist-binaries.sh {{.version}}