Skip to content

Commit f91158d

Browse files
committed
ci: create a GitHub release when a tag is pushed
Runs after the package is published, so a failed publish does not leave a release pointing at nothing. Notes come from the matching CHANGELOG section, falling back to generated notes when there is no entry.
1 parent 9265654 commit f91158d

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,30 @@ jobs:
1515
- uses: astral-sh/setup-uv@v7
1616
- run: uv build
1717
- uses: pypa/gh-action-pypi-publish@release/v1
18+
19+
github-release:
20+
needs: publish
21+
runs-on: ubuntu-latest
22+
permissions:
23+
contents: write
24+
steps:
25+
- uses: actions/checkout@v5
26+
27+
- name: Take the notes from the changelog
28+
run: |
29+
version="${GITHUB_REF_NAME#v}"
30+
awk -v want="## $version" '
31+
$0 == want { found = 1; next }
32+
found && /^## / { exit }
33+
found { print }
34+
' CHANGELOG.md > notes.md || true
35+
36+
- name: Publish the release
37+
env:
38+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
39+
run: |
40+
if [ -s notes.md ]; then
41+
gh release create "$GITHUB_REF_NAME" --title "$GITHUB_REF_NAME" --notes-file notes.md
42+
else
43+
gh release create "$GITHUB_REF_NAME" --title "$GITHUB_REF_NAME" --generate-notes
44+
fi

0 commit comments

Comments
 (0)