|
11 | 11 | - patch |
12 | 12 | - minor |
13 | 13 | - major |
14 | | - prerelease: |
15 | | - description: 'Mark as pre-release' |
| 14 | + release_notes: |
| 15 | + description: 'Optional custom changelog (use \\n for new lines)' |
| 16 | + required: false |
| 17 | + type: string |
| 18 | + dry_run: |
| 19 | + description: 'Dry run (build & compute version only, skip commit/tag/publish/release)' |
16 | 20 | required: false |
17 | 21 | type: boolean |
18 | 22 | default: false |
@@ -81,35 +85,65 @@ jobs: |
81 | 85 | run: pnpm build |
82 | 86 |
|
83 | 87 | - name: Commit version change |
| 88 | + if: ${{ github.event.inputs.dry_run != 'true' }} |
84 | 89 | run: | |
85 | 90 | git config user.name "github-actions[bot]" |
86 | 91 | git config user.email "github-actions[bot]@users.noreply.github.com" |
87 | 92 | git add package.json |
88 | 93 | git commit -m "chore: bump version to v${{ steps.version.outputs.version }}" |
89 | 94 |
|
90 | 95 | - name: Create and push tag |
| 96 | + if: ${{ github.event.inputs.dry_run != 'true' }} |
91 | 97 | run: | |
92 | 98 | git tag -a "v${{ steps.version.outputs.version }}" -m "Release v${{ steps.version.outputs.version }}" |
93 | 99 | git push origin HEAD |
94 | 100 | git push origin "v${{ steps.version.outputs.version }}" |
95 | 101 |
|
96 | 102 | - name: Publish to npm |
| 103 | + if: ${{ github.event.inputs.dry_run != 'true' }} |
97 | 104 | run: pnpm publish --access public |
98 | 105 | env: |
99 | 106 | NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
100 | 107 |
|
101 | 108 | - name: Create GitHub Release |
| 109 | + if: ${{ github.event.inputs.dry_run != 'true' }} |
102 | 110 | run: | |
103 | | - PRERELEASE_FLAG="" |
104 | | - if [ "${{ github.event.inputs.prerelease }}" = "true" ]; then |
105 | | - PRERELEASE_FLAG="--prerelease" |
| 111 | + NOTES_INPUT="${{ github.event.inputs.release_notes }}" |
| 112 | + # Convert literal \n sequences into actual newlines (user can input escaped newlines) |
| 113 | + NOTES_INPUT="${NOTES_INPUT//\\n/$'\n'}" |
| 114 | + if [ -z "$NOTES_INPUT" ]; then |
| 115 | + printf "## What's Changed\n\n**Full Changelog**: https://github.com/${{ github.repository }}/commits/v${{ steps.version.outputs.version }}\n" > RELEASE_NOTES.md |
| 116 | + else |
| 117 | + printf "%s\n\n**Full Changelog**: https://github.com/${{ github.repository }}/commits/v${{ steps.version.outputs.version }}\n" "$NOTES_INPUT" > RELEASE_NOTES.md |
106 | 118 | fi |
107 | | - |
| 119 | +
|
| 120 | + echo "---- Release Notes ----" |
| 121 | + cat RELEASE_NOTES.md |
| 122 | +
|
108 | 123 | gh release create "v${{ steps.version.outputs.version }}" \ |
109 | 124 | --title "Release v${{ steps.version.outputs.version }}" \ |
110 | | - --notes "## What's Changed |
111 | | - |
112 | | - **Full Changelog**: https://github.com/${{ github.repository }}/commits/v${{ steps.version.outputs.version }}" \ |
113 | | - $PRERELEASE_FLAG |
| 125 | + --notes-file RELEASE_NOTES.md |
114 | 126 | env: |
115 | 127 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 128 | + |
| 129 | + - name: Preview release notes (dry run) |
| 130 | + if: ${{ github.event.inputs.dry_run == 'true' }} |
| 131 | + run: | |
| 132 | + NOTES_INPUT="${{ github.event.inputs.release_notes }}" |
| 133 | + NOTES_INPUT="${NOTES_INPUT//\\n/$'\n'}" |
| 134 | + if [ -z "$NOTES_INPUT" ]; then |
| 135 | + printf "## What's Changed\n\n**Full Changelog**: https://github.com/${{ github.repository }}/commits/v${{ steps.version.outputs.version }}\n" > RELEASE_NOTES.md |
| 136 | + else |
| 137 | + printf "%s\n\n**Full Changelog**: https://github.com/${{ github.repository }}/commits/v${{ steps.version.outputs.version }}\n" "$NOTES_INPUT" > RELEASE_NOTES.md |
| 138 | + fi |
| 139 | +
|
| 140 | + echo "---- (Dry Run) Release Notes Preview ----" |
| 141 | + cat RELEASE_NOTES.md |
| 142 | + echo "----------------------------------------" |
| 143 | +
|
| 144 | + - name: Dry run summary |
| 145 | + if: ${{ github.event.inputs.dry_run == 'true' }} |
| 146 | + run: | |
| 147 | + echo "Dry run mode enabled." |
| 148 | + echo "Calculated new version: v${{ steps.version.outputs.version }}" |
| 149 | + echo "Build completed. Skipped commit, tag creation, push, npm publish, and GitHub release." |
0 commit comments