Skip to content

Commit 9751a63

Browse files
dcjclaude
andcommitted
Auto-create GitHub Release on tag push
The publish.yml workflow previously only published to PyPI on `v*` tag push; the GitHub Releases page stayed empty across all prior versions (0.1.0 → 0.5.0; backfilled by hand). Adds a `release` job that runs after `publish` succeeds, extracts the matching `## [VERSION]` section from CHANGELOG.md via awk, and creates a GitHub Release with that body (falling back to the annotated-tag message if no CHANGELOG section exists). Requires bumping permissions to `contents: write`. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent d5478be commit 9751a63

1 file changed

Lines changed: 29 additions & 1 deletion

File tree

.github/workflows/publish.yml

Lines changed: 29 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
test:
@@ -34,3 +34,31 @@ jobs:
3434
- uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0
3535
with:
3636
print-hash: true
37+
38+
release:
39+
needs: publish
40+
runs-on: ubuntu-latest
41+
steps:
42+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
43+
- name: Create GitHub Release
44+
env:
45+
GH_TOKEN: ${{ github.token }}
46+
run: |
47+
version="${GITHUB_REF_NAME#v}"
48+
# Extract the [VERSION] section from CHANGELOG.md (between this
49+
# version's heading and the next "## [" heading).
50+
if [ -f CHANGELOG.md ]; then
51+
awk -v ver="## [${version}]" '
52+
index($0, ver) == 1 { in_section=1; next }
53+
in_section && /^## \[/ { exit }
54+
in_section { print }
55+
' CHANGELOG.md > /tmp/release_body.md
56+
fi
57+
# Fall back to the annotated-tag message if CHANGELOG was empty.
58+
if [ ! -s /tmp/release_body.md ]; then
59+
git tag -l --format='%(contents)' "${GITHUB_REF_NAME}" > /tmp/release_body.md
60+
fi
61+
gh release create "${GITHUB_REF_NAME}" \
62+
--repo "${{ github.repository }}" \
63+
--title "${GITHUB_REF_NAME}" \
64+
--notes-file /tmp/release_body.md

0 commit comments

Comments
 (0)