forked from harness/harness
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskfile.yml
More file actions
167 lines (142 loc) · 4.27 KB
/
Taskfile.yml
File metadata and controls
167 lines (142 loc) · 4.27 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
# https://taskfile.dev
version: '3'
vars:
GOPROXY: 'https://goproxy.cn,direct'
GOSUMDB: sum.golang.google.cn
GIT_BRANCH: $(git branch -r --contains | head -1 | sed -E -e "s%(HEAD ->|origin|upstream)/?%%g" | sed 's|/|-|g' | xargs)
GIT_COMMIT: $(git rev-parse --short HEAD || echo "abcdefgh")
BUILD_DATE: $(date +%Y%m%d%H)
BUILD_RELEASE: $(cat version.txt || echo "1.0.0")
BIN_DIR: $(pwd)/bin
GOOS: $(go env GOOS)
GOARCH: $(go env GOARCH)
VERSION_PKG: github.com/easysoft/gitfox/pkg/util/common
LDFLAGS: "-w -s \
-X '{{.VERSION_PKG}}.Version={{.BUILD_RELEASE}}' \
-X '{{.VERSION_PKG}}.BuildDate={{.BUILD_DATE}}' \
-X '{{.VERSION_PKG}}.GitBranch={{.GIT_BRANCH}}' \
-X '{{.VERSION_PKG}}.GitCommitHash={{.GIT_COMMIT}}'"
tasks:
gencopyright:
desc: generate code license
cmds:
- go install github.com/google/addlicense@latest
- hack/scripts/gencopyright.sh
gofmt:
cmds:
- go install golang.org/x/tools/cmd/goimports@latest
- gofmt -s -w .
- goimports -w .
govulncheck:
desc: vulnerability detection
cmds:
- go install golang.org/x/vuln/cmd/govulncheck@v1.1.1
- govulncheck ./...
golint:
cmds:
- go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.57.2
- golangci-lint run -v ./...
gci:
cmds:
- go install github.com/daixiang0/gci@v0.13.1
- gci write --skip-generated --custom-order -s standard -s "prefix(github.com/easysoft/gitfox)" -s default -s blank -s dot .
devinit:
desc: Install git hooks to perform pre-commit checks
cmds:
- git config core.hooksPath .githooks
# - git config commit.template .gitmessage
gomod:
cmds:
- go mod tidy
lint:
desc: lint code
cmds:
- task: gomod
- task: gofmt
- task: gci
- task: golint
# - task: govulncheck
fmt:
desc: format code
run: once
cmds:
- task: gencopyright
- task: lint
# swag:
# desc: generate swagger doc
# cmds:
# - go install github.com/swaggo/swag/cmd/swag@latest
# - ./hack/scripts/gendocs.sh "{{.GIT_BRANCH}}-{{.GIT_COMMIT}}-{{.BUILD_DATE}}"
build:
desc: build binary
deps:
- web
cmds:
- CGO_ENABLED=1 GOOS={{.GOOS}} GOARCH={{.GOARCH}} go build -o "{{.BIN_DIR}}/gitfox_{{.GOOS}}_{{.GOARCH}}" -ldflags "{{.LDFLAGS}}" ./cmd/gitfox
cross-build:
desc: cross build multi arch
cmds:
# - CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -tags=nosqlite -o "{{.BIN_DIR}}/gitfox_linux_amd64" -ldflags "{{.LDFLAGS}}" ./cmd/gitfox
- CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -o "{{.BIN_DIR}}/gitfox_linux_amd64" -ldflags "{{.LDFLAGS}}" ./cmd/gitfox
config-local:
desc: try to create local config
run: once
cmds:
- cp .gitfox.env.sample .gitfox.env
status:
- test -f .gitfox.env
run-local:
desc: debug run
dotenv: [".gitfox.env"]
deps:
- config-local
cmds:
- CGO_ENABLED=1 go run -ldflags "{{.LDFLAGS}}" ./cmd/gitfox server
web-local:
desc: run web for devel
dir: web
cmds:
- yarn
- API_URL=http://127.0.0.1:3000 yarn dev-local
generate:
desc: generate code
cmds:
- ./scripts/wire/gitfox.sh
run:
desc: run binary
deps:
# - swag
- build
dotenv: [".gitfox.env"]
cmds:
- "{{.BIN_DIR}}/gitfox_{{.GOOS}}_{{.GOARCH}} server"
web:
desc: build web
run: once
dir: web
cmds:
# - cat package.json | jq '.version="'1.0.0-{{.GIT_BRANCH}}-{{.GIT_COMMIT}}-{{.BUILD_DATE}}'"' > package.json.new
# - mv package.json.new package.json
- yarn config set registry https://registry.npmmirror.com
- yarn && yarn build
status:
- test -f dist/index.html
clean:
run: once
desc: clean
cmds:
- rm -rf "{{.BIN_DIR}}/gitfox_{{.GOOS}}_{{.GOARCH}}"
- rm -rf web/dist
download-gitfox-plugin:
desc: download gitfox plugin
cmds:
- wget -O hack/ci-plugin/plugins.zip https://pkg.zentao.net/gitfox/20241024/plugins.zip
docker:
desc: build docker image
cmds:
- docker buildx build --pull --push --platform linux/amd64 -t hub.zentao.net/app/gitfox:{{.GIT_BRANCH}}-{{.GIT_COMMIT}}-{{.BUILD_DATE}} .
default:
cmds:
- task: clean
- task: web
- task: build