fix: match linksocks build logic - use cwd=here and remove cleanup_te… #56
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 Python Bindings | |
| on: | |
| push: | |
| branches: ["**"] | |
| tags: ["v*"] | |
| workflow_dispatch: | |
| inputs: | |
| enable_tmate: | |
| description: "Enable tmate debug session on failure" | |
| required: false | |
| type: boolean | |
| default: false | |
| build_linux_wheels: | |
| description: "Build Linux wheels" | |
| required: false | |
| type: boolean | |
| default: false | |
| build_windows_wheels: | |
| description: "Build Windows wheels" | |
| required: false | |
| type: boolean | |
| default: false | |
| build_macos_wheels: | |
| description: "Build macOS wheels" | |
| required: false | |
| type: boolean | |
| default: false | |
| jobs: | |
| tests: | |
| name: Tests Py${{ matrix.python }} on ${{ matrix.os }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - os: ubuntu-latest | |
| python: "3.9" | |
| - os: ubuntu-latest | |
| python: "3.13" | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set Up Python ${{ matrix.python }} | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python }} | |
| - name: Show Versions | |
| run: | | |
| python --version | |
| pip --version | |
| - name: Upgrade pip | |
| run: | | |
| python -m pip install --upgrade pip | |
| - name: Install masktunnel (Editable, dev extras) | |
| run: | | |
| make python-test-deps PYBIN=python | |
| - name: Verify embedded build (masktunnel_ffi) | |
| run: | | |
| python - <<'PY' | |
| import pathlib | |
| import masktunnel_ffi | |
| import masktunnel_ffi._lib as L | |
| ffi_dir = pathlib.Path(masktunnel_ffi.__file__).resolve().parent | |
| names = [p.name for p in ffi_dir.iterdir()] | |
| # Check for shared library in masktunnel/ directory | |
| masktunnel_dir = ffi_dir.parent / "masktunnel" | |
| if masktunnel_dir.exists(): | |
| names.extend([p.name for p in masktunnel_dir.iterdir()]) | |
| assert any( | |
| (n.endswith((".so", ".dylib", ".dll")) and "masktunnel" in n) | |
| for n in names | |
| ), names | |
| print("ffi_ok", L.version()) | |
| PY | |
| - name: Run Pytest | |
| working-directory: _bindings/python | |
| run: pytest -v -n auto | |
| - name: Start tmate session (manual, on failure) | |
| if: ${{ failure() && github.event_name == 'workflow_dispatch' && inputs.enable_tmate }} | |
| uses: mxschmitt/action-tmate@v3 | |
| with: | |
| limit-access-to-actor: true | |
| build_linux_wheels_x64: | |
| if: ${{ startsWith(github.ref, 'refs/tags/') || (github.event_name == 'workflow_dispatch' && inputs.build_linux_wheels) }} | |
| name: Linux wheel (x64) | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Build + repair inside manylinux container | |
| run: | | |
| set -euxo pipefail | |
| IMAGE="quay.io/pypa/manylinux2014_x86_64" | |
| PLAT="manylinux2014_x86_64" | |
| CPY="cp311-cp311" | |
| docker run --rm \ | |
| -e PLAT="${PLAT}" \ | |
| -v "$PWD":/project \ | |
| -w /project \ | |
| "${IMAGE}" bash -lc "\ | |
| set -euxo pipefail; \ | |
| PY=/opt/python/${CPY}/bin/python; \ | |
| \$PY --version; \ | |
| \$PY -m pip install -U pip build auditwheel; \ | |
| rm -rf /project/wheelhouse_raw /project/wheelhouse_manylinux; \ | |
| cd _bindings/python; \ | |
| \$PY -m build --wheel --outdir /project/wheelhouse_raw/; \ | |
| mkdir -p /project/wheelhouse_manylinux/; \ | |
| auditwheel show /project/wheelhouse_raw/*.whl || true; \ | |
| auditwheel repair --plat \"${PLAT}\" /project/wheelhouse_raw/*.whl -w /project/wheelhouse_manylinux/" | |
| ls -la wheelhouse_manylinux || true | |
| - name: Upload Artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: wheels-linux-x64 | |
| path: ./wheelhouse_manylinux/*.whl | |
| - name: Start tmate session (manual, on failure) | |
| if: ${{ failure() && github.event_name == 'workflow_dispatch' && inputs.enable_tmate }} | |
| uses: mxschmitt/action-tmate@v3 | |
| with: | |
| limit-access-to-actor: true | |
| build_linux_wheels_arm64: | |
| if: ${{ startsWith(github.ref, 'refs/tags/') || (github.event_name == 'workflow_dispatch' && inputs.build_linux_wheels) }} | |
| name: Linux wheel (arm64) | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Build + repair inside manylinux container | |
| run: | | |
| set -euxo pipefail | |
| IMAGE="quay.io/pypa/manylinux2014_aarch64" | |
| PLAT="manylinux2014_aarch64" | |
| CPY="cp311-cp311" | |
| docker run --rm \ | |
| --platform linux/arm64 \ | |
| -e PLAT="${PLAT}" \ | |
| -v "$PWD":/project \ | |
| -w /project \ | |
| "${IMAGE}" bash -lc "\ | |
| set -euxo pipefail; \ | |
| PY=/opt/python/${CPY}/bin/python; \ | |
| \$PY --version; \ | |
| \$PY -m pip install -U pip build auditwheel; \ | |
| rm -rf /project/wheelhouse_raw /project/wheelhouse_manylinux; \ | |
| cd _bindings/python; \ | |
| \$PY -m build --wheel --outdir /project/wheelhouse_raw/; \ | |
| mkdir -p /project/wheelhouse_manylinux/; \ | |
| auditwheel show /project/wheelhouse_raw/*.whl || true; \ | |
| auditwheel repair --plat \"${PLAT}\" /project/wheelhouse_raw/*.whl -w /project/wheelhouse_manylinux/" | |
| ls -la wheelhouse_manylinux || true | |
| - name: Upload Artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: wheels-linux-arm64 | |
| path: ./wheelhouse_manylinux/*.whl | |
| - name: Start tmate session (manual, on failure) | |
| if: ${{ failure() && github.event_name == 'workflow_dispatch' && inputs.enable_tmate }} | |
| uses: mxschmitt/action-tmate@v3 | |
| with: | |
| limit-access-to-actor: true | |
| build_windows_wheels: | |
| if: ${{ startsWith(github.ref, 'refs/tags/') || (github.event_name == 'workflow_dispatch' && inputs.build_windows_wheels) }} | |
| name: Windows wheel (amd64) | |
| runs-on: windows-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set Up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.11" | |
| - name: Build wheel | |
| working-directory: _bindings/python | |
| run: | | |
| python -m pip install --upgrade pip build | |
| python -m build --wheel --outdir ../../wheelhouse/ | |
| - name: Upload Artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: wheels-windows-amd64 | |
| path: ./wheelhouse/*.whl | |
| - name: Start tmate session (manual, on failure) | |
| if: ${{ failure() && github.event_name == 'workflow_dispatch' && inputs.enable_tmate }} | |
| uses: mxschmitt/action-tmate@v3 | |
| with: | |
| limit-access-to-actor: true | |
| build_sdist: | |
| if: startsWith(github.ref, 'refs/tags/') | |
| name: Build source distribution | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Install build dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install build setuptools wheel | |
| - name: Build source distribution | |
| run: | | |
| cd _bindings/python | |
| python -m build --sdist --outdir ../../dist/ | |
| - name: Upload source distribution | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: source-dist | |
| path: ./dist/*.tar.gz | |
| - name: Start tmate session (manual, on failure) | |
| if: ${{ failure() && github.event_name == 'workflow_dispatch' && inputs.enable_tmate }} | |
| uses: mxschmitt/action-tmate@v3 | |
| with: | |
| limit-access-to-actor: true | |
| build_macos_wheels: | |
| if: ${{ startsWith(github.ref, 'refs/tags/') || (github.event_name == 'workflow_dispatch' && inputs.build_macos_wheels) }} | |
| name: macOS wheel (${{ matrix.arch }}) | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - os: macos-15-intel | |
| arch: x64 | |
| - os: macos-14 | |
| arch: arm64 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.11" | |
| - name: Build wheel | |
| working-directory: _bindings/python | |
| run: | | |
| python -m pip install --upgrade pip build | |
| python -m build --wheel --outdir ../../wheelhouse/ | |
| - name: Upload Artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: wheels-macos-${{ matrix.arch }} | |
| path: ./wheelhouse/*.whl | |
| - name: Start tmate session (manual, on failure) | |
| if: ${{ failure() && github.event_name == 'workflow_dispatch' && inputs.enable_tmate }} | |
| uses: mxschmitt/action-tmate@v3 | |
| with: | |
| limit-access-to-actor: true |