From 1f6adea83ccf8a12f8aac6554bfefc691f819746 Mon Sep 17 00:00:00 2001 From: Jacob Date: Thu, 15 Feb 2024 09:47:45 +0100 Subject: [PATCH] Update python-publish.yml --- .github/workflows/python-publish.yml | 122 ++++++++++----------------- 1 file changed, 44 insertions(+), 78 deletions(-) diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index e3341b9..1bc4970 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -5,85 +5,51 @@ on: types: [created] jobs: - publish-mac-windows: - strategy: - matrix: - python-version: ["3.6.x", "3.7.x", "3.8.x", "3.9.x", "3.10.x", "3.11.x", "3.12.x"] - os: [macos-latest, windows-latest] - exclude: - - os: macos-latest - runs-on: ${{matrix.os}} - steps: - - uses: actions/checkout@v2 - with: + build_wheels: + name: Build wheels on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + # macos-13 is an intel runner, macos-14 is apple silicon + os: [ubuntu-22.04, windows-2022, macos-13, macos-14] + steps: + - uses: actions/checkout@v4 + with: submodules: true - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: ${{matrix.python-version}} - architecture: ${{matrix.architecture}} - - name: Install Ninja - if: startsWith(matrix.os, 'macOS') - run: | - brew install ninja - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install setuptools wheel twine ninja mypy pybind11 - - name: Build and publish - env: - TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} - TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} - run: | - python setup.py bdist_wheel - twine upload --verbose dist/* + - name: Build wheels + uses: pypa/cibuildwheel@v2.16.5 - publish-unix: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - with: - submodules: true - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: "3.x" - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install setuptools wheel twine mypy pybind11 - - name: build manylinux - uses: RalfG/python-wheels-manylinux-build@v0.5.0-manylinux2014_x86_64 - with: - system-packages: 'ninja-build' - - name: Publish manylinux - env: - TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} - TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} - run: | - twine upload --verbose dist/*-manylinux*.whl + - uses: actions/upload-artifact@v4 + with: + name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }} + path: ./wheelhouse/*.whl + build_sdist: + name: Build source distribution + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Build sdist + run: pipx run build --sdist + + - uses: actions/upload-artifact@v4 + with: + name: cibw-sdist + path: dist/*.tar.gz + + upload_pypi: + needs: [build_wheels, build_sdist] + runs-on: ubuntu-latest + environment: pypi + permissions: + id-token: write + steps: + - uses: actions/download-artifact@v4 + with: + # unpacks all CIBW artifacts into dist/ + pattern: cibw-* + path: dist + merge-multiple: true + - uses: pypa/gh-action-pypi-publish@release/v1 - publish-source: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - with: - submodules: true - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: "3.x" - - name: Install dependencies - run: | - sudo apt update -y - sudo apt install ninja-build -y - python -m pip install --upgrade pip - pip install setuptools wheel twine mypy pybind11 - - name: Build and publish - env: - TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} - TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} - run: | - python setup.py sdist - twine upload --verbose dist/*.tar.gz