Skip to content

Commit 33f44f6

Browse files
committed
Only build and push to PyPI once
1 parent 5e3b36f commit 33f44f6

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

.github/workflows/python-package.yml

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ on:
1212
branches: [ master ]
1313

1414
jobs:
15-
build:
16-
15+
test:
1716
runs-on: ubuntu-latest
1817
strategy:
1918
matrix:
@@ -25,11 +24,6 @@ jobs:
2524
uses: actions/setup-python@v4
2625
with:
2726
python-version: ${{ matrix.python-version }}
28-
- name: Debug Event Info
29-
run: |
30-
echo "Event name: ${{ github.event_name }}"
31-
echo "Ref: ${{ github.ref }}"
32-
echo "Is tag? ${{ startsWith(github.ref, 'refs/tags/') }}"
3327
- name: Install dependencies
3428
run: |
3529
python -m pip install --upgrade pip
@@ -45,14 +39,24 @@ jobs:
4539
- name: Test with pytest
4640
run: |
4741
pytest
42+
43+
publish:
44+
needs: test
45+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
46+
runs-on: ubuntu-latest
47+
48+
steps:
49+
- uses: actions/checkout@v3
50+
- name: Set up Python 3.12
51+
uses: actions/setup-python@v4
52+
with:
53+
python-version: 3.12
4854
- name: Build and publish
49-
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
5055
env:
5156
TWINE_USERNAME: __token__
5257
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
5358
run: |
54-
pip install twine wheel
59+
pip install setuptools twine wheel
5560
pip wheel -w dist --no-deps .
5661
python setup.py sdist
5762
twine upload dist/*
58-
continue-on-error: true

0 commit comments

Comments
 (0)