Skip to content

Commit 65fafad

Browse files
committed
ci: fail on tag/version mismatch; create a GitHub Release per tag
1 parent 9836f3d commit 65fafad

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

.github/workflows/publish.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,27 @@ on:
66
push:
77
tags: ["v*"]
88
permissions:
9-
contents: read
9+
contents: write # tag-anchored GitHub Release
1010
jobs:
1111
publish:
1212
runs-on: ubuntu-latest
1313
permissions:
1414
id-token: write
1515
steps:
1616
- uses: actions/checkout@v4
17+
# A tag must publish exactly the version it names; a stale
18+
# pyproject.toml fails fast instead of a late PyPI reject.
19+
- name: tag matches package version
20+
run: |
21+
v=$(python3 -c "import tomllib; print(tomllib.load(open('pyproject.toml','rb'))['project']['version'])")
22+
[ "v$v" = "$GITHUB_REF_NAME" ] || { echo "tag $GITHUB_REF_NAME != pyproject v$v" >&2; exit 1; }
1723
- uses: actions/setup-python@v5
1824
with:
1925
python-version: "3.12"
2026
- run: pip install build pytest && python -m pytest tests/ -q
2127
- run: python -m build
2228
- uses: pypa/gh-action-pypi-publish@release/v1
29+
- name: github release
30+
run: gh release create "$GITHUB_REF_NAME" --generate-notes
31+
env:
32+
GH_TOKEN: ${{ github.token }}

0 commit comments

Comments
 (0)