|
| 1 | +name: Build bernard-ledit Wheel |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + workflow_dispatch: |
| 6 | + |
| 7 | +permissions: |
| 8 | + contents: read |
| 9 | + |
| 10 | +jobs: |
| 11 | + build-wheel: |
| 12 | + name: Build bernard-ledit wheel |
| 13 | + timeout-minutes: 30 |
| 14 | + strategy: |
| 15 | + fail-fast: false |
| 16 | + matrix: |
| 17 | + os: |
| 18 | + - "ubuntu-22.04" |
| 19 | + - "windows-2022" |
| 20 | + - "macos-latest" |
| 21 | + runs-on: ${{ matrix.os }} |
| 22 | + steps: |
| 23 | + - uses: actions/checkout@v6 |
| 24 | + with: |
| 25 | + submodules: recursive |
| 26 | + |
| 27 | + - name: Set up Python 3.10 |
| 28 | + uses: actions/setup-python@v6 |
| 29 | + with: |
| 30 | + python-version: "3.10" |
| 31 | + |
| 32 | + - name: Resolve bernard-ledit submodule commit |
| 33 | + id: bernard |
| 34 | + shell: bash |
| 35 | + run: echo "sha=$(git -C bernard-ledit rev-parse HEAD)" >> "$GITHUB_OUTPUT" |
| 36 | + |
| 37 | + # Skip the whole Rust/maturin build when the submodule pointer is unchanged. |
| 38 | + - name: Restore cached bernard-ledit build |
| 39 | + id: cache |
| 40 | + uses: actions/cache@v5 |
| 41 | + with: |
| 42 | + path: ./.github/artifacts/bernard-ledit |
| 43 | + key: bernard-ledit-${{ runner.os }}-${{ steps.bernard.outputs.sha }} |
| 44 | + |
| 45 | + - name: Cache downloaded PDFium binary |
| 46 | + if: steps.cache.outputs.cache-hit != 'true' |
| 47 | + uses: actions/cache@v5 |
| 48 | + with: |
| 49 | + path: bernard-ledit/core/.pdfium_cache |
| 50 | + key: pdfium-${{ runner.os }}-${{ hashFiles('bernard-ledit/core/build.rs') }} |
| 51 | + restore-keys: | |
| 52 | + pdfium-${{ runner.os }}- |
| 53 | +
|
| 54 | + - name: Cache Rust build |
| 55 | + if: steps.cache.outputs.cache-hit != 'true' |
| 56 | + uses: Swatinem/rust-cache@v2 |
| 57 | + with: |
| 58 | + workspaces: bernard-ledit |
| 59 | + key: ${{ steps.bernard.outputs.sha }} |
| 60 | + |
| 61 | + - name: Build bernard-ledit wheel |
| 62 | + if: steps.cache.outputs.cache-hit != 'true' |
| 63 | + shell: bash |
| 64 | + run: | |
| 65 | + python -m pip install --upgrade pip |
| 66 | + pip wheel --no-deps --wheel-dir ./.github/artifacts/bernard-ledit bernard-ledit/bindings/python/ |
| 67 | +
|
| 68 | + # The wheel does not embed PDFium; ship the library so consumers can set PDFIUM_PATH. |
| 69 | + - name: Collect bundled PDFium library |
| 70 | + if: steps.cache.outputs.cache-hit != 'true' |
| 71 | + shell: bash |
| 72 | + run: | |
| 73 | + lib=$(find bernard-ledit/core/.pdfium_cache \( -name 'libpdfium.*' -o -name 'pdfium.dll' \) -print | head -n 1) |
| 74 | + if [ -z "$lib" ]; then |
| 75 | + echo "::error::PDFium library not found under bernard-ledit/core/.pdfium_cache after build" |
| 76 | + exit 1 |
| 77 | + fi |
| 78 | + cp "$lib" ./.github/artifacts/bernard-ledit/ |
| 79 | + echo "Bundled PDFium library: $(basename "$lib")" |
| 80 | +
|
| 81 | + - name: Upload bernard-ledit build |
| 82 | + uses: actions/upload-artifact@v4 |
| 83 | + with: |
| 84 | + name: bernard-ledit-wheel-${{ runner.os }} |
| 85 | + path: | |
| 86 | + ./.github/artifacts/bernard-ledit/*.whl |
| 87 | + ./.github/artifacts/bernard-ledit/libpdfium.* |
| 88 | + ./.github/artifacts/bernard-ledit/pdfium.dll |
| 89 | + if-no-files-found: error |
0 commit comments