Skip to content

Commit d2c7560

Browse files
ci: improve release pipeline (#21)
1 parent 461637b commit d2c7560

File tree

1 file changed

+44
-10
lines changed

1 file changed

+44
-10
lines changed

.github/workflows/release-publish.yml

Lines changed: 44 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,12 @@ on:
1111
- patch
1212
- minor
1313
- 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)'
1620
required: false
1721
type: boolean
1822
default: false
@@ -81,35 +85,65 @@ jobs:
8185
run: pnpm build
8286

8387
- name: Commit version change
88+
if: ${{ github.event.inputs.dry_run != 'true' }}
8489
run: |
8590
git config user.name "github-actions[bot]"
8691
git config user.email "github-actions[bot]@users.noreply.github.com"
8792
git add package.json
8893
git commit -m "chore: bump version to v${{ steps.version.outputs.version }}"
8994
9095
- name: Create and push tag
96+
if: ${{ github.event.inputs.dry_run != 'true' }}
9197
run: |
9298
git tag -a "v${{ steps.version.outputs.version }}" -m "Release v${{ steps.version.outputs.version }}"
9399
git push origin HEAD
94100
git push origin "v${{ steps.version.outputs.version }}"
95101
96102
- name: Publish to npm
103+
if: ${{ github.event.inputs.dry_run != 'true' }}
97104
run: pnpm publish --access public
98105
env:
99106
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
100107

101108
- name: Create GitHub Release
109+
if: ${{ github.event.inputs.dry_run != 'true' }}
102110
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
106118
fi
107-
119+
120+
echo "---- Release Notes ----"
121+
cat RELEASE_NOTES.md
122+
108123
gh release create "v${{ steps.version.outputs.version }}" \
109124
--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
114126
env:
115127
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

Comments
 (0)