Skip to content

Commit 43f2fcd

Browse files
authored
fix(publish): create GitHub Release on tag push (#95)
Adds a GitHub Release creation step to the publish workflow so the `v*` tag push that ships a PyPI release also produces a GitHub Release page with the wheel + sdist attached. Closes the "manual changelog duplication" gap that 0.16.3 would otherwise hit: the land-badge on the landing page would render 0.16.3 only after a separate `gh release create` step, which would race the PyPI publish job in the same workflow run. Diff: - `permissions.contents: write` on the publish job — required by softprops/action-gh-release to push the release ref. Additive to the existing `id-token: write` (which PyPI Trusted Publishing needs); does NOT weaken the existing security posture since the workflow already has `actions/checkout@v4` writing into `${{ github.workspace }}`. - New step "Create GitHub Release" at the end of the publish job, gated on `startsWith(github.ref, 'refs/tags/v')` so manual workflow_dispatch re-runs (used for hotfix rebuilds) don't create duplicate releases on branch refs. `generate_release_notes: true` asks GitHub to auto-aggregate merged PR titles + labels into the release body so the GH release page mirrors CHANGELOG.md without manual editing. `files: dist/*.whl, dist/*.tar.gz` attaches the same artifacts that PyPI receives, so the release page doubles as a download mirror for environments where pip isn't available. Pinned to `softprops/action-gh-release@v2` (matches the project release-train convention). The latest stable release is v3.0.2; the inputs used here (`tag_name`, `generate_release_notes`, `files`) are identical between v2 and v3, so bumping is a one-line change when desired. No changes to test/, build, or PyPI publish step. The existing `needs: test` dependency still gates the release creation on a green test matrix.
1 parent 6c857b2 commit 43f2fcd

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

.github/workflows/publish.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ jobs:
4343
url: https://pypi.org/p/nullrun
4444
permissions:
4545
id-token: write
46+
# contents: write is required by softprops/action-gh-release to
47+
# create the GitHub Release (push the tag ref + draft release).
48+
# The existing publish step only needs id-token for PyPI Trusted
49+
# Publishing, so this is additive and scoped to the new step.
50+
contents: write
4651

4752
steps:
4853
- uses: actions/checkout@v4
@@ -63,3 +68,22 @@ jobs:
6368
6469
- name: Publish to PyPI (Trusted Publishing)
6570
uses: pypa/gh-action-pypi-publish@release/v1
71+
72+
# GitHub Release creation — gated on tag pushes so the manual
73+
# workflow_dispatch path (used for hotfix re-runs) doesn't create
74+
# a duplicate release on the current HEAD's branch ref. The
75+
# ``generate_release_notes`` flag asks GitHub to auto-aggregate
76+
# merged PR titles + labels into the release body, which keeps
77+
# the GitHub release page in sync with the CHANGELOG.md body
78+
# without manual editing. Attached files mirror what PyPI receives
79+
# (wheel + sdist) so the release page doubles as a download mirror
80+
# for environments where pip isn't available.
81+
- name: Create GitHub Release
82+
if: startsWith(github.ref, 'refs/tags/v')
83+
uses: softprops/action-gh-release@v2
84+
with:
85+
tag_name: ${{ github.ref_name }}
86+
generate_release_notes: true
87+
files: |
88+
dist/*.whl
89+
dist/*.tar.gz

0 commit comments

Comments
 (0)