-
Notifications
You must be signed in to change notification settings - Fork 1
/
Taskfile.yml
138 lines (122 loc) · 3.55 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
126
127
128
129
130
131
132
133
134
135
136
137
138
# https://taskfile.dev
version: '3'
vars:
GOPROXY: 'https://goproxy.cn,direct'
GOSUMDB: sum.golang.google.cn
VERSION_PKG: github.com/ysicing/tiga/common
ROOT_DIR: $(pwd)
BUILD_DIR: $(pwd)/_output
BIN_DIR: $(pwd)/bin
BUILD_RELEASE: v$(cat VERSION || echo "0.0.1")
BUILD_DATE: $(date +%Y%m%d)
GIT_BRANCH: $(git branch -r --contains | head -1 | sed -E -e "s%(HEAD ->|origin|upstream)/?%%g" | xargs)
GIT_COMMIT: $(git rev-parse --short HEAD || echo "abcdefgh")
LOCAL_OS: $(go version | awk '{print $NF}')
GOOS: $(go env GOOS)
GOARCH: $(go env GOARCH)
LDFLAGS: "-w -s \
-X '{{.VERSION_PKG}}.Version={{.BUILD_RELEASE}}' \
-X '{{.VERSION_PKG}}.BuildDate={{.BUILD_DATE}}' \
-X '{{.VERSION_PKG}}.GitCommitHash={{.GIT_COMMIT}}' \
-X 'k8s.io/client-go/pkg/version.gitVersion={{.BUILD_RELEASE}}' \
-X 'k8s.io/client-go/pkg/version.gitCommit={{.GIT_COMMIT}}' \
-X 'k8s.io/client-go/pkg/version.gitTreeState=dirty' \
-X 'k8s.io/client-go/pkg/version.buildDate={{.BUILD_DATE}}' \
-X 'k8s.io/client-go/pkg/version.gitMajor=1' \
-X 'k8s.io/client-go/pkg/version.gitMinor=24' \
-X 'k8s.io/component-base/version.gitVersion={{.BUILD_RELEASE}}' \
-X 'k8s.io/component-base/version.gitCommit={{.GIT_COMMIT}}' \
-X 'k8s.io/component-base/version.gitTreeState=dirty' \
-X 'k8s.io/component-base/version.gitMajor=1' \
-X 'k8s.io/component-base/version.gitMinor=24' \
-X 'k8s.io/component-base/version.buildDate={{.BUILD_DATE}}'"
tasks:
gencopyright:
desc: generate copyright
cmds:
- go install github.com/google/addlicense@latest
- hack/scripts/gencopyright.sh
godoc:
desc: update docs
deps:
- gomod
- generate
cmds:
- rm -rf ./docs/*.md
- go run ./docs/docs.go
- cp -a README.md docs/index.md
gomod:
desc: update go mod
cmds:
- go mod tidy
gofmt:
desc: gofmt code
cmds:
- go install golang.org/x/tools/cmd/goimports@latest
- gofmt -s -w .
- goimports -w .
golint:
desc: golint code
cmds:
- go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
- golangci-lint run -v ./...
lint:
desc: lint code
deps:
- generate
cmds:
- task: golint
- task: gofmt
fmt:
desc: full fmt code
cmds:
- task: gomod
- task: gencopyright
- task: lint
generate:
desc: generate code
cmds:
- go generate ./...
linux:
desc: build linux for remote test
deps:
- gomod
- generate
vars:
GOOS: linux
GOARCH: amd64
cmds:
- go install github.com/mitchellh/gox@latest
- gox -os={{.GOOS}} -arch={{.GOARCH}} -output="{{.BUILD_DIR}}/tiga_{{.GOOS}}_{{.GOARCH}}" -ldflags "{{.LDFLAGS}}"
# status:
# - test -f {{.BUILD_DIR}}/tiga_{{.GOOS}}_{{.GOARCH}}
local:
desc: build local for test
aliases:
- build
deps:
- gomod
- generate
cmds:
- go install github.com/mitchellh/gox@latest
- gox -os={{.GOOS}} -arch={{.GOARCH}} -output="{{.BUILD_DIR}}/tiga_{{.GOOS}}_{{.GOARCH}}" -ldflags "{{.LDFLAGS}}"
# status:
# - test -f {{.BUILD_DIR}}/tiga_{{.GOOS}}_{{.GOARCH}}
clean:
desc: clean up build cache files
cmds:
- rm -rf _output
- rm -rf dist
snapshot:
desc: build snapshot
aliases:
- release
cmds:
- task: clean
- go install github.com/goreleaser/goreleaser@latest
- goreleaser release --snapshot --clean --skip-publish
default:
cmds:
- task: clean
- task: fmt
- task: local