Skip to content

Commit f58c990

Browse files
authored
Update wheel building workflow to only upload on actual release (#1870)
One pain point with Traits releases has been that we get as far as making the release, only for the wheel build to fail. This PR makes it easier to do a dry run of the wheel building _before_ making a release: the key change is that if the `release-to-pypi` workflow is triggered via workflow dispatch, then wheel building is performed but upload to PyPI is not performed. This makes it harder to trigger a release via workflow dispatch, but I think that's okay: we've almost never needed to do that, and in cases where there's something that needs to be changed we can usually make a new release. Incidental changes: - I've updated the Python version used for working with `build` and `twine` to Python 3.13.
1 parent f7865b7 commit f58c990

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

.github/workflows/release-to-pypi.yml

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
build-wheels:
1010
strategy:
1111
matrix:
12-
os: [windows-latest, macos-13, macos-14, ubuntu-latest]
12+
os: [windows-latest, macos-15-intel, macos-latest, ubuntu-latest]
1313

1414
runs-on: ${{ matrix.os }}
1515

@@ -21,21 +21,23 @@ jobs:
2121
- name: Set up Python
2222
uses: actions/setup-python@v6
2323
with:
24-
python-version: '3.10'
24+
python-version: '3.13'
2525

2626
- name: Install Python packages needed for wheel build and upload
2727
run: python -m pip install twine
2828

2929
- name: Build wheels
3030
uses: pypa/cibuildwheel@v3.3.0
3131

32-
- name: Check and upload wheels
32+
- name: Check wheels
33+
run: python -m twine check --strict wheelhouse/*.whl
34+
35+
- name: Publish wheels to PyPI
36+
if: github.event_name == 'release'
37+
run: python -m twine upload wheelhouse/*.whl
3338
env:
3439
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
3540
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
36-
run: |
37-
python -m twine check --strict wheelhouse/*.whl
38-
python -m twine upload wheelhouse/*.whl
3941

4042
build-sdist:
4143
runs-on: ubuntu-latest
@@ -48,18 +50,20 @@ jobs:
4850
- name: Set up Python
4951
uses: actions/setup-python@v6
5052
with:
51-
python-version: '3.10'
53+
python-version: '3.13'
5254

5355
- name: Install Python packages needed for sdist build and upload
5456
run: python -m pip install build twine
5557

5658
- name: Build sdist
5759
run: python -m build --sdist
5860

61+
- name: Check sdist
62+
run: python -m twine check --strict dist/*
63+
5964
- name: Publish sdist to PyPI
65+
if: github.event_name == 'release'
66+
run: python -m twine upload dist/*
6067
env:
6168
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
6269
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
63-
run: |
64-
python -m twine check --strict dist/*
65-
python -m twine upload dist/*

0 commit comments

Comments
 (0)