Skip to content

Commit b3ed472

Browse files
konardclaude
andcommitted
feat: add JS-style changeset workflow
This implements the changeset workflow similar to JavaScript's @changesets/cli: - Add .changeset/ folder structure with config.json and README.md - Update create-manual-changeset.mjs for JS-style format with frontmatter - Update validate-changeset.mjs to validate the new changeset format - Add merge-changesets.mjs to merge multiple changesets (highest bump wins) - Update collect-changelog.mjs to work with the new format - Update version-and-commit.mjs with changeset mode for auto version bump - Update release.yml with changeset, instant, and changeset-pr modes - Update README.md and CONTRIBUTING.md with new workflow documentation - Remove old changelog.d/ folder The changeset workflow: - Avoids merge conflicts on CHANGELOG.md - Automatically determines version bump from changesets - Matches the pattern used in the JS template 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent e3226b7 commit b3ed472

File tree

12 files changed

+1005
-403
lines changed

12 files changed

+1005
-403
lines changed

.changeset/README.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# Changesets
2+
3+
This directory contains changeset files that document changes for upcoming releases.
4+
5+
## Why Changesets?
6+
7+
Using individual changeset files instead of editing `CHANGELOG.md` directly:
8+
- **Avoids merge conflicts** when multiple PRs are open
9+
- **Associates changes with PRs** for better traceability
10+
- **Enforces documentation** of all changes
11+
- **Determines version bump type** automatically from the changesets
12+
13+
## Creating a Changeset
14+
15+
### Using the Script
16+
17+
```bash
18+
# Create a new changeset
19+
bun scripts/create-manual-changeset.mjs --bump-type patch --description "Fix a bug"
20+
bun scripts/create-manual-changeset.mjs --bump-type minor --description "Add new feature"
21+
bun scripts/create-manual-changeset.mjs --bump-type major --description "Breaking change"
22+
```
23+
24+
### Manually
25+
26+
Create a file with a random name (e.g., `happy-cats-dance.md`) in this directory with the following format:
27+
28+
```markdown
29+
---
30+
'java-ai-driven-development-pipeline-template': patch
31+
---
32+
33+
Description of the changes made.
34+
```
35+
36+
## Changeset Format
37+
38+
Each changeset file has two parts:
39+
40+
1. **Frontmatter** (between `---` markers):
41+
- Package name and version bump type (major, minor, or patch)
42+
43+
2. **Description**:
44+
- Clear description of what changed
45+
- Use present tense ("Add feature" not "Added feature")
46+
- Reference issue numbers when applicable: "Fix login bug (#123)"
47+
48+
### Version Bump Types
49+
50+
- **patch**: Bug fixes, documentation updates, internal changes
51+
- **minor**: New features, non-breaking enhancements
52+
- **major**: Breaking changes, API changes
53+
54+
## Example Changeset
55+
56+
```markdown
57+
---
58+
'java-ai-driven-development-pipeline-template': minor
59+
---
60+
61+
Add async delay function with CompletableFuture support for non-blocking operations.
62+
```
63+
64+
## What Happens During Release
65+
66+
1. The release workflow detects pending changesets
67+
2. Multiple changesets are merged (highest bump type wins)
68+
3. Version is bumped according to the determined bump type
69+
4. A new version entry is added to `CHANGELOG.md`
70+
5. Changeset files are deleted
71+
6. Changes are committed and pushed to main
72+
73+
## Tips
74+
75+
- One changeset per PR is typical
76+
- Be concise but descriptive in your descriptions
77+
- The bump type determines the version number change
78+
- Multiple changesets are automatically merged during release

.changeset/brave-tigers-dance.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
'my-package': minor
3+
---
4+
5+
Add JS-style changeset workflow for managing version bumps and changelogs.
6+
7+
This implementation:
8+
- Uses `.changeset/` folder structure similar to JavaScript's `@changesets/cli`
9+
- Changeset files include package name and bump type in frontmatter
10+
- Automatically determines version bump from changesets (highest type wins)
11+
- Merges multiple changesets during release
12+
- Supports three release modes: changeset, instant, and changeset-pr
13+
- Eliminates merge conflicts on CHANGELOG.md

.changeset/config.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"changelog": false,
3+
"commit": false,
4+
"fixed": [],
5+
"linked": [],
6+
"access": "public",
7+
"baseBranch": "main",
8+
"updateInternalDependencies": "patch",
9+
"ignore": []
10+
}

.github/workflows/release.yml

Lines changed: 162 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,28 @@ on:
77
types: [opened, synchronize, reopened]
88
workflow_dispatch:
99
inputs:
10-
bump_type:
11-
description: 'Version bump type'
10+
release_mode:
11+
description: 'Release mode'
1212
required: true
13+
default: 'changeset'
14+
type: choice
15+
options:
16+
- changeset
17+
- instant
18+
- changeset-pr
19+
bump_type:
20+
description: 'Version bump type (for instant mode or changeset-pr)'
21+
required: false
1322
default: 'patch'
1423
type: choice
1524
options:
1625
- patch
1726
- minor
1827
- major
28+
description:
29+
description: 'Change description (for changeset-pr mode)'
30+
required: false
31+
type: string
1932

