-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTaskfile.yml
170 lines (154 loc) · 3.94 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
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
168
169
170
version: '3'
tasks:
example:
aliases: [eg]
requires:
vars: [NAME]
cmds:
- task: example:build
vars: { NAME: '{{.NAME}}' }
- .out/examples/{{.NAME}} {{.CLI_ARGS}}
example:build:
deps:
- gen
requires:
vars: [NAME]
cmds:
- go build -v -o .out/examples/{{.NAME}} ./examples/{{.NAME}}
test:
deps:
- gen
cmds:
- go test -v ./...
lint:
deps:
- lint:gen
- lint:go
lint:go:
deps:
- gen
cmds:
- golangci-lint run
lint:gen:
deps:
- gen
cmds:
- |
git diff --exit-code internal/pb/*.go s2/*.sync.go && echo "Up-to-date" || {
echo "Not up-to-date"
echo "Run `task gen` and update the generated code"
exit 1
}
fmt:
deps:
- gen
cmds:
- golangci-lint run --fix --issues-exit-code 0 &> /dev/null
gomod:
cmds:
- go mod tidy -go=1.22
gen:
deps:
- gen:proto
- gen:sync
gen:proto:
preconditions:
- sh: which protoc
msg: |
`protoc` command not found
Install the proto compiler: https://grpc.io/docs/protoc-installation/
- sh: which protoc-gen-go
msg: |
`protoc-gen-go` command not found
Install the Go extension using:
$ go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
- sh: which protoc-gen-go-grpc
msg: |
`protoc-gen-go-grpc` command not found
Install the gRPC extension using:
$ go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
sources:
- proto/s2/v1alpha/s2.proto
generates:
- internal/pb/s2.pb.go
- internal/pb/s2_grpc.pb.go
cmds:
- test -d internal/pb || mkdir -p internal/pb
- cmd: |
protoc --proto_path=proto/s2/v1alpha \
--go_opt=Ms2.proto=github.com/s2-streamstore/s2-sdk-go/internal/pb \
--go-grpc_opt=Ms2.proto=github.com/s2-streamstore/s2-sdk-go/internal/pb \
--go_opt=paths=source_relative \
--go-grpc_opt=paths=source_relative \
--go_out=internal/pb \
--go-grpc_out=internal/pb \
s2.proto
gen:sync:
deps:
- gen:sync:types
- gen:sync:client
gen:sync:types:
deps:
- gen:sync:_bin
- gen:proto
sources:
- .out/sync-docs
- internal/pb/s2.pb.go
- s2/types.sync.tmpl
generates:
- s2/types.sync.go
cmds:
- cmd: |
.out/sync-docs \
-i internal/pb/s2.pb.go \
-t s2/types.sync.tmpl \
-o s2/types.sync.go
gen:sync:client:
deps:
- gen:sync:_bin
- gen:proto
sources:
- .out/sync-docs
- internal/pb/s2_grpc.pb.go
- s2/client.sync.tmpl
generates:
- s2/client.sync.go
cmds:
- cmd: |
.out/sync-docs \
-i internal/pb/s2_grpc.pb.go \
-t s2/client.sync.tmpl \
-o s2/client.sync.go
gen:sync:_bin:
sources:
- internal/sync-docs/*.go
generates:
- .out/sync-docs
cmds:
- go build -o .out/sync-docs ./internal/sync-docs/*.go
release:prepare:
requires:
vars: [VERSION]
vars:
SEMVER:
sh: ./scripts/semver.sh {{.VERSION}}
BRANCH: 'release-{{.SEMVER}}-{{now | unixEpoch}}'
cmds:
- git fetch origin -t
- git checkout origin/main
- git switch -c {{.BRANCH}}
- git cliff --unreleased --tag {{.SEMVER}} --prepend CHANGELOG.md
- git add CHANGELOG.md
- 'git commit -m "chore(release): {{.SEMVER}}"'
- echo "Push the branch '{{.BRANCH}}'. Once merged, create tag the release using 'task release:tag'"
release:tag:
requires:
vars: [VERSION]
vars:
SEMVER:
sh: ./scripts/semver.sh {{.VERSION}}
cmds:
- git fetch origin -t
- git checkout origin/main
- git tag {{.SEMVER}}
- echo "Push the tag '{{.SEMVER}}' to release"