-
Notifications
You must be signed in to change notification settings - Fork 404
Expand file tree
/
Copy pathTaskfile.yml
More file actions
166 lines (148 loc) · 4.23 KB
/
Taskfile.yml
File metadata and controls
166 lines (148 loc) · 4.23 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
# yaml-language-server: $schema=https://taskfile.dev/schema.json
version: "3"
vars:
APP_NAME: teldrive
BUILD_DIR: bin
FRONTEND_DIR: ui/dist
FRONTEND_ASSET: https://github.com/tgdrive/teldrive-ui/releases/download/latest/teldrive-ui.zip
GIT_COMMIT:
sh: git rev-parse --short HEAD
MODULE_PATH:
sh: go list -m
GOOS:
sh: go env GOOS
GOARCH:
sh: go env GOARCH
BINARY_EXTENSION: '{{if eq OS "windows"}}.exe{{end}}'
env:
CGO_ENABLED: 0
tasks:
default:
cmds:
- task: ui
- task: server
deps:
cmds:
- go mod download
- go mod tidy
ui:
desc: Download UI assets
cmds:
- go run scripts/extract.go -url {{.FRONTEND_ASSET}} -output {{.FRONTEND_DIR}}
gen-api:
dir: typespec
desc: Genereate API specs
cmds:
- bun i
- bun run tsp:yml
- go run ../scripts/postprocess-openapi/main.go
gen:
desc: Generate API code
cmds:
- go generate ./...
gen:jet:
desc: Regenerate Jet models from migrations
cmds:
- go run ./scripts/generate_jet.go
gen:config:
desc: Regenerate sample config files
cmds:
- go run ./scripts/generate_config_sample
gen:docs:
desc: Regenerate autogenerated docs assets
cmds:
- go run ./scripts/generate_cli_docs
- mkdir -p docs/src/openapi
- cp ./openapi/openapi.yaml ./docs/src/openapi/openapi.yaml
docs:dev:
desc: Run docs site locally
deps: [gen:docs]
dir: docs
cmds:
- bun install
- bun run docs:dev
docs:build:
desc: Build docs site
deps: [gen:docs]
dir: docs
cmds:
- bun install
- bun run docs:build
lint:
desc: Run linters
cmds:
- golangci-lint run
test:integration:
desc: Run integration tests with dockerized postgres
cmds:
- ./scripts/test-integration.sh
server:
desc: Build Server
deps: [gen]
vars:
VERSION:
sh: go run scripts/release.go --version current
cmds:
- echo "Building backend for {{.GOOS}}/{{.GOARCH}}..."
- >
go build -trimpath -ldflags "-s -w
-X '{{.MODULE_PATH}}/internal/version.Version={{.VERSION}}'
-X '{{.MODULE_PATH}}/internal/version.CommitSHA={{.GIT_COMMIT}}'
" -o {{.BUILD_DIR}}/{{.APP_NAME}}{{.BINARY_EXTENSION}}
run:
desc: Run Server
cmds:
- go run main.go run
retag:
desc: Retag a version
vars:
VERSION:
sh: go run scripts/release.go --version current
OLD_COMMIT:
sh: git rev-list -n 1 {{.VERSION}} || true
preconditions:
- sh: test $(git rev-parse --abbrev-ref HEAD) = "main"
msg: "You must be on the main branch to retag"
- sh: "[[ -z $(git diff --shortstat main) ]]"
msg: "You must have a clean working tree to retag"
prompt: "This will recreate tag {{.VERSION}}. Are you sure?"
cmds:
- echo "Retagging {{.VERSION}}..."
- git tag -d {{.VERSION}} || true
- git push --delete origin {{.VERSION}} || true
- |
if [ ! -z "{{.OLD_COMMIT}}" ]; then
if ! git cherry-pick {{.OLD_COMMIT}}; then
git cherry-pick --abort
echo "Failed to cherry-pick version commit"
exit 1
fi
fi
- git tag -a {{.VERSION}} -m "Release {{.VERSION}}"
- git push origin {{.VERSION}}
- git push origin main
migration:*:
desc: Create a new database migration using goose
vars:
MIGRATION_NAME: "{{index .MATCH 0}}"
cmds:
- goose -dir internal/database/migrations create {{.MIGRATION_NAME}} sql
release:*:
desc: Prepare for a new release
vars:
VERSION:
sh: "go run scripts/release.go --version {{index .MATCH 0}}"
preconditions:
- sh: test $(git rev-parse --abbrev-ref HEAD) = "main"
msg: "You must be on the main branch to release"
- sh: "[[ -z $(git diff --shortstat main) ]]"
msg: "You must have a clean working tree to release"
prompt: "Are you sure you want to release version {{.VERSION}}?"
cmds:
- echo "Releasing {{.VERSION}}"
- "go run scripts/release.go {{.VERSION}}"
- "git add --all"
- 'git commit -m "Version {{.VERSION}}"'
- "git push"
- "git tag {{.VERSION}}"
- "git push origin tag {{.VERSION}}"