2033
concurrency:
2134
group: ${{ github.workflow }}-${{ github.ref }}
@@ -129,10 +142,10 @@ jobs:
129142
retention-days: 7
130143

131144
# =============================================================================
132-
# Changelog Fragment Validation (PRs only)
145+
# Changeset Validation (PRs only)
133146
# =============================================================================
134-
changelog-check:
135-
name: Changelog Check
147+
changeset-check:
148+
name: Changeset Check
136149
runs-on: ubuntu-latest
137150
if: github.event_name == 'pull_request'
138151
steps:
@@ -146,13 +159,13 @@ jobs:
146159
with:
147160
bun-version: latest
148161

149-
- name: Validate changelog fragment
162+
- name: Validate changeset
150163
run: bun scripts/validate-changeset.mjs
151164
env:
152165
GITHUB_BASE_REF: ${{ github.base_ref }}
153166

154167
# =============================================================================
155-
# Auto Release (on push to main)
168+
# Auto Release (on push to main with changesets)
156169
# =============================================================================
157170
auto-release:
158171
name: Auto Release
@@ -166,6 +179,7 @@ jobs:
166179
uses: actions/checkout@v4
167180
with:
168181
fetch-depth: 0
182+
token: ${{ secrets.GITHUB_TOKEN }}
169183

170184
- name: Set up JDK ${{ env.JAVA_VERSION }}
171185
uses: actions/setup-java@v4
@@ -179,54 +193,118 @@ jobs:
179193
with:
180194
bun-version: latest
181195

