|
| 1 | +name: Wheel build |
| 2 | + |
| 3 | +on: |
| 4 | + release: |
| 5 | + types: [created] |
| 6 | + schedule: |
| 7 | + # ┌───────────── minute (0 - 59) |
| 8 | + # │ ┌───────────── hour (0 - 23) |
| 9 | + # │ │ ┌───────────── day of the month (1 - 31) |
| 10 | + # │ │ │ ┌───────────── month (1 - 12 or JAN-DEC) |
| 11 | + # │ │ │ │ ┌───────────── day of the week (0 - 6 or SUN-SAT) |
| 12 | + # │ │ │ │ │ |
| 13 | + - cron: "42 3 * * 4" |
| 14 | + push: |
| 15 | + paths: |
| 16 | + - .github/workflows/wheels.yml |
| 17 | + - requirements.txt |
| 18 | + - pyproject.toml |
| 19 | + - MANIFEST.in |
| 20 | + - Makefile |
| 21 | + - setup.py |
| 22 | + pull_request: |
| 23 | + types: [opened, synchronize, reopened] |
| 24 | + paths: |
| 25 | + - .github/workflows/wheels.yml |
| 26 | + - requirements.txt |
| 27 | + - pyproject.toml |
| 28 | + - MANIFEST.in |
| 29 | + - Makefile |
| 30 | + - setup.py |
| 31 | + workflow_dispatch: |
| 32 | + |
| 33 | +permissions: {} |
| 34 | + |
| 35 | +jobs: |
| 36 | + sdist: |
| 37 | + runs-on: ubuntu-latest |
| 38 | + |
| 39 | + permissions: |
| 40 | + contents: write |
| 41 | + |
| 42 | + steps: |
| 43 | + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 |
| 44 | + |
| 45 | + - name: Set up Python |
| 46 | + uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0 |
| 47 | + with: |
| 48 | + python-version: "3.x" |
| 49 | + |
| 50 | + - name: Install Python dependencies |
| 51 | + run: python -m pip install -U pip setuptools wheel && python -m pip install -U -r requirements.txt |
| 52 | + |
| 53 | + - name: Build sdist |
| 54 | + run: make sdist |
| 55 | + |
| 56 | + - name: Release |
| 57 | + uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844 # v0.1.15 |
| 58 | + if: startsWith(github.ref, 'refs/tags/') |
| 59 | + with: |
| 60 | + files: dist/*.tar.gz |
| 61 | + |
| 62 | + - name: Upload sdist |
| 63 | + uses: actions/upload-artifact@c7d193f32edcb7bfad88892161225aeda64e9392 # v4.0.0 |
| 64 | + with: |
| 65 | + name: sdist |
| 66 | + path: dist/*.tar.gz |
| 67 | + |
| 68 | + generate-wheels-matrix: |
| 69 | + # Create a matrix of all architectures & versions to build. |
| 70 | + # This enables the next step to run cibuildwheel in parallel. |
| 71 | + # From https://iscinumpy.dev/post/cibuildwheel-2-10-0/#only-210 |
| 72 | + name: Generate wheels matrix |
| 73 | + runs-on: ubuntu-latest |
| 74 | + outputs: |
| 75 | + include: ${{ steps.set-matrix.outputs.include }} |
| 76 | + steps: |
| 77 | + - uses: actions/checkout@v4 |
| 78 | + - name: Install cibuildwheel |
| 79 | + # Nb. keep cibuildwheel version pin consistent with job below |
| 80 | + run: pipx install cibuildwheel==2.16.2 |
| 81 | + - id: set-matrix |
| 82 | + run: | |
| 83 | + MATRIX=$( |
| 84 | + { |
| 85 | + cibuildwheel --print-build-identifiers --platform linux \ |
| 86 | + | jq -nRc '{"only": inputs, "os": "ubuntu-latest"}' \ |
| 87 | + && cibuildwheel --print-build-identifiers --platform macos \ |
| 88 | + | jq -nRc '{"only": inputs, "os": "macos-latest"}' \ |
| 89 | + && cibuildwheel --print-build-identifiers --platform windows \ |
| 90 | + | jq -nRc '{"only": inputs, "os": "windows-2019"}' |
| 91 | + } | jq -sc |
| 92 | + ) |
| 93 | + echo "include=$MATRIX" >> $GITHUB_OUTPUT |
| 94 | +
|
| 95 | + build_wheels: |
| 96 | + name: Build wheels on ${{ matrix.only }} |
| 97 | + needs: generate-wheels-matrix |
| 98 | + runs-on: ${{ matrix.os }} |
| 99 | + |
| 100 | + strategy: |
| 101 | + fail-fast: false |
| 102 | + matrix: |
| 103 | + include: ${{ fromJson(needs.generate-wheels-matrix.outputs.include) }} |
| 104 | + |
| 105 | + steps: |
| 106 | + - name: Check out the repo |
| 107 | + uses: actions/checkout@v4 |
| 108 | + |
| 109 | + - name: Set up QEMU |
| 110 | + if: runner.os == 'Linux' |
| 111 | + uses: docker/setup-qemu-action@v3 |
| 112 | + with: |
| 113 | + platforms: all |
| 114 | + |
| 115 | + - name: Build wheels |
| 116 | + |
| 117 | + with: |
| 118 | + only: ${{ matrix.only }} |
| 119 | + |
| 120 | + - uses: actions/upload-artifact@v3 |
| 121 | + with: |
| 122 | + path: ./wheelhouse/*.whl |
| 123 | + name: lxml-wheels |
| 124 | + |
| 125 | + upload_release_assets: |
| 126 | + name: Upload Release Assets |
| 127 | + needs: [ build_wheels ] |
| 128 | + runs-on: ubuntu-latest |
| 129 | + if: startsWith(github.ref, 'refs/tags') |
| 130 | + |
| 131 | + steps: |
| 132 | + - name: Download bdist files |
| 133 | + id: download_artifact |
| 134 | + uses: actions/download-artifact@v3 |
| 135 | + with: |
| 136 | + name: lxml-wheels |
| 137 | + path: ~/downloads |
| 138 | + |
| 139 | + - name: List downloaded artifacts |
| 140 | + run: ls -la ~/downloads |
| 141 | + |
| 142 | + - name: Release |
| 143 | + uses: softprops/action-gh-release@v1 |
| 144 | + with: |
| 145 | + files: ~/downloads/*.whl |
0 commit comments