-
Notifications
You must be signed in to change notification settings - Fork 86
Expand file tree
/
Copy pathTaskfile.yml
More file actions
393 lines (345 loc) · 14.6 KB
/
Taskfile.yml
File metadata and controls
393 lines (345 loc) · 14.6 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
383
384
385
386
387
388
389
390
391
392
393
version: '3'
vars:
CHANGELOG_FILE: CHANGELOG.md
PLUGIN_XML: src/main/resources/META-INF/plugin.xml
tasks:
generate-changelog:
desc: Generate changelog for a new version
summary: |
Generates changelog entries by fetching recent merged PRs and updating both CHANGELOG.md and plugin.xml.
Usage: task generate-changelog VERSION=0.8.0 [LIMIT=10]
vars:
VERSION: '{{.VERSION | default "0.0.0"}}'
LIMIT: '{{.LIMIT | default "10"}}'
requires:
vars: [VERSION]
deps:
- check-tools
cmds:
- echo "Generating changelog for version {{.VERSION}}"
- task: fetch-recent-prs
vars: {VERSION: "{{.VERSION}}", LIMIT: "{{.LIMIT}}"}
- task: update-changelog
vars: {VERSION: "{{.VERSION}}"}
- task: update-plugin-xml
vars: {VERSION: "{{.VERSION}}"}
- echo "✅ Changelog generated successfully for version {{.VERSION}}"
- echo "📝 Please review the changes in {{.CHANGELOG_FILE}} and {{.PLUGIN_XML}}"
fetch-recent-prs:
desc: Fetch recent merged PRs and generate changelog content
internal: true
vars:
VERSION: '{{.VERSION}}'
LIMIT: '{{.LIMIT | default "10"}}'
cmds:
- |
echo "Fetching last {{.LIMIT}} merged PRs..."
gh pr list --state merged --limit {{.LIMIT}} --json number,title,mergedAt,author,body > /tmp/recent-prs.json
echo "Generating changelog content..."
cat > /tmp/changelog-content.md << 'EOF'
## [{{.VERSION}}] - $(date +%Y-%m-%d)
### Added
EOF
# Parse PRs and categorize changes
jq -r '.[] | select(.title | test("^[Ff]eat|^[Aa]dd")) | "- " + .title + " (#" + (.number | tostring) + ")"' /tmp/recent-prs.json >> /tmp/changelog-content.md
echo "" >> /tmp/changelog-content.md
echo "### Fixed" >> /tmp/changelog-content.md
jq -r '.[] | select(.title | test("^[Ff]ix")) | "- " + .title + " (#" + (.number | tostring) + ")"' /tmp/recent-prs.json >> /tmp/changelog-content.md
echo "" >> /tmp/changelog-content.md
echo "### Dependencies" >> /tmp/changelog-content.md
jq -r '.[] | select(.title | test("^[Bb]ump|^[Uu]pdate")) | "- " + .title + " (#" + (.number | tostring) + ")"' /tmp/recent-prs.json >> /tmp/changelog-content.md
echo "" >> /tmp/changelog-content.md
echo "### Contributors" >> /tmp/changelog-content.md
jq -r '[.[] | .author.login] | unique | .[] | "- @" + .' /tmp/recent-prs.json >> /tmp/changelog-content.md
update-changelog:
desc: Update CHANGELOG.md with new version
internal: true
vars:
VERSION: '{{.VERSION}}'
cmds:
- |
if [ ! -f {{.CHANGELOG_FILE}} ]; then
echo "# Changelog" > {{.CHANGELOG_FILE}}
echo "" >> {{.CHANGELOG_FILE}}
echo "All notable changes to this project will be documented in this file." >> {{.CHANGELOG_FILE}}
echo "" >> {{.CHANGELOG_FILE}}
fi
# Insert new changelog content after the header
sed -i.bak '/^All notable changes/r /tmp/changelog-content.md' {{.CHANGELOG_FILE}}
rm {{.CHANGELOG_FILE}}.bak
echo "✅ Updated {{.CHANGELOG_FILE}}"
update-plugin-xml:
desc: Update plugin.xml change-notes with new version
internal: true
vars:
VERSION: '{{.VERSION}}'
cmds:
- |
# Generate HTML list items from recent PRs
echo "Generating plugin.xml change notes..."
# Create temporary change notes in HTML format
cat > /tmp/plugin-changes.html << EOF
<h2>v{{.VERSION}}</h2>
<UL>
EOF
# Add features
jq -r '.[] | select(.title | test("^[Ff]eat|^[Aa]dd")) | " <LI>" + .title + "</LI>"' /tmp/recent-prs.json >> /tmp/plugin-changes.html
# Add fixes
jq -r '.[] | select(.title | test("^[Ff]ix")) | " <LI>" + .title + "</LI>"' /tmp/recent-prs.json >> /tmp/plugin-changes.html
# Add major dependency updates (limit to avoid clutter)
jq -r '.[] | select(.title | test("^[Bb]ump.*gradle-dependencies|^[Uu]pdate.*dependencies")) | " <LI>" + .title + "</LI>"' /tmp/recent-prs.json | head -3 >> /tmp/plugin-changes.html
echo " </UL>" >> /tmp/plugin-changes.html
# Update plugin.xml by replacing the current version section
# First, backup the file
cp {{.PLUGIN_XML}} {{.PLUGIN_XML}}.bak
# Use a more sophisticated approach to replace the version section
python3 << 'PYTHON'
import re
import sys
with open('{{.PLUGIN_XML}}', 'r') as f:
content = f.read()
with open('/tmp/plugin-changes.html', 'r') as f:
new_changes = f.read()
# Pattern to match the current version section (assuming it's the first one)
pattern = r'(<change-notes><!\[CDATA\[\s*)(.*?)(\s*<h2>v[0-9]+\.[0-9]+\.[0-9]+</h2>)'
if re.search(pattern, content, re.DOTALL):
# Replace existing first version
content = re.sub(pattern, r'\1' + new_changes + r'\3', content, count=1, flags=re.DOTALL)
else:
# Insert as first version if no versions exist
pattern = r'(<change-notes><!\[CDATA\[\s*)'
content = re.sub(pattern, r'\1 ' + new_changes + '\n ', content)
with open('{{.PLUGIN_XML}}', 'w') as f:
f.write(content)
PYTHON
echo "✅ Updated {{.PLUGIN_XML}}"
check-tools:
desc: Check if required tools are available
internal: true
cmds:
- |
command -v gh >/dev/null 2>&1 || { echo "❌ GitHub CLI (gh) is required but not installed. Install from: https://cli.github.com/"; exit 1; }
command -v jq >/dev/null 2>&1 || { echo "❌ jq is required but not installed. Install with: brew install jq"; exit 1; }
command -v python3 >/dev/null 2>&1 || { echo "❌ python3 is required but not installed."; exit 1; }
echo "✅ All required tools are available"
clean-temp:
desc: Clean temporary files
silent: true
cmds:
- rm -f /tmp/recent-prs.json /tmp/changelog-content.md /tmp/plugin-changes.html
- echo "✅ Temporary files cleaned"
version:
desc: Show current plugin version
vars:
CURRENT_VERSION:
sh: grep -E '^version\s*=' build.gradle.kts | head -n1 | sed 's/.*"\(.*\)".*/\1/'
cmds:
- echo "DevoxxGenie plugin version {{.CURRENT_VERSION}}"
build:
desc: Build the plugin using Gradle
cmds:
- ./gradlew buildPlugin
- echo "✅ Plugin built successfully"
test:
desc: Run all tests
cmds:
- ./gradlew test
- echo "✅ Tests completed"
verify:
desc: Verify the plugin (includes tests and plugin verification)
cmds:
- ./gradlew verifyPlugin
- echo "✅ Plugin verification completed"
run-ide:
desc: Run IntelliJ IDEA with the plugin for testing
cmds:
- ./gradlew runIde
clean:
desc: Clean build artifacts
cmds:
- ./gradlew clean
- echo "✅ Build artifacts cleaned"
publish:
desc: Publish plugin to JetBrains Marketplace
summary: |
Publishes the plugin to JetBrains Marketplace.
Requires PUBLISH_TOKEN environment variable to be set.
cmds:
- |
if [ -z "$PUBLISH_TOKEN" ]; then
echo "❌ PUBLISH_TOKEN environment variable is required"
echo "Set it with: export PUBLISH_TOKEN=your_token"
exit 1
fi
- ./gradlew publishPlugin
- echo "✅ Plugin published successfully"
build-and-test:
desc: Build and run all tests
deps:
- build
- test
release:patch:
desc: 📦 Release a patch version (e.g. 0.5.6 → 0.5.7)
summary: |
Bumps the patch version in build.gradle.kts, generates changelog, creates a git tag, and pushes to remote.
preconditions:
- sh: git diff-index --quiet HEAD --
msg: "You have uncommitted changes. Please commit or stash them before releasing."
vars:
CURRENT_VERSION:
sh: grep -E '^version\s*=' build.gradle.kts | head -n1 | sed 's/.*"\(.*\)".*/\1/'
NEW_VERSION:
sh: |
current="{{.CURRENT_VERSION}}"
major=$(echo "$current" | cut -d'.' -f1)
minor=$(echo "$current" | cut -d'.' -f2)
patch=$(echo "$current" | cut -d'.' -f3)
new_patch=$((patch + 1))
echo "$major.$minor.$new_patch"
prompt: "Release patch version {{.NEW_VERSION}}? (current: {{.CURRENT_VERSION}})"
deps:
- check-tools
cmds:
- task: test
- |
sed -i.bak -E 's/^(version[[:space:]]*=[[:space:]]*")[^"]+(".*)$/\1{{.NEW_VERSION}}\2/' build.gradle.kts
rm -f build.gradle.kts.bak
echo "✅ Updated build.gradle.kts to version {{.NEW_VERSION}}"
- task: generate-changelog
vars: {VERSION: "{{.NEW_VERSION}}"}
- git add build.gradle.kts CHANGELOG.md {{.PLUGIN_XML}}
- 'git commit -m "chore(release): prepare release v{{.NEW_VERSION}}"'
- 'git tag -a "v{{.NEW_VERSION}}" -m "Release v{{.NEW_VERSION}}"'
- git push origin HEAD
- 'git push origin "v{{.NEW_VERSION}}"'
- echo "✅ Released v{{.NEW_VERSION}}"
release:minor:
desc: 📦 Release a minor version (e.g. 0.5.6 → 0.6.0)
summary: |
Bumps the minor version in build.gradle.kts, generates changelog, creates a git tag, and pushes to remote.
preconditions:
- sh: git diff-index --quiet HEAD --
msg: "You have uncommitted changes. Please commit or stash them before releasing."
vars:
CURRENT_VERSION:
sh: grep -E '^version\s*=' build.gradle.kts | head -n1 | sed 's/.*"\(.*\)".*/\1/'
NEW_VERSION:
sh: |
current="{{.CURRENT_VERSION}}"
major=$(echo "$current" | cut -d'.' -f1)
minor=$(echo "$current" | cut -d'.' -f2)
new_minor=$((minor + 1))
echo "$major.$new_minor.0"
prompt: "Release minor version {{.NEW_VERSION}}? (current: {{.CURRENT_VERSION}})"
deps:
- check-tools
cmds:
- task: test
- |
sed -i.bak -E 's/^(version[[:space:]]*=[[:space:]]*")[^"]+(".*)$/\1{{.NEW_VERSION}}\2/' build.gradle.kts
rm -f build.gradle.kts.bak
echo "✅ Updated build.gradle.kts to version {{.NEW_VERSION}}"
- task: generate-changelog
vars: {VERSION: "{{.NEW_VERSION}}"}
- git add build.gradle.kts CHANGELOG.md {{.PLUGIN_XML}}
- 'git commit -m "chore(release): prepare release v{{.NEW_VERSION}}"'
- 'git tag -a "v{{.NEW_VERSION}}" -m "Release v{{.NEW_VERSION}}"'
- git push origin HEAD
- 'git push origin "v{{.NEW_VERSION}}"'
- echo "✅ Released v{{.NEW_VERSION}}"
release:major:
desc: 📦 Release a major version (e.g. 0.5.6 → 1.0.0)
summary: |
Bumps the major version in build.gradle.kts, generates changelog, creates a git tag, and pushes to remote.
preconditions:
- sh: git diff-index --quiet HEAD --
msg: "You have uncommitted changes. Please commit or stash them before releasing."
vars:
CURRENT_VERSION:
sh: grep -E '^version\s*=' build.gradle.kts | head -n1 | sed 's/.*"\(.*\)".*/\1/'
NEW_VERSION:
sh: |
current="{{.CURRENT_VERSION}}"
major=$(echo "$current" | cut -d'.' -f1)
new_major=$((major + 1))
echo "$new_major.0.0"
prompt: "Release major version {{.NEW_VERSION}}? (current: {{.CURRENT_VERSION}})"
deps:
- check-tools
cmds:
- task: test
- |
sed -i.bak -E 's/^(version[[:space:]]*=[[:space:]]*")[^"]+(".*)$/\1{{.NEW_VERSION}}\2/' build.gradle.kts
rm -f build.gradle.kts.bak
echo "✅ Updated build.gradle.kts to version {{.NEW_VERSION}}"
- task: generate-changelog
vars: {VERSION: "{{.NEW_VERSION}}"}
- git add build.gradle.kts CHANGELOG.md {{.PLUGIN_XML}}
- 'git commit -m "chore(release): prepare release v{{.NEW_VERSION}}"'
- 'git tag -a "v{{.NEW_VERSION}}" -m "Release v{{.NEW_VERSION}}"'
- git push origin HEAD
- 'git push origin "v{{.NEW_VERSION}}"'
- echo "✅ Released v{{.NEW_VERSION}}"
preview-changes:
desc: Preview what changes would be made without updating files
summary: |
Shows what PRs would be included in the changelog without making changes.
Usage: task preview-changes VERSION=0.8.0 [LIMIT=10]
vars:
VERSION: '{{.VERSION | default "0.0.0"}}'
LIMIT: '{{.LIMIT | default "10"}}'
requires:
vars: [VERSION]
deps:
- check-tools
cmds:
- echo "Preview of changes for version {{.VERSION}}"
- echo "=========================================="
- |
gh pr list --state merged --limit {{.LIMIT}} --json number,title,mergedAt,author --template '
{{range .}}
📝 #{{.number}}: {{.title}} (@{{.author.login}})
{{end}}'
- echo "=========================================="
- echo "Use 'task generate-changelog VERSION={{.VERSION}}' to apply these changes"
help:
desc: Show available tasks and usage examples
silent: true
cmds:
- |
cat << 'EOF'
DevoxxGenie Development & Release Automation
============================================
🔨 Build & Test Tasks:
build - Build the plugin using Gradle
test - Run all tests
verify - Verify the plugin (includes tests and verification)
build-and-test - Build and run all tests
run-ide - Run IntelliJ IDEA with the plugin for testing
clean - Clean build artifacts
publish - Publish plugin to JetBrains Marketplace
📝 Changelog Tasks:
generate-changelog - Generate changelog for a new version
preview-changes - Preview changes without updating files
clean-temp - Clean temporary files
📦 Release Tasks:
release:major - Release a major version (e.g. 0.5.6 → 1.0.0)
release:minor - Release a minor version (e.g. 0.5.6 → 0.6.0)
release:patch - Release a patch version (e.g. 0.5.6 → 0.5.7)
Examples:
# Development
task build
task test
task run-ide
# Release
task release:patch
task verify
PUBLISH_TOKEN=xxx task publish
Requirements:
- GitHub CLI (gh) - https://cli.github.com/
- jq - brew install jq
- python3
- Java/Gradle (for build tasks)
EOF
default:
deps: [help]