-
Notifications
You must be signed in to change notification settings - Fork 0
/
Taskfile.yml
125 lines (106 loc) · 2.97 KB
/
Taskfile.yml
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
# https://taskfile.dev
version: '3'
vars:
PKG_NAME: github.com/comunidade-shallom/diakonos
APP_BASE_NAME: diakonos
DIR_DIST: ./bin
BUILD_DATE: '{{now | date "2006-01-02T15:04:05"}}'
APP_VERSION:
sh: git describe --dirty --always --tags
GIT_HASH:
sh: git log -n 1 --format=%h | echo "unknow"
dotenv: ['.env']
tasks:
install:
desc: Install dependencies
cmds:
- go get ./...
- go mod tidy
- go mod vendor
install:lint:
desc: Install dependencies
status:
- test -f $(go env GOPATH)/bin/golangci-lint
cmds:
- curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin
install:gofumpt:
desc: Install dependencies
status:
- test -f $(go env GOPATH)/bin/gofumpt
cmds:
- go install mvdan.cc/gofumpt@latest
setup:
desc: Setup project dependencies
deps:
- install
- install:lint
- install:gofumpt
update:
desc: Update dependencies
cmds:
- go get -u ./...
- go mod tidy
- go mod vendor
generate:
cmds:
- go generate ./...
format:
desc: Check source code
cmds:
- go fmt ./...
vet:
desc: Check source code
cmds:
- go vet ./...
check:
desc: Check source code
deps:
- format
- vet
cmds:
- golangci-lint run ./... {{.CLI_ARGS}}
clean:
desc: Remove old binaries
cmds:
- rm -rf {{.DIR_DIST}}/{{.APP_BASE_NAME}}-*
run:cli:
desc: Run CLI
cmds:
- go run ./apps/cli/ {{.CLI_ARGS}}
build:
desc: Build CLI (linux by default)
cmds:
- echo "Generating {{.BIN_NAME}}"
- "{{.EXTRA_ENVS}} go build {{.BUILDFLAGS}} {{.LDFLAGS}} -o {{.DIR_DIST}}/{{.BIN_NAME}} ./apps/{{.APP}}"
- chmod +x {{.DIR_DIST}}/{{.BIN_NAME}}
vars:
LDFLAGS: -ldflags "-X {{.PKG_NAME}}/pkg/config.commit={{.GIT_HASH}} -X {{.PKG_NAME}}/pkg/config.version={{.APP_VERSION}} -X {{.PKG_NAME}}/pkg/config.buildDate={{.BUILD_DATE}}"
APP: '{{default "cli" .APP}}'
GOOS: '{{default "linux" .GOOS}}'
GOARCH: '{{default "amd64" .GOARCH}}'
CGO_ENABLED: '{{default 0 .CGO_ENABLED}}'
BIN_NAME: '{{.APP_BASE_NAME}}-{{.APP}}-{{.GOOS}}-{{.GOARCH}}'
env:
GOOS: "{{.GOOS}}"
GOARCH: "{{.GOARCH}}"
GOARM: "{{.GOARM}}"
CGO_ENABLED: "{{.CGO_ENABLED}}"
production:linux:
desc: production build for Linux OS
cmds:
- task: build
vars:
UPX: yes
GOOS: linux
BUILDFLAGS: -a -installsuffix cgo -ldflags '-s -w -extldflags "-static"'
production:
desc: Production build for all platforms
deps: [ production:linux ]
cmds:
- cd {{.DIR_DIST}} && ls -lh | tr -s ' ' | cut -d ' ' -f 5,9-
- find -iname '{{.APP_BASE_NAME}}-*' -execdir upx {} \;
- cd {{.DIR_DIST}} && ls -lh | tr -s ' ' | cut -d ' ' -f 5,9-
release:snapshot:
desc: release snapshot mode
cmds:
- goreleaser release --snapshot --rm-dist