Skip to content

Commit fb1dd62

Browse files
committed
feat: add automatic release notes generation
- Add automatic changelog generation from previous tag - Include commit messages and hashes in release notes - Add installation instructions to release notes - Support both incremental and initial releases
1 parent 7a09fc6 commit fb1dd62

File tree

1 file changed

+51
-4
lines changed

1 file changed

+51
-4
lines changed

.github/workflows/npm-publish.yml

Lines changed: 51 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
name: Publish to npm
22

33
on:
4-
release:
5-
types: [published]
4+
push:
5+
tags:
6+
- 'v*'
67

78
jobs:
89
publish:
@@ -40,12 +41,58 @@ jobs:
4041
env:
4142
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
4243

44+
- name: Generate Release Notes
45+
id: release_notes
46+
run: |
47+
# Get the previous tag
48+
PREVIOUS_TAG=$(git describe --tags --abbrev=0 HEAD~1 2>/dev/null || echo "")
49+
50+
if [ -n "$PREVIOUS_TAG" ]; then
51+
echo "Previous tag: $PREVIOUS_TAG"
52+
echo "Current tag: ${{ github.ref_name }}"
53+
54+
# Generate changelog between tags
55+
CHANGELOG=$(git log --pretty=format:"- %s (%h)" $PREVIOUS_TAG..HEAD)
56+
57+
# Create release notes
58+
cat << EOF > release_notes.md
59+
## Changes in ${{ github.ref_name }}
60+
61+
### Commits since $PREVIOUS_TAG
62+
$CHANGELOG
63+
64+
### Installation
65+
\`\`\`bash
66+
npm install effect-audio@${{ github.ref_name }}
67+
\`\`\`
68+
EOF
69+
else
70+
echo "No previous tag found, creating initial release notes"
71+
cat << EOF > release_notes.md
72+
## Initial Release ${{ github.ref_name }}
73+
74+
### Installation
75+
\`\`\`bash
76+
npm install effect-audio@${{ github.ref_name }}
77+
\`\`\`
78+
EOF
79+
fi
80+
81+
# Output the release notes
82+
cat release_notes.md
83+
84+
# Set output for next step
85+
echo "release_notes<<EOF" >> $GITHUB_OUTPUT
86+
cat release_notes.md >> $GITHUB_OUTPUT
87+
echo "EOF" >> $GITHUB_OUTPUT
88+
4389
- name: Create GitHub Release
4490
uses: actions/create-release@v1
4591
env:
4692
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4793
with:
48-
tag_name: ${{ github.ref }}
49-
release_name: Release ${{ github.ref }}
94+
tag_name: ${{ github.ref_name }}
95+
release_name: Release ${{ github.ref_name }}
96+
body: ${{ steps.release_notes.outputs.release_notes }}
5097
draft: false
5198
prerelease: false

0 commit comments

Comments
 (0)