From ca72521cf179d8f9b21500db3b9f8eea3712f2d0 Mon Sep 17 00:00:00 2001 From: Vincent Fazio Date: Thu, 11 Apr 2024 18:56:20 -0500 Subject: [PATCH] ci: add workflow to build wheels Add a Github workflow to build an sdist archive and wheels for: - x86_64: manylinux2014 & manylinux_2_28 - aarch64: manylinux2014 & manylinux_2_28 Signed-off-by: Vincent Fazio --- .github/workflows/build_wheels.yml | 71 ++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 .github/workflows/build_wheels.yml diff --git a/.github/workflows/build_wheels.yml b/.github/workflows/build_wheels.yml new file mode 100644 index 00000000..5e0dfcc1 --- /dev/null +++ b/.github/workflows/build_wheels.yml @@ -0,0 +1,71 @@ +name: Build + +on: + push: + tags: + # The main purpose of this workflow is to build wheels for release tags. + # It runs automatically on tags matching this pattern. + - "bindings-python-*" + # workflow_dispatch: + # Allow this workflow to be run manually (pushing to testpypi instead of pypi) + +jobs: + build_sdist: + name: Build sdist + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v3 + - name: Build sdist + env: + LIBGPIOD_VERSION: 2.1 + # create the sdist and dump it's contents + run: | + cd bindings/python + pip install build + python3 -m build -s + tar -tvf dist/*.tar.gz + - uses: actions/upload-artifact@v4.3.1 + with: + name: libgpiod-source-dist + path: ./bindings/python/dist/*.tar.gz + + build_wheels: + name: Build libgpiod wheels + needs: [build_sdist] + runs-on: ubuntu-22.04 + strategy: + matrix: + cibw_arch: [x86_64, aarch64] + cibw_manylinux_target: [manylinux2014, manylinux_2_28] + + steps: + - name: Download sdist + uses: actions/download-artifact@v4.1.4 + with: + name: libgpiod-source-dist + path: sdist + - name: Extract sdist + run: | + mkdir extract + tar -C extract/ --strip-components=1 -xvf sdist/*.tar.gz + ls -R extract/ + - name: Set up QEMU + if: ${{ matrix.cibw_arch == 'aarch64' } + uses: docker/setup-qemu-action@v3 + with: + platforms: arm64 + - name: Build wheels + uses: pypa/cibuildwheel@v2.17.0 + env: + CIBW_ARCHS_LINUX: ${{ matrix.cibw_arch }} + CIBW_MANYLINUX_AARCH64_IMAGE: quay.io/pypa/${{matrix.cibw_manylinux_target}}_aarch64 + CIBW_MANYLINUX_X86_64_IMAGE: quay.io/pypa/${{matrix.cibw_manylinux_target}}_x86_64 + CIBW_BUILD: "cp39-* cp310-* cp311-* cp312-*" + CIBW_SKIP: "*musllinux*" + with: + package-dir: ./extract + output-dir: dist + - uses: actions/upload-artifact@v4.3.1 + with: + name: cibw-wheels-${{ matrix.cibw_arch }}-${{ matrix.cibw_manylinux_target }} + path: ./dist/*.whl \ No newline at end of file