Skip to content

Commit bf8e645

Browse files
committed
ci: add GitHub release creation to publish workflow
After npm publish, the workflow now extracts release notes from CHANGELOG.md and creates a GitHub release using gh CLI. Changes: - Bump contents permission from read to write - Add changelog extraction step using awk - Add gh release create step with --verify-tag - Add release URL to verify step output
1 parent e7581b6 commit bf8e645

1 file changed

Lines changed: 43 additions & 1 deletion

File tree

.github/workflows/publish.yml

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77

88
permissions:
99
id-token: write
10-
contents: read
10+
contents: write
1111

1212
jobs:
1313
publish:
@@ -64,7 +64,49 @@ jobs:
6464
env:
6565
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
6666

67+
- name: Extract release notes from CHANGELOG
68+
id: release_notes
69+
run: |
70+
VERSION="${{ steps.extract_version.outputs.version }}"
71+
72+
# Extract compare URL from reference link
73+
COMPARE_URL=$(grep -E "^\[${VERSION}\]: " CHANGELOG.md | sed "s/^\[${VERSION}\]: //")
74+
75+
# Extract body: convert ### to ##, strip --- separators, collapse blank lines
76+
NOTES=$(awk -v ver="$VERSION" '
77+
/^## \[/ {
78+
if (found) exit
79+
if ($0 ~ "\\[" ver "\\]") { found=1; next }
80+
}
81+
/^\[.*\]: https/ { next }
82+
found { print }
83+
' CHANGELOG.md \
84+
| sed 's/^### /## /' \
85+
| sed '/^---$/d' \
86+
| sed '/^$/N;/^\n$/d')
87+
88+
# Combine: Full Changelog link + body
89+
{
90+
if [ -n "$COMPARE_URL" ]; then
91+
printf "**Full Changelog**: %s\n\n" "$COMPARE_URL"
92+
fi
93+
echo "$NOTES"
94+
} > /tmp/release-notes.md
95+
96+
echo "Extracted release notes for v$VERSION"
97+
98+
- name: Create GitHub release
99+
env:
100+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
101+
run: |
102+
VERSION="${{ steps.extract_version.outputs.version }}"
103+
gh release create "v${VERSION}" \
104+
--title "v${VERSION}" \
105+
--notes-file /tmp/release-notes.md \
106+
--verify-tag
107+
67108
- name: Verify publish success
68109
run: |
69110
echo "✅ Successfully published linearis@${{ steps.extract_version.outputs.version }}"
70111
echo "📦 Package URL: https://www.npmjs.com/package/linearis"
112+
echo "📋 Release: https://github.com/${{ github.repository }}/releases/tag/v${{ steps.extract_version.outputs.version }}"

0 commit comments

Comments
 (0)