generated from permafrost-dev/go-project-template
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTaskfile.yaml
96 lines (83 loc) · 2.34 KB
/
Taskfile.yaml
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
# This file can be run with the `task` utility: https://taskfile.dev/
version: '3'
tasks:
mod:
desc: Downloads and tidy Go modules
cmds:
- go mod download
- go mod tidy
build:
deps:
- task: update-version-file
cmds:
- task: build-pg-log-analyzer
clean:
desc: Cleans up build artifacts
preconditions:
- test -d ./dist
- test -f ./dist/pg-log-analyzer
cmds:
- rm -f ./dist/pg-log-analyzer
lint:
cmds:
- task: lint-dotenv
- task: lint-pg-log-analyzer
update-version-file:
vars:
VERSION:
sh: go run tools/build-version.go
cmds:
- printf "package main\n\nvar Version = \"{{.VERSION}}\"" > ./app/version.go
lint-dotenv:
internal: true
vars:
DOTENV_FILES:
sh: find . -name ".env*" -print | sort -u | egrep -v '^./dist.*$' | tr '\n' ' '
preconditions:
- which dotenv-linter
- test -n "$(find -name '.env*')"
cmds:
- dotenv-linter {{.DOTENV_FILES}}
lint-pg-log-analyzer:
internal: true
vars:
GO_SRC_DIRS:
sh: find . -name "*.go" -printf '%h\n' | awk -F/ '{ print "./" $2 }' | sort -u | grep -v './tools' | tr '\n' ' '
preconditions:
- test -f ./.golangci.yml
- which golangci-lint
cmds:
- golangci-lint run {{.GO_SRC_DIRS}}
build-pg-log-analyzer:
desc: Builds pg-log-analyzer binary
vars:
GIT_COMMIT:
sh: git log -n 1 --format=%h
sources:
- './app/**/*.go'
- './cmd/**/*.go'
- './internal/**/*.go'
- './main.go'
generates:
- ./dist/pg-log-analyzer
cmds:
- mkdir -p ./dist
- go build -trimpath -ldflags="-s -w -X main.Version={{.VERSION}}-{{.GIT_COMMIT}}" -o dist/pg-log-analyzer .
release:
desc: Creates a new snapshot release
deps:
- task: mod
- task: lint
- task: update-version-file
preconditions:
- test -f ./.goreleaser.yaml
- which goreleaser
cmds:
- goreleaser build -f ./.goreleaser.yaml --clean --snapshot
autobuild:
interactive: true
desc: Watches for changes, automatically rebuilds the project & displays a minimal system notification
preconditions:
- which watchexec
cmds:
- watchexec --exts go --fs-events create,modify,remove -N --debounce 500 -w ./app -w ./cmd -w ./internal -- task build -f