Upload package to Pypi #91
Workflow file for this run
This file contains hidden or 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
| name: Upload package to Pypi | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| overrideVersion: | |
| description: Manually force a version | |
| uploadToPyPI: | |
| description: Upload to PyPI | |
| required: false | |
| default: false | |
| type: boolean | |
| env: | |
| CIBW_BUILD_VERBOSITY: 3 | |
| SETUPTOOLS_SCM_PRETEND_VERSION: ${{ github.event.inputs.overrideVersion }} | |
| # Run the package tests using `pytest` | |
| CIBW_TEST_REQUIRES: pytest | |
| CIBW_TEST_COMMAND: pytest {project}/tests | |
| jobs: | |
| make_sdist: | |
| name: Make SDist | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v2 | |
| - name: Setup Python | |
| uses: actions/setup-python@v2 | |
| with: | |
| python-version: "3.10" | |
| - name: Install deps | |
| run: python -m pip install build twine | |
| - name: Build SDist | |
| run: python -m build --sdist | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: cibw-sdist | |
| path: dist/*.tar.gz | |
| - name: Check metadata | |
| run: twine check dist/* | |
| build_wheels: | |
| name: Build wheels on ${{ matrix.os }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| os: [ubuntu-latest, windows-latest, macos-latest] | |
| steps: | |
| - uses: actions/checkout@v2 | |
| # Used to host cibuildwheel | |
| - uses: actions/setup-python@v2 | |
| - name: Install cibuildwheel | |
| run: python -m pip install cibuildwheel | |
| - name: Build wheels | |
| run: python -m cibuildwheel --output-dir wheelhouse | |
| env: | |
| # Disable explicitly building PyPI wheels for specific configurations | |
| CIBW_SKIP: pp* cp{38,39,310,311,312,313,314}-manylinux_i686 *-musllinux_* cp{38,39,310,311,312,313,314}-win32 | |
| CIBW_PRERELEASE_PYTHONS: False | |
| # Manually force a version (and avoid building local wheels) | |
| CIBW_ENVIRONMENT: "SETUPTOOLS_SCM_PRETEND_VERSION=${{ github.event.inputs.overrideVersion }}" | |
| CIBW_ARCHS_MACOS: x86_64 arm64 | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }} | |
| path: wheelhouse/*.whl | |
| build_aarch64_wheels: | |
| name: Build wheels manylinux_aarch64 | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| python: [38, 39, 310, 311, 312, 313,314] | |
| include: | |
| - os: ubuntu-latest | |
| arch: aarch64 | |
| platform_id: manylinux_aarch64 | |
| steps: | |
| - uses: actions/checkout@v2 | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v1 | |
| - name: Install cibuildwheel | |
| run: python -m pip install cibuildwheel | |
| - name: Build wheels | |
| run: python -m cibuildwheel --output-dir wheelhouse | |
| env: | |
| CIBW_ARCHS_LINUX: ${{matrix.arch}} | |
| CIBW_BUILD: cp${{ matrix.python }}-${{ matrix.platform_id }} | |
| # Manually force a version (and avoid building local wheels) | |
| CIBW_ENVIRONMENT: "SETUPTOOLS_SCM_PRETEND_VERSION=${{ github.event.inputs.overrideVersion }}" | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: cibw-aarch64_wheels-${{ matrix.os }}-${{ strategy.job-index }} | |
| path: wheelhouse/*.whl | |
| upload_all: | |
| needs: [build_wheels, build_aarch64_wheels, make_sdist] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/download-artifact@v5 | |
| with: | |
| pattern: cibw-* | |
| path: dist | |
| merge-multiple: true | |
| - name: Publish to PyPI | |
| if: ${{ github.event.inputs.uploadToPyPI == 'true' }} | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| user: ${{ secrets.PYPI_USERNAME }} | |
| password: ${{ secrets.PYPI_PASSWORD }} | |
| - name: Skipped PyPI Upload | |
| if: ${{ github.event.inputs.uploadToPyPI != 'true' }} | |
| run: echo "Upload to PyPI was skipped due to workflow input." |