-
Notifications
You must be signed in to change notification settings - Fork 4
/
Taskfile.yml
140 lines (121 loc) Β· 3.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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# https://taskfile.dev
version: '3'
vars:
GOPROXY: 'https://goproxy.cn,direct'
GOSUMDB: sum.golang.google.cn
VERSION_PKG: github.com/easysoft/qcadmin/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%H)
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 code license
cmds:
- go install github.com/google/addlicense@latest
- hack/scripts/gencopyright.sh
godoc:
desc: update docs
cmds:
- rm -rf ./docs/*.md
- go run ./docs/docs.go
- cp -a README.md docs/index.md
gofmt:
cmds:
- go install golang.org/x/tools/cmd/goimports@latest
- gofmt -s -w .
- goimports -w .
golint:
cmds:
- go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
- golangci-lint run -v ./...
lint:
desc: lint code
cmds:
- task: gofmt
- task: golint
fmt:
desc: format code
cmds:
- task: gencopyright
- task: gofmt
- task: golint
generate:
desc: generate code
cmds:
- go generate ./...
linux:
desc: build linux for remote test
vars:
GOOS: linux
GOARCH: amd64
deps:
- generate
cmds:
- go install github.com/mitchellh/gox@latest
- gox -os={{.GOOS}} -arch={{.GOARCH}} -output="{{.BUILD_DIR}}/qcadmin_{{.GOOS}}_{{.GOARCH}}" -ldflags "{{.LDFLAGS}}"
# status:
# - test -f {{.BUILD_DIR}}/qcadmin_{{.GOOS}}_{{.GOARCH}}
local:
desc: build local for test
deps:
- generate
cmds:
- go install github.com/mitchellh/gox@latest
- gox -os={{.GOOS}} -arch={{.GOARCH}} -output="{{.BUILD_DIR}}/qcadmin_{{.GOOS}}_{{.GOARCH}}" -ldflags "{{.LDFLAGS}}"
# status:
# - test -f {{.BUILD_DIR}}/qcadmin_{{.GOOS}}_{{.GOARCH}}
clean:
desc: Clean Up Build Cache Files
cmds:
- rm -rf _output
- rm -rf dist
snapshot:
desc: Build Snapshot Version
cmds:
- task: clean
- go install github.com/goreleaser/goreleaser@latest
- goreleaser release --snapshot --clean --skip-publish
version-ci:
desc: ci fix version
cmds:
- cat examples/sonar-project.properties.example | sed "s#2.0.0#${APP_VERSION}#g" > sonar-project.properties
version-local:
desc: local fix version
cmds:
- cat examples/sonar-project.properties.example | sed "s#2.0.0#${APP_VERSION}#g" | sed "s#quickon#pangu#g" > sonar-project.properties
docker-build:
desc: build docker image
cmds:
- docker buildx build --pull --push --platform linux/amd64 -t ttl.sh/easysoft/qcadmin .
trivy-docker:
desc: trivy docker image
cmds:
- trivy image --severity MEDIUM,HIGH,CRITICAL ttl.sh/easysoft/qcadmin --scanners vuln
default:
desc: default linux
cmds:
- task: clean
- task: linux