Fix Linux build: use manylinux_2_28 with GCC 13 for C++23 #29
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: CI | |
| on: | |
| push: | |
| branches: [main, master] | |
| tags: ["v*"] | |
| pull_request: | |
| branches: [main, master] | |
| workflow_dispatch: | |
| jobs: | |
| build: | |
| name: Build wheel | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v5 | |
| - name: Set up Python | |
| run: uv python install 3.12 | |
| - name: Clone libcdoc | |
| run: git clone https://github.com/open-eid/libcdoc.git | |
| - name: Install dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y libssl-dev libxml2-dev zlib1g-dev flatbuffers-compiler libflatbuffers-dev | |
| - name: Build wheel | |
| run: uv build --wheel | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: wheel | |
| path: dist/*.whl | |
| test: | |
| name: Test | |
| needs: build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v5 | |
| - name: Set up Python | |
| run: uv python install 3.12 | |
| - name: Download wheel | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: wheel | |
| path: dist | |
| - name: Install wheel and test | |
| run: | | |
| uv venv | |
| uv pip install dist/*.whl pytest cryptography | |
| uv run --no-project pytest tests/ -v | |
| build_wheels: | |
| name: Build wheels on ${{ matrix.os }} | |
| runs-on: ${{ matrix.os }} | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| os: [ubuntu-latest, macos-latest, windows-latest] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v5 | |
| - name: Clone libcdoc | |
| run: git clone https://github.com/open-eid/libcdoc.git | |
| - name: Install dependencies (Ubuntu) | |
| if: runner.os == 'Linux' | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y libssl-dev libxml2-dev zlib1g-dev | |
| - name: Install dependencies (macOS) | |
| if: runner.os == 'macOS' | |
| run: | | |
| brew install openssl@3 libxml2 flatbuffers cmake swig | |
| - name: Install dependencies (Windows) | |
| if: runner.os == 'Windows' | |
| run: | | |
| vcpkg install zlib:x64-windows libxml2:x64-windows flatbuffers:x64-windows | |
| choco install openssl | |
| - name: Build wheels | |
| uses: pypa/cibuildwheel@v2.22.0 | |
| env: | |
| # Use uv for faster builds | |
| CIBW_BUILD_FRONTEND: "build[uv]" | |
| # Build for Python 3.9-3.13 | |
| CIBW_BUILD: "cp39-* cp310-* cp311-* cp312-* cp313-*" | |
| # Skip 32-bit builds and musllinux | |
| CIBW_SKIP: "*-win32 *-manylinux_i686 *-musllinux_*" | |
| # Use manylinux_2_28 for GCC 13 (C++23 support) | |
| CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_28 | |
| CIBW_MANYLINUX_AARCH64_IMAGE: manylinux_2_28 | |
| # Install build dependencies in the container (need GCC 13 for C++23, OpenSSL 3.x) | |
| CIBW_BEFORE_ALL_LINUX: > | |
| dnf install -y gcc-toolset-13 perl-IPC-Cmd libxml2-devel zlib-devel && | |
| curl -L https://www.openssl.org/source/openssl-3.0.13.tar.gz | tar xz && | |
| cd openssl-3.0.13 && | |
| source /opt/rh/gcc-toolset-13/enable && | |
| ./config --prefix=/usr/local/openssl3 --openssldir=/usr/local/openssl3 && | |
| make -j$(nproc) && | |
| make install | |
| CIBW_ENVIRONMENT_LINUX: > | |
| OPENSSL_ROOT_DIR=/usr/local/openssl3 | |
| PKG_CONFIG_PATH=/usr/local/openssl3/lib64/pkgconfig | |
| PATH=/opt/rh/gcc-toolset-13/root/usr/bin:$PATH | |
| LD_LIBRARY_PATH=/opt/rh/gcc-toolset-13/root/usr/lib64:$LD_LIBRARY_PATH | |
| # Install flatbuffers from source on Linux | |
| CIBW_BEFORE_BUILD_LINUX: > | |
| uv pip install --system cmake swig && | |
| if ! command -v flatc; then | |
| cd /tmp && | |
| curl -L https://github.com/google/flatbuffers/archive/refs/tags/v24.3.25.tar.gz | tar xz && | |
| cd flatbuffers-24.3.25 && | |
| cmake -B build -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_BUILD_TESTS=OFF && | |
| cmake --build build --target install; | |
| fi | |
| # cmake and swig installed via brew in Install dependencies step | |
| CIBW_BEFORE_BUILD_WINDOWS: uv pip install --system cmake swig | |
| # Set vcpkg toolchain for Windows | |
| CIBW_ENVIRONMENT_WINDOWS: > | |
| CMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake | |
| # Set OpenSSL path on macOS; Homebrew OpenSSL requires macOS 15+ | |
| CIBW_ENVIRONMENT_MACOS: > | |
| OPENSSL_ROOT_DIR=/opt/homebrew/opt/openssl@3 | |
| CMAKE_PREFIX_PATH=/opt/homebrew | |
| MACOSX_DEPLOYMENT_TARGET=15.0 | |
| # Repair wheels | |
| CIBW_REPAIR_WHEEL_COMMAND_LINUX: auditwheel repair -w {dest_dir} {wheel} | |
| CIBW_REPAIR_WHEEL_COMMAND_MACOS: delocate-wheel -w {dest_dir} {wheel} | |
| # Test the wheel | |
| CIBW_TEST_REQUIRES: pytest | |
| CIBW_TEST_COMMAND: pytest {project}/tests -v | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: wheels-${{ matrix.os }} | |
| path: ./wheelhouse/*.whl | |
| build_sdist: | |
| name: Build source distribution | |
| runs-on: ubuntu-latest | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v5 | |
| - name: Clone libcdoc | |
| run: git clone https://github.com/open-eid/libcdoc.git | |
| - name: Build sdist | |
| run: uv build --sdist | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: sdist | |
| path: dist/*.tar.gz | |
| publish: | |
| name: Publish to PyPI | |
| needs: [build_wheels, build_sdist] | |
| runs-on: ubuntu-latest | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| environment: | |
| name: pypi | |
| url: https://pypi.org/p/pycdoc | |
| permissions: | |
| id-token: write | |
| steps: | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| pattern: wheels-* | |
| path: dist | |
| merge-multiple: true | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| name: sdist | |
| path: dist | |
| - name: Publish to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 |