-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTaskfile.dist.yaml
132 lines (129 loc) · 3.07 KB
/
Taskfile.dist.yaml
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
version: "3"
vars:
PACKAGE: github.com/ismtabo/magus/v2
BINARY_NAME: magus
TARGET_DIR: target
VERSION:
sh: git describe --tags --match "*.*.*" --candidates 1 | sed -e 's/^v//'
BUILD:
sh: git rev-parse --short HEAD
BUILD_TIME: "{{now | date `2006-01-02T15:04+00:00`}}"
ARCH: amd64
TARGET_OSS: linux
OUTPUTS: |
{{.TARGET_DIR}}/{{.BINARY_NAME}}-linux-{{.ARCH}}
{{.TARGET_DIR}}/{{.BINARY_NAME}}-darwin-{{.ARCH}}
{{.TARGET_DIR}}/{{.BINARY_NAME}}-windows-{{.ARCH}}.exe
GO_FILES:
sh: find . -type f -name '*.go' -not -path "./vendor/*"
DETECTED_OS:
sh: go env GOOS
OS: "{{.DETECTED_OS}}"
CHANGELOG: CHANGELOG.md
DOCS_FILES: |
README.md
CHANGELOG.md
includes:
docs:
taskfile: docs/Taskfile.dist.yaml
dir: docs/
scripts:
taskfile: scripts/Taskfile.dist.yaml
dir: scripts/
tasks:
build-target:
desc: Build target OS binary
cmds:
- |
GOARCH={{.ARCH}} GOOS={{.TARGET_OS}} go build \
-ldflags "-X '{{.PACKAGE}}/config.Version={{.VERSION}}' -X '{{.PACKAGE}}/config.Build={{.BUILD}}' -X '{{.PACKAGE}}/config.BuildTime={{.BUILD_TIME}}' -X '{{.PACKAGE}}/config.OS={{.TARGET_OS}}'" \
-o {{.TARGET_DIR}}/{{.BINARY_NAME}}-{{.TARGET_OS}}-{{.ARCH}} \
main.go
requires:
vars:
- TARGET_OS
sources:
- main.go
- "*.go"
- "**/*.go"
generates:
- "{{.TARGET_DIR}}/{{.BINARY_NAME}}-{{.TARGET_OS}}-{{.ARCH}}"
build:
desc: Build targets
cmds:
- task: build-target
for:
var: TARGET_OSS
vars:
TARGET_OS: "{{.ITEM}}"
requires:
vars:
- TARGET_OSS
install:
desc: Install dependencies
cmds:
- go mod tidy
run:
desc: Run the application
cmds:
- go run main.go {{.CLI_ARGS}}
dir: "{{.USER_WORKING_DIR}}"
clean:
desc: Clean target directory
cmds:
- go clean
- rm -rf {{.TARGET_DIR}}
requires:
vars:
- TARGET_DIR
test:
desc: Run tests
cmds:
- go test -v ./...
test_coverage:
desc: Run tests with coverage
cmds:
- go test -v -coverprofile=coverage.out ./...
- go tool cover -html=coverage.out
dep:
desc: Download dependencies
cmds:
- go mod download
vet:
desc: Run go vet
cmds:
- go vet ./...
lint:
desc: Run golangci-lint
cmds:
- golangci-lint run --enable-all
release:
desc: Create a new release
deps:
- task: clean
- task: build
cmds:
- gh release create {{.VERSION}} -F {{.CHANGELOG}} {{.TARGET_DIR}}/*
requires:
vars:
- VERSION
- CHANGELOG
- TARGET_DIR
hotfix:
desc: Create hotfix branch
cmds:
- git switch -c hotfix/{{.PATCH_VERSION}}
vars:
VERSION:
sh: git describe --tags --match "*.*.*" --candidates 1 | sed -e 's/^v//'
PATCH_VERSION:
sh: semver bump patch {{.VERSION}}
fix:
desc: Create fix branch
cmds:
- git switch main
- git pull
- git switch -c fix/{{.PATCH_VERSION}}
requires:
vars:
- PATCH_VERSION