diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index da534b1..1ad11fe 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -6,43 +6,48 @@ on: jobs: build: - name: build - ${{ matrix.runs-on }} + name: build - ${{ matrix.platform }} runs-on: ${{ matrix.runs-on }} permissions: contents: write strategy: fail-fast: false matrix: - runs-on: [ubuntu-latest, ubuntu-24.04-arm, macos-latest] + include: + - platform: linux-x86_64 + runs-on: ubuntu-latest + - platform: linux-arm64 + runs-on: ubuntu-24.04-arm + - platform: macos + runs-on: macos-latest steps: - uses: actions/checkout@v6 - uses: actions/setup-python@v6 + if: runner.os != 'Linux' with: python-version: "3.14" - - name: Install build dependencies - run: ./setup.sh + - name: Build wheels + run: ./build_wheels.sh dist/ - - name: build and release wheels + - name: Upload releases env: GH_TOKEN: ${{ github.token }} run: | - pip install build - for toml in */pyproject.toml; do [ -f "$toml" ] || continue pkg="$(dirname "$toml")" + module="${pkg//-/_}" version=$(python3 -c "import tomllib; print(tomllib.load(open('$toml', 'rb'))['project']['version'])") tag="${pkg}/v${version}" echo "=========================================" - echo "Building: $pkg v$version" + echo "Uploading: $pkg v$version" echo "=========================================" - python -m build --wheel "$pkg" - whl=$(ls "$pkg"/dist/*.whl) - echo "Uploading: $whl" + whl=$(ls dist/${module}-${version}-*.whl 2>/dev/null) || continue + echo "Wheel: $whl" if gh release view "$tag" --repo "$GITHUB_REPOSITORY" &>/dev/null; then gh release upload "$tag" "$whl" --repo "$GITHUB_REPOSITORY" --clobber else diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 402d7b9..e997200 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -22,16 +22,12 @@ jobs: steps: - uses: actions/checkout@v6 - uses: actions/setup-python@v6 + if: runner.os != 'Linux' with: python-version: "3.14" - - name: Install build dependencies - run: ./setup.sh - name: Build wheels - run: | - for pkg in */pyproject.toml; do - pip wheel "./$(dirname "$pkg")" --no-deps --wheel-dir dist/ - done - - name: Smoketest locally + run: ./build_wheels.sh dist/ + - name: Smoketest run: bash smoketest.sh dist/ - uses: actions/upload-artifact@v4 with: @@ -51,6 +47,8 @@ jobs: runs-on: ubuntu-latest - image: ubuntu:24.04 runs-on: ubuntu-latest + - image: ubuntu:20.04 + runs-on: ubuntu-latest - image: fedora:41 runs-on: ubuntu-latest - image: archlinux:latest diff --git a/build_wheels.sh b/build_wheels.sh new file mode 100755 index 0000000..4950475 --- /dev/null +++ b/build_wheels.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env bash +set -euo pipefail + +DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +cd "$DIR" + +WHEEL_DIR="${1:-dist}" + +# on Linux, build inside manylinux_2_28 container for glibc 2.28 compatibility. +# for reference, Ubuntu 20.04 is glibc 2.31, so this gives us wide compatibility. +if [ "$(uname)" = "Linux" ] && [ -z "${MANYLINUX:-}" ]; then + ARCH="$(uname -m)" + IMAGE="quay.io/pypa/manylinux_2_28_${ARCH}" + exec docker run --rm \ + -e MANYLINUX=1 \ + -v "$DIR:/work" \ + -w /work \ + "$IMAGE" \ + bash build_wheels.sh "$WHEEL_DIR" +fi + +# Set up Python inside manylinux container +if [ -n "${MANYLINUX:-}" ]; then + export PATH="/opt/python/cp312-cp312/bin:$PATH" +fi + +./setup.sh +pip install setuptools wheel + +mkdir -p "$WHEEL_DIR" +for pkg in */pyproject.toml; do + pip wheel "./$(dirname "$pkg")" --no-deps --wheel-dir "$WHEEL_DIR"/ +done diff --git a/setup.sh b/setup.sh index 999cc07..0cc73ef 100755 --- a/setup.sh +++ b/setup.sh @@ -3,6 +3,8 @@ set -euo pipefail if [ "$(uname)" = "Darwin" ]; then brew install nasm pkg-config -else +elif command -v dnf &>/dev/null; then + dnf install -y nasm cmake gcc-c++ pkgconfig git perl-IPC-Cmd +elif command -v apt-get &>/dev/null; then sudo apt-get update && sudo apt-get install -y nasm cmake g++ pkg-config fi