182-
- name: Get current version
183-
id: version
184-
run: |
185-
VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
186-
echo "version=$VERSION" >> $GITHUB_OUTPUT
187-
echo "Current version: $VERSION"
188-
189-
- name: Check if tag exists
190-
id: tag_check
196+
- name: Check for changesets
197+
id: changesets
191198
run: |
192-
TAG="v${{ steps.version.outputs.version }}"
193-
if git rev-parse "$TAG" >/dev/null 2>&1; then
194-
echo "exists=true" >> $GITHUB_OUTPUT
195-
echo "Tag $TAG already exists"
199+
CHANGESET_COUNT=$(find .changeset -name "*.md" ! -name "README.md" 2>/dev/null | wc -l)
200+
echo "count=$CHANGESET_COUNT" >> $GITHUB_OUTPUT
201+
if [ "$CHANGESET_COUNT" -gt 0 ]; then
202+
echo "has_changesets=true" >> $GITHUB_OUTPUT
203+
echo "Found $CHANGESET_COUNT changeset(s)"
196204
else
197-
echo "exists=false" >> $GITHUB_OUTPUT
198-
echo "Tag $TAG does not exist"
205+
echo "has_changesets=false" >> $GITHUB_OUTPUT
206+
echo "No changesets found"
199207
fi
200208
209+
- name: Merge changesets (if multiple)
210+
if: steps.changesets.outputs.has_changesets == 'true' && steps.changesets.outputs.count > 1
211+
run: bun scripts/merge-changesets.mjs
212+
213+
- name: Run version and commit script
214+
if: steps.changesets.outputs.has_changesets == 'true'
215+
id: release
216+
run: bun scripts/version-and-commit.mjs --mode changeset
217+
env:
218+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
219+
220+
- name: Build release artifacts
221+
if: steps.release.outputs.released == 'true'
222+
run: mvn package source:jar javadoc:jar -DskipTests -B
223+
224+
- name: Create GitHub Release
225+
if: steps.release.outputs.released == 'true'
226+
run: |
227+
bun scripts/create-github-release.mjs \
228+
--release-version "${{ steps.release.outputs.new_version }}" \
229+
--repository "${{ github.repository }}"
230+
env:
231+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
232+
233+
- name: Upload release artifacts
234+
if: steps.release.outputs.released == 'true'
235+
run: |
236+
TAG="v${{ steps.release.outputs.new_version }}"
237+
gh release upload "$TAG" target/*.jar --clobber || true
238+
env:
239+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
240+
241+
# =============================================================================
242+
# Manual Release - Changeset Mode (workflow dispatch)
243+
# =============================================================================
244+
manual-release-changeset:
245+
name: Manual Release (Changeset)
246+
runs-on: ubuntu-latest
247+
needs: [build]
248+
if: github.event_name == 'workflow_dispatch' && github.event.inputs.release_mode == 'changeset'
249+
permissions:
250+
contents: write
251+
steps:
252+
- name: Checkout code
253+
uses: actions/checkout@v4
254+
with:
255+
fetch-depth: 0
256+
token: ${{ secrets.GITHUB_TOKEN }}
257+
258+
- name: Set up JDK ${{ env.JAVA_VERSION }}
259+
uses: actions/setup-java@v4
260+
with:
261+
java-version: ${{ env.JAVA_VERSION }}
262+
distribution: ${{ env.JAVA_DISTRIBUTION }}
263+
cache: maven
264+
265+
- name: Set up Bun
266+
uses: oven-sh/setup-bun@v2
267+
with:
268+
bun-version: latest
269+
270+
- name: Merge changesets (if multiple)
271+
run: bun scripts/merge-changesets.mjs
272+
273+
- name: Run version and commit script
274+
id: release
275+
run: bun scripts/version-and-commit.mjs --mode changeset
276+
env:
277+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
278+
201279
- name: Build release artifacts
202-
if: steps.tag_check.outputs.exists == 'false'
280+
if: steps.release.outputs.released == 'true'
203281
run: mvn package source:jar javadoc:jar -DskipTests -B
204282

205283
- name: Create GitHub Release
206-
if: steps.tag_check.outputs.exists == 'false'
284+
if: steps.release.outputs.released == 'true'
207285
run: |
208286
bun scripts/create-github-release.mjs \
209-
--release-version "${{ steps.version.outputs.version }}" \
287+
--release-version "${{ steps.release.outputs.new_version }}" \
210288
--repository "${{ github.repository }}"
211289
env:
212290
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
213291

214292
- name: Upload release artifacts
215-
if: steps.tag_check.outputs.exists == 'false'
293+
if: steps.release.outputs.released == 'true'
216294
run: |
217-
TAG="v${{ steps.version.outputs.version }}"
295+
TAG="v${{ steps.release.outputs.new_version }}"
218296
gh release upload "$TAG" target/*.jar --clobber || true
219297
env:
220298
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
221299

222300
# =============================================================================
223-
# Manual Release (workflow dispatch)
301+
# Manual Release - Instant Mode (workflow dispatch)
224302
# =============================================================================
225-
manual-release:
226-
name: Manual Release
303+
manual-release-instant:
304+
name: Manual Release (Instant)
227305
runs-on: ubuntu-latest
228306
needs: [build]
229-
if: github.event_name == 'workflow_dispatch'
307+
if: github.event_name == 'workflow_dispatch' && github.event.inputs.release_mode == 'instant'
230308
permissions:
231309
contents: write
232310
steps:
@@ -250,7 +328,7 @@ jobs:
250328

251329
- name: Run version and commit script
252330
id: release
253-
run: bun scripts/version-and-commit.mjs --bump-type ${{ inputs.bump_type }}
331+
run: bun scripts/version-and-commit.mjs --mode instant --bump-type ${{ inputs.bump_type }}
254332
env:
255333
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
256334

@@ -274,3 +352,55 @@ jobs:
274352
gh release upload "$TAG" target/*.jar --clobber || true
275353
env:
276354
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
355+
356+
# =============================================================================
357+
# Manual Changeset PR (workflow dispatch)
358+
# =============================================================================
359+
changeset-pr:
360+
name: Create Changeset PR
361+
runs-on: ubuntu-latest
362+
if: github.event_name == 'workflow_dispatch' && github.event.inputs.release_mode == 'changeset-pr'
363+
permissions:
364+
contents: write
365+
pull-requests: write
366+
steps:
367+
- name: Checkout code
368+
uses: actions/checkout@v4
369+
with:
370+
fetch-depth: 0
371+
372+
- name: Set up Bun
373+
uses: oven-sh/setup-bun@v2
374+
with:
375+
bun-version: latest
376+
377+
- name: Create changeset file
378+
run: |
379+
DESCRIPTION="${{ inputs.description }}"
380+
if [ -z "$DESCRIPTION" ]; then
381+
DESCRIPTION="Manual release"
382+
fi
383+
bun scripts/create-manual-changeset.mjs \
384+
--bump-type "${{ inputs.bump_type }}" \
385+
--description "$DESCRIPTION"
386+
387+
- name: Create Pull Request
388+
uses: peter-evans/create-pull-request@v6
389+
with:
390+
token: ${{ secrets.GITHUB_TOKEN }}
391+
commit-message: "chore: add changeset for ${{ inputs.bump_type }} release"
392+
branch: changeset-manual-release-${{ github.run_id }}
393+
delete-branch: true
394+
title: "chore: ${{ inputs.bump_type }} release changeset"
395+
body: |
396+
## Summary
397+
398+
This PR adds a changeset for a **${{ inputs.bump_type }}** release.
399+
400+
${{ inputs.description }}
401+
402+
---
403+
*This PR was automatically created by the changeset-pr workflow.*
404+
labels: |
405+
release
406+
automated

0 commit comments

Comments
 (0)