Skip to content

Commit 04c071c

Browse files
committed
Guard PyPI publish release versions
1 parent a099e5c commit 04c071c

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

.github/workflows/python-publish.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ jobs:
1313
runs-on: ubuntu-latest
1414
steps:
1515
- uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0
1618

1719
- name: Set up Python
1820
uses: actions/setup-python@v5
@@ -24,10 +26,24 @@ jobs:
2426
python -m pip install --upgrade pip
2527
python -m pip install build twine
2628
29+
- name: Verify release tag
30+
run: |
31+
TAG="$(git describe --tags --exact-match)"
32+
case "$TAG" in
33+
v[0-9]*)
34+
echo "Publishing $TAG"
35+
;;
36+
*)
37+
echo "Refusing to publish from non-release tag: $TAG"
38+
exit 1
39+
;;
40+
esac
41+
2742
- name: Build and publish
2843
env:
2944
TWINE_USERNAME: __token__
3045
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
3146
run: |
3247
python -m build --sdist --wheel
48+
python -m twine check dist/*
3349
python -m twine upload dist/*

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ dependencies = [
3030
"markdown",
3131
"pygments",
3232
"pyyaml",
33-
"webifier-extensions>=1.0.0",
33+
"webifier-extensions>=1.0.1",
3434
]
3535

3636
[project.optional-dependencies]

0 commit comments

Comments
 (0)