Publish package (Test PyPI) #11
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Build wheels and sdist and publish new version of the package to Test PyPI. | |
name: Publish package (Test PyPI) | |
on: | |
workflow_dispatch: | |
jobs: | |
build-wheels: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-20.04, windows-2019, macos-12] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up Python 3.12 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.12' | |
- name: Build wheels | |
uses: pypa/cibuildwheel@v2.19.2 | |
with: | |
output-dir: dist | |
env: | |
CIBW_BUILD: cp312-* | |
CIBW_ARCHS: auto | |
CIBW_BUILD_FRONTEND: pip | |
CIBW_TEST_REQUIRES: pytest | |
CIBW_TEST_COMMAND: pytest {project}/tests | |
- name: Upload wheels to artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: dist-${{ matrix.os }} | |
path: ./dist/*.whl | |
build-sdist: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up Python 3.12 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.12' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
python -m pip install build | |
- name: Build source distribution | |
run: | |
python -m build --sdist | |
- name: Upload source distribution to artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: dist-source | |
path: ./dist/*.tar.gz | |
publish-wheels: | |
runs-on: ubuntu-latest | |
needs: [build-wheels, build-sdist] | |
steps: | |
- name: Download wheels from artifact | |
uses: actions/download-artifact@v4 | |
with: | |
pattern: dist-* | |
path: ./dist | |
merge-multiple: true | |
- name: Publish distribution to Test PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
user: __token__ | |
password: ${{ secrets.TEST_PYPI_API_TOKEN }} | |
repository-url: https://test.pypi.org/legacy/ | |
packages-dir: dist | |
skip-existing: true |