CI: Upgrade workflow for up/download artifacts@v4 #201
Workflow file for this run
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 test, upload to PyPI on release | |
on: | |
push: | |
branches: | |
- master | |
- '*' | |
tags: | |
- '*' | |
pull_request: | |
branches: | |
- master | |
env: | |
CIBW_TEST_REQUIRES: ddt | |
CIBW_TEST_COMMAND: "cd {project} && python -m unittest -v" | |
CIBW_MANYLINUX_X86_64_IMAGE: "manylinux2014" | |
CIBW_MANYLINUX_I686_IMAGE: "manylinux2014" | |
CIBW_MANYLINUX_PYPY_X86_64_IMAGE: "manylinux2014" | |
CIBW_MANYLINUX_PYPY_I686_IMAGE: "manylinux2014" | |
CIBW_SKIP: "cp36-*" | |
MACOSX_DEPLOYMENT_TARGET: "10.9" | |
jobs: | |
build_wheel_linux: | |
name: Build wheels on Linux (${{ matrix.wheel_arch }}) | |
runs-on: ubuntu-20.04 | |
strategy: | |
fail-fast: false | |
matrix: | |
wheel_arch: [x86_64, i686] | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
fetch-depth: 0 | |
- uses: actions/setup-python@v5 | |
name: Install Python | |
with: | |
python-version: '3.8' | |
- name: Build wheels (manylinux) | |
uses: pypa/cibuildwheel@v2.16.2 | |
env: | |
CIBW_BEFORE_BUILD: "yum install -y flex bison && | |
pip install cmake wheel && | |
{package}/scripts/build_igraph.sh && | |
{package}/scripts/build_libleidenalg.sh " | |
CIBW_ARCHS_LINUX: ${{ matrix.wheel_arch }} | |
CIBW_BUILD: "*-manylinux_${{ matrix.wheel_arch }}" | |
CIBW_ENVIRONMENT: > | |
CFLAGS='-I/project/build-deps/install/include/ -L/project/build-deps/install/lib64/ -L/project/build-deps/install/lib/' | |
LD_LIBRARY_PATH='/project/build-deps/install/lib64/:/project/build-deps/install/lib/' | |
- name: Build wheels (musllinux) | |
uses: pypa/cibuildwheel@v2.16.2 | |
env: | |
CIBW_BEFORE_BUILD: "apk add flex bison zlib-dev && | |
pip install cmake wheel && | |
{package}/scripts/build_igraph.sh && | |
{package}/scripts/build_libleidenalg.sh" | |
CIBW_BUILD: "*-musllinux_${{ matrix.wheel_arch }}" | |
CIBW_TEST_EXTRAS: "test-musl" | |
CIBW_ENVIRONMENT: > | |
CFLAGS='-I/project/build-deps/install/include/ -L/project/build-deps/install/lib64/ -L/project/build-deps/install/lib/' | |
LD_LIBRARY_PATH='/project/build-deps/install/lib64/:/project/build-deps/install/lib/' | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: wheels-linux-${{ matrix.wheel_arch }} | |
path: ./wheelhouse/*.whl | |
build_wheel_linux_aarch64: | |
name: Build wheels on Linux (aarch64) | |
runs-on: ubuntu-20.04 | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
fetch-depth: 0 | |
- name: Set up QEMU | |
id: qemu | |
uses: docker/setup-qemu-action@v3 | |
- name: Build wheels (manylinux) | |
uses: pypa/cibuildwheel@v2.16.2 | |
env: | |
CIBW_BEFORE_BUILD: "yum install -y flex bison zlib-devel && | |
pip install cmake wheel && | |
{package}/scripts/build_igraph.sh && | |
{package}/scripts/build_libleidenalg.sh" | |
CIBW_ARCHS_LINUX: aarch64 | |
CIBW_BUILD: "*-manylinux_aarch64" | |
CIBW_ENVIRONMENT: > | |
CFLAGS='-I/project/build-deps/install/include/ -L/project/build-deps/install/lib64/ -L/project/build-deps/install/lib/' | |
LD_LIBRARY_PATH='/project/build-deps/install/lib64/:/project/build-deps/install/lib/' | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: wheels-linux-aarch64 | |
path: ./wheelhouse/*.whl | |
build_wheel_macos: | |
name: Build wheels on macOS (${{ matrix.wheel_arch }}) | |
runs-on: macos-latest | |
env: | |
LLVM_VERSION: "14.0.5" | |
strategy: | |
matrix: | |
include: | |
- cmake_arch: x86_64 | |
wheel_arch: x86_64 | |
- cmake_arch: arm64 | |
extra_cmake_args: -DF2C_EXTERNAL_ARITH_HEADER=../../../etc/arith_apple_m1.h -DIEEE754_DOUBLE_ENDIANNESS_MATCHES=ON | |
wheel_arch: arm64 | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
fetch-depth: 0 | |
- name: Cache installed C core | |
id: cache-c-core | |
uses: actions/cache@v3 | |
with: | |
path: build-deps | |
key: C-core-cache-${{ runner.os }}-${{ matrix.cmake_arch }}-llvm${{ env.LLVM_VERSION }}-${{ hashFiles('scripts/build_igraph.sh') }}-${{ hashFiles('scripts/build_libleidenalg.sh') }} | |
- uses: actions/setup-python@v5 | |
name: Install Python | |
with: | |
python-version: '3.8' | |
- name: Install OS dependencies | |
if: steps.cache-c-core.outputs.cache-hit != 'true' || steps.cache-c-deps.outputs.cache-hit != 'true' # Only needed when building the C core | |
run: | |
brew install ninja cmake | |
- name: Build wheels | |
uses: pypa/cibuildwheel@v2.16.2 | |
env: | |
CIBW_ARCHS_MACOS: "${{ matrix.wheel_arch }}" | |
CIBW_BEFORE_BUILD: "{package}/scripts/build_igraph.sh && | |
{package}/scripts/build_libleidenalg.sh" | |
CIBW_ENVIRONMENT: > | |
CFLAGS='-Wno-unused-command-line-argument -I/Users/runner/work/leidenalg/leidenalg/build-deps/install/include/ -L/Users/runner/work/leidenalg/leidenalg/build-deps/install/lib64/ -L/Users/runner/work/leidenalg/leidenalg/build-deps/install/lib/' | |
REPAIR_LIBRARY_PATH="${DYLD_LIBRARY_PATH}:/Users/runner/work/leidenalg/leidenalg/build-deps/install/lib64/:/Users/runner/work/leidenalg/leidenalg/build-deps/install/lib/" | |
EXTRA_CMAKE_ARGS="-DCMAKE_OSX_ARCHITECTURES=${{ matrix.cmake_arch }} ${{ matrix.extra_cmake_args }}" | |
CIBW_REPAIR_WHEEL_COMMAND: > | |
DYLD_LIBRARY_PATH=$REPAIR_LIBRARY_PATH delocate-wheel --require-archs {delocate_archs} -w {dest_dir} -v {wheel} | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: wheels-macos-${{ matrix.wheel_arch }} | |
path: ./wheelhouse/*.whl | |
build_wheel_win: | |
name: Build wheels on Windows (${{ matrix.cmake_arch }}) | |
runs-on: windows-2022 | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- cmake_arch: Win32 | |
wheel_arch: win32 | |
- cmake_arch: x64 | |
wheel_arch: win_amd64 | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
fetch-depth: 0 | |
- uses: actions/setup-python@v5 | |
name: Install Python | |
with: | |
python-version: '3.8' | |
- name: Cache installed C core | |
id: cache-c-core | |
uses: actions/cache@v3 | |
with: | |
path: build-deps | |
key: C-core-cache-${{ runner.os }}-${{ matrix.cmake_arch }}-llvm${{ env.LLVM_VERSION }}-${{ hashFiles('scripts/build_igraph.sh') }}-${{ hashFiles('scripts/build_libleidenalg.sh') }} | |
- name: Install build dependencies | |
if: steps.cache-c-core.outputs.cache-hit != 'true' # Only needed when building the C core | |
run: choco install winflexbison3 cmake ninja | |
- name: Build wheels | |
uses: pypa/cibuildwheel@v2.16.2 | |
env: | |
CIBW_BEFORE_BUILD: "{package}/scripts/build_igraph.bat && | |
{package}/scripts/build_libleidenalg.bat && | |
pip install delvewheel" | |
CIBW_BUILD: "*-${{ matrix.wheel_arch }}" | |
CIBW_TEST_COMMAND: "cd /d {project} && python -m unittest -v" | |
CIBW_SKIP: "cp36-* pp*" | |
CIBW_ENVIRONMENT: > | |
LIB="D:/a/leidenalg/leidenalg/build-deps/install/lib;$LIB" | |
INCLUDE="D:/a/leidenalg/leidenalg/build-deps/install/include/;$INCLUDE" | |
PATH="D:/a/leidenalg/leidenalg/build-deps/install/bin;$PATH" | |
EXTRA_CMAKE_ARGS="-A ${{ matrix.cmake_arch }}" | |
CIBW_REPAIR_WHEEL_COMMAND: "delvewheel repair -w {dest_dir} {wheel}" | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: wheels-win-${{ matrix.wheel_arch }} | |
path: ./wheelhouse/*.whl | |
build_sdist: | |
name: Build sdist | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true | |
fetch-depth: 0 | |
- uses: actions/setup-python@v5 | |
name: Install Python | |
with: | |
python-version: '3.8' | |
- name: Install pypa/build | |
run: pip3 install build | |
- name: Build sdist | |
run: | | |
python3 -m build --sdist | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: wheels-sdist | |
path: dist/*.tar.gz | |
upload_pypi: | |
needs: [build_wheel_linux, build_wheel_linux_aarch64, build_wheel_macos, build_wheel_win, build_sdist] | |
runs-on: ubuntu-latest | |
# upload to PyPI on every push from the master branch | |
if: github.event_name == 'push' && | |
startsWith(github.ref, 'refs/tags') | |
steps: | |
- uses: actions/download-artifact@v4 | |
with: | |
name: wheels-* | |
merge-multiple: true | |
path: dist | |
# Upload tagged versions to production PyPI | |
- name: Publish distribution 📦 to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
password: ${{ secrets.PYPI_API_TOKEN }} |