name: Wheel build on: release: types: [created] schedule: # ┌───────────── minute (0 - 59) # │ ┌───────────── hour (0 - 23) # │ │ ┌───────────── day of the month (1 - 31) # │ │ │ ┌───────────── month (1 - 12 or JAN-DEC) # │ │ │ │ ┌───────────── day of the week (0 - 6 or SUN-SAT) # │ │ │ │ │ - cron: "42 3 * * 4" push: paths: - .github/workflows/wheels.yml - requirements.txt - pyproject.toml - MANIFEST.in - Makefile - setup* - build* pull_request: types: [opened, synchronize, reopened] paths: - .github/workflows/wheels.yml - requirements.txt - pyproject.toml - MANIFEST.in - Makefile - setup* - build* workflow_dispatch: concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }} cancel-in-progress: true permissions: {} env: ZLIB_VERSION: "1.3.2" LIBICONV_VERSION: "1.18" LIBXML2_VERSION: "2.14.6" LIBXSLT_VERSION: "1.1.43" jobs: cache_libs: strategy: fail-fast: false matrix: os: - "ubuntu-22.04" - "ubuntu-22.04-arm" - "macos-latest" - "windows-2022" # win32 - "windows-latest" # win_amd64 - "windows-11-arm" runs-on: ${{ matrix.os }} steps: - name: Check out the repo uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 - name: Cache [libs] uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 with: path: | libs/*.xz libs/*.gz libs/*.zip key: libs-${{ runner.os }}-${{ matrix.os == 'windows-2022' && 'i686' || runner.arch }}-${{ env.LIBXML2_VERSION }}-${{ env.LIBXSLT_VERSION }}-${{ env.LIBICONV_VERSION }}-${{ env.ZLIB_VERSION }} - name: Download latest libraries env: GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: python3 buildlibxml.py --download-only ${{ matrix.os == 'windows-2022' && 'win32' || '' }} sdist: runs-on: ubuntu-24.04 permissions: contents: write steps: - name: Check out the repo uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 - name: Set up Python uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0 with: python-version: "3.x" - name: Install lib dependencies run: sudo apt-get update -y -q && sudo apt-get install -y -q "libxml2=2.9.14*" "libxml2-dev=2.9.14*" libxslt1.1 libxslt1-dev - name: Install Python dependencies run: python -m pip install -U pip setuptools && python -m pip install -U docutils pygments sphinx sphinx-rtd-theme -r requirements.txt - name: Build docs and sdist run: make html sdist env: { STATIC_DEPS: false; CFLAGS="-Og" } # it's run-once, so build more quickly - name: Upload sdist uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 with: name: sdist path: dist/*.tar.gz - name: Upload website uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 with: name: website path: doc/html generate-wheels-matrix: # Create a matrix of all architectures & versions to build. # This enables the next step to run cibuildwheel in parallel. # From https://iscinumpy.dev/post/cibuildwheel-2-10-0/#only-210 name: Generate wheels matrix runs-on: ubuntu-24.04 outputs: include: ${{ steps.set-matrix.outputs.include }} steps: - name: Check out the repo uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 - name: Install cibuildwheel # Nb. keep cibuildwheel version pin consistent with job below run: pipx install cibuildwheel==4.2.0 - id: set-matrix run: | MATRIX=$( { cibuildwheel --print-build-identifiers --platform linux \ | jq -nRc '{"only": inputs, "os": "ubuntu-22.04"}' \ | sed -e '/aarch64\|armv7l/s|ubuntu-22.04|ubuntu-22.04-arm|' \ && cibuildwheel --print-build-identifiers --platform macos \ | jq -nRc '{"only": inputs, "os": "macos-latest"}' \ && cibuildwheel --print-build-identifiers --platform windows \ | jq -nRc '{"only": inputs, "os": "windows-2022"}' \ && cibuildwheel --print-build-identifiers --platform windows --archs ARM64 \ | jq -nRc '{"only": inputs, "os": "windows-11-arm"}' } | jq -sc ) echo "include=$MATRIX" echo "include=$MATRIX" >> $GITHUB_OUTPUT build_wheels: name: Build for ${{ matrix.only }} needs: [ cache_libs, generate-wheels-matrix ] runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: include: ${{ fromJson(needs.generate-wheels-matrix.outputs.include) }} steps: - name: Check out the repo uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 - name: Cache [libs] uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 with: path: | libs/*.xz libs/*.gz libs/*.zip key: libs-${{ runner.os }}-${{ contains(matrix.only, 'win32') && 'i686' || runner.arch }}-${{ env.LIBXML2_VERSION }}-${{ env.LIBXSLT_VERSION }}-${{ env.LIBICONV_VERSION }}-${{ env.ZLIB_VERSION }} - name: Set up QEMU if: runner.os == 'Linux' uses: docker/setup-qemu-action@96fe6ef7f33517b61c61be40b68a1882f3264fb8 # v4.2.0 with: platforms: all - name: Build wheels uses: pypa/cibuildwheel@1828c10ab37f080699c7b81cea34097c684a7074 # v4.2.0 env: GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: only: ${{ matrix.only }} - name: Build Py3.8 wheels if: startsWith(matrix.only, 'cp39-macos') || matrix.only == 'cp39-musllinux_x86_64' || matrix.only == 'cp39-win_amd64' # Keep cibuildwheel at 3.4.1 here. uses: pypa/cibuildwheel@8d2b08b68458a16aeb24b64e68a09ab1c8e82084 # v3.4.1 env: CIBW_BUILD: "cp38*" - name: Build old Linux wheels if: matrix.only == 'cp39-manylinux_x86_64' || matrix.only == 'cp39-manylinux_aarch64' # Keep cibuildwheel at 3.4.1 here. uses: pypa/cibuildwheel@8d2b08b68458a16aeb24b64e68a09ab1c8e82084 # v3.4.1 env: CIBW_BUILD: "${{ contains(matrix.only, 'x86_64') && '*-manylinux_i686 *-manylinux_x86_64' || '*-manylinux_aarch64' }}" CIBW_MANYLINUX_i686_IMAGE: manylinux2014 CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014 CIBW_MANYLINUX_AARCH64_IMAGE: manylinux2014 - name: Upload wheels uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 with: path: ./wheelhouse/*.whl name: lxml-wheel-${{ matrix.only }} upload_release_assets: name: Upload Release Assets needs: [ sdist, build_wheels ] runs-on: ubuntu-latest permissions: contents: write defaults: run: shell: bash steps: - name: Download artifacts uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 with: path: ./release_upload pattern: lxml-wheel-* merge-multiple: true - name: Upload wheels uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 with: path: ./release_upload/*.whl name: all_wheels - name: List downloaded artifacts run: | cd ./release_upload ls -la echo; echo "Wheels built: "; ls *.whl | wc -l echo; echo "Validating wheel success…" RESULT_CODE=0 for PYVERSION in 38 39 310 311 312 313 314 315 ; do \ for WHEEL_ARCH in "win32" "win_amd64" "win_arm64" "manylinux*i686" "manylinux*x86_64" "musllinux*x86_64" "macosx"; do \ [[ "${PYVERSION}-${WHEEL_ARCH}" == "315"*"i686" ]] && continue; \ [[ "${PYVERSION}-${WHEEL_ARCH}" == "38-win_arm64" ]] && continue; \ ls *-cp${PYVERSION}-*${WHEEL_ARCH}*.whl >/dev/null 2>&1 || { echo "MISSING WHEEL: cp${PYVERSION}-${WHEEL_ARCH}" ; RESULT_CODE=1; } ; \ done; \ done; \ exit ${RESULT_CODE} - name: Release uses: softprops/action-gh-release@718ea10b132b3b2eba29c1007bb80653f286566b # v3.0.1 if: github.ref_type == 'tag' with: files: | ./release_upload/*.whl ./release_upload/*.tar.gz