name: Publish Python 🐍 distributions πŸ“¦ to PyPI and TestPyPI on: push: branches: - releases/* tags: - v* jobs: build_wheels: name: Build wheels on ${{ matrix.platform }} runs-on: ${{ matrix.platform }} strategy: matrix: platform: [ubuntu-latest, macos-latest, windows-latest, ubuntu-24.04-arm, windows-11-arm] env: CIBW_ARCHS_LINUX: "native" CIBW_ARCHS_MACOS: "x86_64 universal2 arm64" # Include latest Python beta CIBW_PRERELEASE_PYTHONS: True CIBW_SKIP: "pp*" steps: - name: Checkout πŸ›ŽοΈ uses: actions/checkout@v4 with: fetch-depth: 20 - name: Fetch release tags run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* - name: Set up Python 🐍 uses: actions/setup-python@v6 with: python-version: 3.13 - name: Install cibuildwheel run: | python -m pip install -U pip cibuildwheel - name: Build wheels run: python -m cibuildwheel --output-dir wheelhouse - name: Upload wheels uses: actions/upload-artifact@v4 with: name: artifact-${{ matrix.platform }} path: wheelhouse/*.whl build_source_dist: name: Build source dist runs-on: ubuntu-latest steps: - name: Checkout πŸ›ŽοΈ uses: actions/checkout@v4 with: fetch-depth: 20 - name: Fetch release tags run: git fetch --depth=1 origin +refs/tags/*:refs/tags/* - name: Set up Python 🐍 uses: actions/setup-python@v4 with: python-version: 3.13 - name: Build source distribution & wheels🎑 run: | python -m pip install -U pip setuptools setuptools_scm[toml] build python -m build --sdist - name: Upload source distribution uses: actions/upload-artifact@v4 with: name: artifact-source path: dist/*.tar.gz pypi-publish: name: publish Python 🐍 distributions πŸ“¦ to PyPI and TestPyPI runs-on: ubuntu-latest needs: [build_wheels, build_source_dist] environment: pypi permissions: id-token: write steps: - name: download dist artifacts uses: actions/download-artifact@v4 with: path: dist merge-multiple: true - name: Publish distribution πŸ“¦ to Test PyPI if: ${{ startsWith(github.event.ref, 'refs/heads/releases') }} uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc # release/v1.12.4 with: repository-url: https://test.pypi.org/legacy/ - name: Publish distribution πŸ“¦ to PyPI if: startsWith(github.event.ref, 'refs/tags') uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc # release/v1.12.4