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
2033concurrency :
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