Skip to content

Commit d79787e

Browse files
ci: create GitHub release with changelog notes on tag push
1 parent da851ab commit d79787e

1 file changed

Lines changed: 26 additions & 1 deletion

File tree

.github/workflows/release.yml

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
- "v*"
77

88
permissions:
9-
contents: read
9+
contents: write
1010
id-token: write
1111

1212
jobs:
@@ -40,3 +40,28 @@ jobs:
4040

4141
- name: Publish to npm
4242
run: npm publish --provenance --access public
43+
44+
- name: Extract changelog entry
45+
id: changelog
46+
run: |
47+
VERSION="${GITHUB_REF_NAME#v}"
48+
NOTES=$(awk "/^## \[${VERSION}\]/{found=1; next} found && /^## \[/{exit} found{print}" CHANGELOG.md)
49+
echo "notes<<EOF" >> "$GITHUB_OUTPUT"
50+
echo "$NOTES" >> "$GITHUB_OUTPUT"
51+
echo "EOF" >> "$GITHUB_OUTPUT"
52+
53+
- name: Create GitHub release
54+
uses: actions/github-script@v7
55+
with:
56+
script: |
57+
await github.rest.repos.createRelease({
58+
owner: context.repo.owner,
59+
repo: context.repo.repo,
60+
tag_name: context.ref.replace('refs/tags/', ''),
61+
name: context.ref.replace('refs/tags/', ''),
62+
body: process.env.RELEASE_NOTES,
63+
draft: false,
64+
prerelease: false,
65+
})
66+
env:
67+
RELEASE_NOTES: ${{ steps.changelog.outputs.notes }}

0 commit comments

Comments
 (0)