-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskfile.yml
More file actions
83 lines (73 loc) · 2.33 KB
/
Taskfile.yml
File metadata and controls
83 lines (73 loc) · 2.33 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
version: '3'
vars:
GIT_VERSION:
sh: git describe --tags --abbrev=0 || git rev-parse --short HEAD || echo "v0.0.0" | tr -d '\n'
GIT_COMMIT:
sh: git log -n 1 --format=%h
BUILD_DATE:
sh: date -u +'%Y-%m-%dT%H:%M:%SZ'
tasks:
prepare:
desc: Prepare the environment
cmds:
- curl -sfL https://raw.githubusercontent.com/securego/gosec/master/install.sh | sudo sh -s -- -b /usr/local/bin v2.22.0
- go mod download
test:
desc: Run tests
aliases: [t]
cmds:
- go clean -testcache
- go test -v ./...
coverage:
desc: Run tests with coverage
aliases: [c]
cmds:
- go clean -testcache
- go test -v -cover ./... -coverprofile=coverage.txt
- go tool cover --html=coverage.txt -o coverage.html
- go tool cover --func=coverage.txt
lint:
desc: Run linters
aliases: [l]
cmds:
- golangci-lint run ./...
- gosec ./...
fmt:
desc: Run go fmt
aliases: [f]
cmds:
- go fmt ./...
run:
desc: Run the binary file
aliases: [r]
cmds:
- go build -tags=build -o ./bin/git-profile ./cmd/*.go && git-profile {{.CLI_ARGS}}
build:
desc: Build all binary files
aliases: [b]
cmds:
- for:
- { OS: linux, ARCH: amd64}
- { OS: linux, ARCH: arm64 }
- { OS: windows, ARCH: amd64, EXT: .exe}
- { OS: windows, ARCH: arm64, EXT: .exe}
- { OS: darwin, ARCH: amd64}
- { OS: darwin, ARCH: arm64}
cmd: |
GOOS={{.ITEM.OS}} GOARCH={{.ITEM.ARCH}} go build -o ./build/git-profile-{{.GIT_VERSION}}-{{.ITEM.OS}}-{{.ITEM.ARCH}}{{.ITEM.EXT}} -ldflags="-s -w -X main.version={{.GIT_VERSION}} -X main.gitCommit={{.GIT_COMMIT}} -X main.buildDate={{.BUILD_DATE}}" {{.CLI_ARGS}} ./cmd/*.go
shasum -a 256 "./build/git-profile-{{.GIT_VERSION}}-{{.ITEM.OS}}-{{.ITEM.ARCH}}{{.ITEM.EXT}}" > ./build/git-profile-{{.GIT_VERSION}}-{{.ITEM.OS}}-{{.ITEM.ARCH}}{{.ITEM.EXT}}.sha256
shasum -c ./build/git-profile-{{.GIT_VERSION}}-{{.ITEM.OS}}-{{.ITEM.ARCH}}{{.ITEM.EXT}}.sha256
check:
desc: Check the code
aliases: [ch]
cmds:
- go vet ./...
- go fmt ./...
- go mod tidy
- go mod verify
clean:
desc: Clean the binary files
aliases: [cl]
cmds:
- go clean
- rm -rf ./bin ./build ./coverage.txt ./coverage.html