Build Wheels and upload (if new release) to PyPI #143
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: Build Wheels and upload (if new release) to PyPI | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| release: | |
| types: | |
| - published | |
| jobs: | |
| build_wheels: | |
| name: Build wheels on ${{ matrix.os }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| matrix: | |
| os: [ubuntu-latest, ubuntu-24.04-arm, windows-latest, macos-14, macos-15-intel, macos-26] | |
| include: | |
| - os: macos-14 | |
| llvm: llvm@15 | |
| macos_deployment_target: "14.0" | |
| - os: macos-15-intel | |
| llvm: llvm@18 | |
| macos_deployment_target: "15.0" | |
| - os: macos-26 | |
| llvm: llvm@20 | |
| macos_deployment_target: "26.0" | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set compiler on macOS to GCC | |
| if: startsWith(matrix.os, 'macos') | |
| run: | | |
| brew install libomp | |
| echo "MACOSX_DEPLOYMENT_TARGET=${{ matrix.macos_deployment_target }}" >> $GITHUB_ENV | |
| echo "CC=gcc-15" >> $GITHUB_ENV | |
| echo "CXX=g++-15" >> $GITHUB_ENV | |
| - name: Install libtiff (macOS) | |
| if: startsWith(matrix.os, 'macos') | |
| run: | | |
| brew install libtiff | |
| - name: Build wheels | |
| uses: pypa/cibuildwheel@v2.23.3 | |
| with: | |
| package-dir: . | |
| output-dir: wheelhouse | |
| config-file: "{package}/pyproject.toml" | |
| env: | |
| CIBW_SKIP: "pp* *musllinux*" | |
| CIBW_BEFORE_BUILD_LINUX: | | |
| yum install -y libtiff-devel | |
| CIBW_BEFORE_ALL_WINDOWS: | | |
| vcpkg install tiff:x64-windows | |
| vcpkg install tiff:x86-windows | |
| CIBW_CONFIG_SETTINGS_WINDOWS: > | |
| cmake.define.CMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: pyvale-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: pyvale-sdist | |
| path: dist/*.tar.gz | |
| upload_pypi: | |
| needs: [build_wheels, build_sdist] | |
| runs-on: ubuntu-latest | |
| environment: pypi | |
| permissions: | |
| id-token: write | |
| if: github.event_name == 'release' && github.event.action == 'published' | |
| steps: | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| pattern: pyvale-* | |
| path: dist | |
| merge-multiple: true | |
| # upload to pypi | |
| - uses: pypa/gh-action-pypi-publish@release/v1 | |
| #with: | |
| # repository-url: https://test.pypi.org/legacy/ |