[CI] Bump actions to v4 #87
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
name: Build and upload to PyPI | |
# Build on every branch push, tag push, and pull request change: | |
# on: [push, pull_request] | |
# Alternatively, to publish when a (published) GitHub Release is created, use the following: | |
on: | |
push: | |
pull_request: | |
release: | |
types: | |
- published | |
jobs: | |
build_wheels: | |
name: Build wheels on ${{ matrix.os }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
# Note: builds on these are backward compatible | |
# (Linux builds use manylinux Docker containers) | |
# (macOS builds target old versions by default) | |
os: [ubuntu-latest, macos-latest, windows-latest] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Build wheels | |
uses: pypa/[email protected] | |
# to supply options, put them in 'env', like: | |
# env: | |
# CIBW_SOME_OPTION: value | |
env: | |
# List of platforms to build on | |
CIBW_BUILD: cp3{8,9,10,11,12}-manylinux_x86_64 cp3{8,9,10,11,12}-macosx_x86_64 cp3{8,9,10,11,12}-macosx_arm64 cp3{8,9,10,11,12}-win_amd64 | |
# Install Eigen and pybind11 on manylinux images (no brew, need Eigen >= 3.4) | |
CIBW_BEFORE_ALL_LINUX: > | |
sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-* && | |
sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-* && | |
yum install -y wget && | |
wget https://gitlab.com/libeigen/eigen/-/archive/3.4.0/eigen-3.4.0.tar.gz && | |
tar xzf eigen-3.4.0.tar.gz && | |
cd eigen-3.4.0 && | |
mkdir build && | |
cd build && | |
cmake .. && | |
make install && | |
cd ../.. | |
CIBW_BEFORE_BUILD_LINUX: pip install pybind11[global] | |
# Install Eigen and pybind11 on macOS | |
CIBW_BEFORE_ALL_MACOS: brew install eigen pybind11 | |
# Install Eigen and pybind11 on Windows | |
CIBW_BEFORE_ALL_WINDOWS: choco install eigen | |
CIBW_BEFORE_BUILD_WINDOWS: pip install pybind11[global] delvewheel | |
# cibuildwheel doesn't yet ship a default repair command for Windows | |
CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: "delvewheel repair -w {dest_dir} {wheel}" | |
# Install test dependencies and run tests | |
CIBW_TEST_REQUIRES: numpy | |
CIBW_TEST_COMMAND: python {project}/tests/test_multistart.py | |
- 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 | |
# upload to PyPI on every tag starting with 'v' | |
# if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') | |
# alternatively, to publish when a GitHub Release is created, use the following rule: | |
if: github.event_name == 'release' && github.event.action == 'published' | |
steps: | |
- uses: actions/download-artifact@v4 | |
with: | |
# unpacks all CIBW artifacts into dist/ | |
pattern: cibw-* | |
path: dist | |
merge-multiple: true | |
- uses: pypa/[email protected] | |
with: | |
user: __token__ | |
password: ${{ secrets.pypi_password }} | |
# To test: repository_url: https://test.pypi.org/legacy/ |