Build and Release Patched Patchright #6
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and Release Patched Patchright | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| playwright_version: | |
| description: 'Playwright-Python version tag (e.g. v1.56.0)' | |
| required: true | |
| default: 'v1.56.0' | |
| patchright_release: | |
| description: 'Patchright release version (e.g. 1.56.0)' | |
| required: true | |
| default: '1.56.0' | |
| permissions: | |
| contents: write | |
| jobs: | |
| build-wheels: | |
| name: Build wheels | |
| runs-on: ubuntu-latest | |
| env: | |
| patchright_release: ${{ github.event.inputs.patchright_release }} | |
| playwright_version: ${{ github.event.inputs.playwright_version }} | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v4 | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v4 | |
| - name: Set up Python | |
| run: uv python install 3.11 | |
| - name: Install dependencies | |
| run: | | |
| uv sync --all-groups | |
| git clone https://github.com/microsoft/playwright-python --branch "$playwright_version" | |
| uv add -r playwright-python/local-requirements.txt --dev | |
| - name: Patch Playwright-Python Package | |
| run: uv run patch_python_package.py | |
| - name: Format patched code | |
| run: uvx ruff format playwright-python || true | |
| - name: Build wheels | |
| run: | | |
| cd playwright-python | |
| uv pip install -e . | |
| for wheel in $(uv run setup.py --list-wheels); do | |
| PLAYWRIGHT_TARGET_WHEEL=$wheel uv build --wheel | |
| done | |
| # patchright-python bundles a vanilla driver (its stealth is Python-layer), so | |
| # the driver-level networkidle exclusion has to be added to the bundled | |
| # coreBundle.js here at build time - via ts-morph AST (no string replace, no | |
| # marker), then the wheel RECORD is fixed so the wheel stays install-valid. | |
| - name: Setup Node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '22' | |
| - name: Patch networkidle into bundled driver (ts-morph) | |
| run: | | |
| npm install | |
| python3 patch_wheels_networkidle.py playwright-python/dist | |
| - name: Upload wheel artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: wheels | |
| path: playwright-python/dist/*.whl | |
| release: | |
| name: Create GitHub Release | |
| needs: build-wheels | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Download wheel artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: wheels | |
| path: dist/ | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: v${{ github.event.inputs.patchright_release }} | |
| name: patchright v${{ github.event.inputs.patchright_release }} | |
| body: | | |
| Custom patchright build based on playwright-python ${{ github.event.inputs.playwright_version }}. | |
| Stealth is upstream patchright's Python-layer patching (unchanged). This | |
| fork additionally excludes captcha/analytics/heartbeat requests from | |
| `networkidle` by patching the bundled driver's `coreBundle.js` | |
| (`_inflightRequestStarted`/`_inflightRequestFinished`) via **ts-morph AST** | |
| at build time - no string replace, no marker comment - and fixing the | |
| wheel RECORD. Same exclusion list as the driver-repo `framesPatch.ts`. | |
| Install: `pip install patchright@https://github.com/bugbasesecurity/patchright-python/releases/download/v${{ github.event.inputs.patchright_release }}/patchright-${{ github.event.inputs.patchright_release }}-py3-none-manylinux1_x86_64.whl` | |
| files: dist/*.whl | |
| draft: false | |
| prerelease: false |