-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskfile.yml
More file actions
382 lines (334 loc) · 11.9 KB
/
Taskfile.yml
File metadata and controls
382 lines (334 loc) · 11.9 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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
version: "3"
dotenv:
- .env.local # Load environment variables from .env.local
vars:
# Default values for local development
CI_API_V4_URL: "https://gitlab.com/api/v4"
# CI_PROJECT_ID: "69861189"
PACKAGE_NAME: "semantic-version-manager"
EXECUTABLE_NAME: "semantic-version-manager"
BREW_FORMULA_NAME: "SemanticVersionManager"
VERSION:
sh: swift package plugin {{.EXECUTABLE_NAME}} show full
tasks:
clean:
cmds:
- swift package clean
- swift package reset
- swift package purge-cache
version:show:full:
cmds:
- echo "Current version is {{.VERSION}}"
version:bump:patch:
desc: Bump patch version and commit
cmds:
- swift package plugin {{.EXECUTABLE_NAME}} bump patch
- git add version.json
- |
VERSION=$(swift package plugin {{.EXECUTABLE_NAME}} show full)
git commit -m "chore: bump version to $VERSION"
echo "Version bumped to $VERSION"
version:bump:minor:
desc: Bump minor version and commit
cmds:
- swift package plugin {{.EXECUTABLE_NAME}} bump minor
- git add version.json
- |
VERSION=$(swift package plugin {{.EXECUTABLE_NAME}} show full)
git commit -m "chore: bump version to $VERSION"
echo "Version bumped to $VERSION"
version:bump:major:
desc: Bump major version and commit
cmds:
- swift package plugin {{.EXECUTABLE_NAME}} bump major
- git add version.json
- |
VERSION=$(swift package plugin {{.EXECUTABLE_NAME}} show full)
git commit -m "chore: bump version to $VERSION"
echo "Version bumped to $VERSION"
format:
cmds:
- |
swift package plugin --allow-writing-to-package-directory format-source-code --targets \
SemanticVersionKit SemanticVersionKitTests \
SemanticVersionTool SemanticVersionToolTests \
SemanticVersionPlugin SemanticVersionPluginTests \
--swift-format-configuration .swift-format.json
lint:
cmds:
- |
swift package plugin lint-source-code --targets \
SemanticVersionKit SemanticVersionKitTests \
SemanticVersionTool SemanticVersionToolTests \
SemanticVersionPlugin SemanticVersionPluginTests \
--swift-format-configuration .swift-format.json
review:
cmds:
- task: format
- task: lint
build:debug:
cmds:
- mkdir -p .build/debug/codecov
- swift build --enable-code-coverage --build-tests
test:
cmds:
- swift test --parallel --skip-build --enable-code-coverage
- rm -rf default.profraw
coverage-path:
cmds:
- swift test --show-codecov-path
test:coverage:
cmds:
# - task: binary:install:local
- swift package plugin code-coverage-review {{ .COVERAGE_PATH }} --threshold 85
vars:
COVERAGE_PATH:
sh: swift test --show-codecov-path
document:
cmds:
- |
swift package \
--allow-writing-to-directory ./docs \
generate-documentation \
--target SemanticVersionKit \
--output-path ./docs \
--hosting-base-path / \
--transform-for-static-hosting
#--hosting-base-path /public/{{.PACKAGE_NAME}}
- |
cat << EOF > docs/theme-settings.json
{
"theme": {
"color": {
"documentation-intro-fill": "rebeccapurple"
}
}
}
EOF
binary:uninstall:
cmds:
- rm -rf bin/{{.EXECUTABLE_NAME}}
build:release:
cmds:
- rm -rf dist
- swift build -c release --arch arm64 --arch x86_64 --product {{.EXECUTABLE_NAME}}
- mkdir -p dist
- cp .build/apple/Products/Release/{{.EXECUTABLE_NAME}} dist/
binary:install:
cmds:
- task: binary:uninstall
- task: build:release
- sudo cp "{{.EXECUTABLE_BUILD_BIN_PATH}}/semantic-version-manager" /usr/local/bin/semantic-version-manager
vars:
EXECUTABLE_BUILD_BIN_PATH:
sh: swift build -c release --show-bin-path
binary:install:local:
cmds:
- rm -rf bin
- mkdir -p bin
- cp "dist/semantic-version-manager" bin/semantic-version-manager
vars:
EXECUTABLE_BUILD_BIN_PATH:
sh: swift build -c release --show-bin-path
brew:generate-formula:
desc: Generate Homebrew formula with project-specific URL
cmds:
- |
URL="{{.CI_API_V4_URL}}/projects/{{.CI_PROJECT_ID}}/packages/generic/{{.PACKAGE_NAME}}/{{.VERSION}}/{{.PACKAGE_NAME}}-{{.VERSION}}.tar.gz"
SHA256=$(shasum -a 256 dist/{{.PACKAGE_NAME}}-{{.VERSION}}.tar.gz | awk '{print $1}')
mkdir -p Formula
cat << EOF > Formula/{{.EXECUTABLE_NAME}}.rb
class {{.BREW_FORMULA_NAME}} < Formula
desc "Swift version management tool"
homepage "https://gitlab.com/thecb4-universe/public/{{.PACKAGE_NAME}}"
url "${URL}"
sha256 "${SHA256}"
license "MIT"
version "{{.VERSION}}"
def install
bin.install "{{.EXECUTABLE_NAME}}"
end
test do
system "#{bin}/{{.EXECUTABLE_NAME}}", "--version"
end
end
EOF
echo "Generated Homebrew formula:"
cat Formula/{{.PACKAGE_NAME}}.rb
brew:test:
cmds:
- brew install --build-from-source Formula/{{.EXECUTABLE_NAME}}.rb
- "{{.EXECUTABLE_NAME}} --help"
- brew uninstall {{.EXECUTABLE_NAME}}
package:prepare:
cmds:
- task: build:release
- tar -czf dist/{{.PACKAGE_NAME}}-{{.VERSION}}.tar.gz -C dist {{.EXECUTABLE_NAME}}
package:registry-upload:
desc: Upload release package to GitLab Registry
cmds:
- |
# Use CI_JOB_TOKEN in CI, fallback to personal token locally
if [ -z "${CI}" ]; then
AUTH_HEADER="PRIVATE-TOKEN: {{.GITLAB_REGISTRY_TOKEN}}"
else
AUTH_HEADER="JOB-TOKEN: ${CI_JOB_TOKEN}"
fi
curl --location --header "${AUTH_HEADER}" \
--upload-file dist/{{.PACKAGE_NAME}}-{{.VERSION}}.tar.gz \
"{{.CI_API_V4_URL}}/projects/{{.CI_PROJECT_ID}}/packages/generic/{{.PACKAGE_NAME}}/{{.VERSION}}/{{.PACKAGE_NAME}}-{{.VERSION}}.tar.gz"
vars:
GITLAB_TOKEN: "{{.GITLAB_TOKEN | default}}"
package:registry-delete:
cmds:
- |
# Use CI_JOB_TOKEN in CI, fallback to personal token locally
if [ -z "${CI}" ]; then
AUTH_HEADER="PRIVATE-TOKEN: {{.GITLAB_REGISTRY_TOKEN}}"
else
AUTH_HEADER="JOB-TOKEN: ${CI_JOB_TOKEN}"
fi
curl --request DELETE --header "${AUTH_HEADER}" \
"{{.CI_API_V4_URL}}/projects/{{.CI_PROJECT_ID}}/packages/generic/{{.PACKAGE_NAME}}/{{.VERSION}}/{{.PACKAGE_NAME}}"
package:tag:
cmds:
- git tag -a {{.VERSION}} -m "Release version {{.VERSION}}"
- git push origin {{.VERSION}}
package:release:
desc: Create GitLab release and attach package link
cmds:
- |
# Set authentication header
if [ -z "${CI}" ]; then
AUTH_HEADER="PRIVATE-TOKEN: {{.GITLAB_REGISTRY_TOKEN}}"
else
AUTH_HEADER="JOB-TOKEN: ${CI_JOB_TOKEN}"
fi
# Construct the package URL
PACKAGE_URL="{{.CI_API_V4_URL}}/projects/{{.CI_PROJECT_ID}}/packages/generic/{{.PACKAGE_NAME}}/{{.VERSION}}/{{.PACKAGE_NAME}}-{{.VERSION}}.tar.gz"
# Create the release with asset link
curl --header "Content-Type: application/json" \
--header "${AUTH_HEADER}" \
--data '{
"name": "Release {{.VERSION}}",
"tag_name": "{{.VERSION}}",
"description": "Release for version {{.VERSION}}",
"assets": {
"links": [
{
"name": "{{.PACKAGE_NAME}}-{{.VERSION}}.tar.gz",
"url": "'"${PACKAGE_URL}"'",
"link_type": "package"
}
]
}
}' \
--request POST "{{.CI_API_V4_URL}}/projects/{{.CI_PROJECT_ID}}/releases"
pipeline:local:
cmds:
- task: version:show:full
- task: review
- task: build:debug
- task: test
- task: test:coverage
- task: document
pipeline:homebrew:
desc: Build and test Homebrew formula locally
cmds:
- task: package:prepare
- task: brew:generate-formula
- task: package:registry-upload
- task: brew:test
brew:install:remote:
cmds:
- brew uninstall --force {{.EXECUTABLE_NAME}} || true
- brew untap thecb4-universe/{{.PACKAGE_NAME}} || true
- brew tap thecb4-universe/{{.PACKAGE_NAME}} https://gitlab.com/thecb4-universe/public/{{.PACKAGE_NAME}}.git
- brew install thecb4-universe/{{.PACKAGE_NAME}}/{{.EXECUTABLE_NAME}}
- "{{.EXECUTABLE_NAME}} --help"
- brew uninstall {{.EXECUTABLE_NAME}}
- brew untap thecb4-universe/{{.PACKAGE_NAME}}
deploy:documentation:
cmds:
- mkdir -p public/
- cp -r docs/* public/
- find public/ -type d -exec chmod 755 {} \; # Set permissions for directories
- find public/ -type f -exec chmod 644 {} \; # Set permissions for files
# Comprehensive Release Tasks
release:validate:
desc: Validate the codebase is ready for release
cmds:
- task: pipeline:local
- echo "All tests passed, coverage met, and code formatted"
release:prepare:
desc: Prepare the release artifacts
cmds:
- task: package:prepare
- task: brew:generate-formula
- git add Formula/{{.EXECUTABLE_NAME}}.rb
- |
git commit -m "chore: update Homebrew formula for v{{.VERSION}}" || echo "No changes to commit"
- echo "Release artifacts prepared and formula committed"
release:publish:
desc: Publish the release to registries and create tags
cmds:
- task: package:registry-upload
- task: package:tag
- task: package:release
- echo "Package uploaded, tag created, and release published"
release:finalize:
desc: Final steps and notifications
cmds:
- git push origin main
- echo "Release {{.VERSION}} completed successfully!"
- |
echo "Package URL: {{.CI_API_V4_URL}}/projects/{{.CI_PROJECT_ID}}/packages/generic/{{.PACKAGE_NAME}}/{{.VERSION}}/{{.PACKAGE_NAME}}-{{.VERSION}}.tar.gz"
- |
echo "Release URL: https://gitlab.com/thecb4-universe/public/{{.PACKAGE_NAME}}/-/releases/{{.VERSION}}"
release:full:
desc: Complete release process with validation, build, tag, and publish
preconditions:
- sh: git diff --quiet
msg: "Working directory has uncommitted changes. Please commit or stash them first."
- sh: git diff --cached --quiet
msg: "Staging area has uncommitted changes. Please commit or stash them first."
cmds:
- task: release:validate
- task: release:prepare
- task: release:publish
- task: release:finalize
release:patch:
desc: Create a patch release (bug fixes)
cmds:
- task: version:bump:patch
- task: release:full
release:minor:
desc: Create a minor release (new features)
cmds:
- task: version:bump:minor
- task: release:full
release:major:
desc: Create a major release (breaking changes)
cmds:
- task: version:bump:major
- task: release:full
release:dry-run:
desc: Test the release process without publishing
cmds:
- task: release:validate
- task: build:release
- tar -czf dist/{{.PACKAGE_NAME}}-{{.VERSION}}.tar.gz -C dist {{.EXECUTABLE_NAME}}
- task: brew:generate-formula
- echo "Dry run completed. Release {{.VERSION}} is ready."
- echo "Review generated formula at Formula/{{.EXECUTABLE_NAME}}.rb"
- echo "Package would be at dist/{{.PACKAGE_NAME}}-{{.VERSION}}.tar.gz"
release:rollback:
desc: Rollback a failed release
cmds:
- |
git tag -d {{.VERSION}} || echo "Tag not found locally"
- |
git push origin :refs/tags/{{.VERSION}} || echo "Tag not found on remote"
- task: package:registry-delete
- git reset --hard HEAD~1
- echo "Rolled back release {{.VERSION}}"