Build and upload to PyPI #336
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 upload to PyPI | |
| on: | |
| schedule: | |
| # trigger build every day at 4:30 UTC | |
| - cron: '30 4 * * *' | |
| push: | |
| tags: | |
| - '*' | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| build_wheels: | |
| name: Build wheels on ${{ matrix.os }} for ${{ matrix.arch }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| # Linux x86_64 | |
| - os: ubuntu-latest | |
| arch: auto | |
| requires-python: ">=3.9,<3.10" | |
| python: 39 | |
| platform_id: manylinux_x86_64 | |
| - os: ubuntu-latest | |
| arch: auto | |
| requires-python: ">=3.10,<3.11" | |
| python: 310 | |
| platform_id: manylinux_x86_64 | |
| - os: ubuntu-latest | |
| arch: auto | |
| requires-python: ">=3.11,<3.12" | |
| python: 311 | |
| platform_id: manylinux_x86_64 | |
| - os: ubuntu-latest | |
| arch: auto | |
| requires-python: ">=3.12,<3.13" | |
| python: 312 | |
| platform_id: manylinux_x86_64 | |
| # Linux aarch64 | |
| - os: ubuntu-latest | |
| arch: aarch64 | |
| requires-python: ">=3.9,<3.10" | |
| python: 39 | |
| platform_id: manylinux_aarch64 | |
| - os: ubuntu-latest | |
| arch: aarch64 | |
| requires-python: ">=3.10,<3.11" | |
| python: 310 | |
| platform_id: manylinux_aarch64 | |
| - os: ubuntu-latest | |
| arch: aarch64 | |
| requires-python: ">=3.11,<3.12" | |
| python: 311 | |
| platform_id: manylinux_aarch64 | |
| - os: ubuntu-latest | |
| arch: aarch64 | |
| requires-python: ">=3.12,<3.13" | |
| python: 312 | |
| platform_id: manylinux_aarch64 | |
| # macOS arm64 | |
| - os: macos-14 | |
| arch: arm64 | |
| requires-python: ">=3.9,<3.10" | |
| python: 39 | |
| platform_id: macosx_arm64 | |
| - os: macos-14 | |
| arch: arm64 | |
| requires-python: ">=3.10,<3.11" | |
| python: 310 | |
| platform_id: macosx_arm64 | |
| - os: macos-14 | |
| arch: arm64 | |
| requires-python: ">=3.11,<3.12" | |
| python: 311 | |
| platform_id: macosx_arm64 | |
| - os: macos-14 | |
| arch: arm64 | |
| requires-python: ">=3.12,<3.13" | |
| python: 312 | |
| platform_id: macosx_arm64 | |
| # macOS x86_64 | |
| - os: macos-13 | |
| arch: x86_64 | |
| requires-python: ">=3.9,<3.10" | |
| python: 39 | |
| platform_id: macosx_x86_64 | |
| - os: macos-13 | |
| arch: x86_64 | |
| requires-python: ">=3.10,<3.11" | |
| python: 310 | |
| platform_id: macosx_x86_64 | |
| - os: macos-13 | |
| arch: x86_64 | |
| requires-python: ">=3.11,<3.12" | |
| python: 311 | |
| platform_id: macosx_x86_64 | |
| - os: macos-13 | |
| arch: x86_64 | |
| requires-python: ">=3.12,<3.13" | |
| python: 312 | |
| platform_id: macosx_x86_64 | |
| # Windows | |
| - os: windows-latest | |
| arch: auto | |
| requires-python: ">=3.9,<3.10" | |
| python: 39 | |
| platform_id: win_amd64 | |
| - os: windows-latest | |
| arch: auto | |
| requires-python: ">=3.10,<3.11" | |
| python: 310 | |
| platform_id: win_amd64 | |
| - os: windows-latest | |
| arch: auto | |
| requires-python: ">=3.11,<3.12" | |
| python: 311 | |
| platform_id: win_amd64 | |
| - os: windows-latest | |
| arch: auto | |
| requires-python: ">=3.12,<3.13" | |
| python: 312 | |
| platform_id: win_amd64 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| submodules: recursive | |
| - name: Add msbuild to PATH | |
| if: ${{ matrix.os == 'windows-latest'}} | |
| uses: microsoft/setup-msbuild@v1.1 | |
| - name: Set up QEMU | |
| if: ${{ matrix.arch == 'aarch64' }} | |
| uses: docker/setup-qemu-action@v3 | |
| with: | |
| platforms: all | |
| # This should be temporary | |
| # xref https://github.com/docker/setup-qemu-action/issues/188 | |
| # xref https://github.com/tonistiigi/binfmt/issues/215 | |
| image: tonistiigi/binfmt:qemu-v8.1.5 | |
| id: qemu | |
| - name: Build web | |
| if: ${{ matrix.os == 'ubuntu-latest' }} | |
| run: | | |
| pip install -r CI/requirements-wheel.txt | |
| cd python && python setup.py build_web && git reset --hard HEAD | |
| - name: Build wheels | |
| uses: pypa/cibuildwheel@v2.16.5 | |
| env: | |
| CIBW_ENVIRONMENT_LINUX: NO_WEB_UI=1 | |
| CIBW_ENVIRONMENT_PASS_LINUX: NO_WEB_UI | |
| CIBW_ARCHS: ${{ matrix.arch }} | |
| CIBW_PROJECT_REQUIRES_PYTHON: ${{ matrix.requires-python }} | |
| CIBW_BEFORE_BUILD_MACOS: pip install -r CI/requirements-wheel.txt && cd python && python setup.py build_web && git reset --hard HEAD | |
| CIBW_BEFORE_BUILD_WINDOWS: pip install -r CI/requirements-wheel.txt && cd python && python setup.py build_web && git reset --hard HEAD | |
| CIBW_TEST_COMMAND: pytest {project}/CI/test_basic_execution.py | |
| CIBW_TEST_REQUIRES: pytest requests | |
| CIBW_BUILD_VERBOSITY: 1 | |
| with: | |
| package-dir: ./python/ | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: wheel-${{ matrix.python }}-${{ matrix.platform_id }} | |
| path: wheelhouse/*.whl | |
| build_sdist: | |
| name: Build source distribution | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| submodules: recursive | |
| - name: Build web | |
| run: | | |
| pip install -r CI/requirements-wheel.txt | |
| cd python && python setup.py build_web && git reset --hard HEAD | |
| - name: Build sdist | |
| run: cd python && pipx run build --sdist | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: sdist | |
| path: ./python/dist/*.tar.gz | |
| upload_pypi: | |
| needs: [build_wheels, build_sdist] | |
| runs-on: ubuntu-latest | |
| # upload to PyPI on every tag starting with 'v' | |
| if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') | |
| permissions: | |
| id-token: write | |
| contents: write | |
| steps: | |
| # Download wheel artifacts | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| pattern: wheel-* | |
| merge-multiple: true | |
| path: dist | |
| # Download sdist artifact | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| name: sdist | |
| path: dist | |
| # if is xorbits repo, upload to pypi | |
| - uses: pypa/gh-action-pypi-publish@release/v1 | |
| if: github.repository == 'xorbitsai/xorbits' | |
| with: | |
| user: __token__ | |
| password: ${{ secrets.PYPI_PASSWORD }} | |
| packages-dir: dist | |
| skip-existing: true | |
| verbose: true | |
| # if is not xorbits repo, upload to test | |
| - uses: pypa/gh-action-pypi-publish@release/v1 | |
| if: github.repository != 'xorbitsai/xorbits' | |
| with: | |
| user: __token__ | |
| password: ${{ secrets.TEST_PYPI_PASSWORD }} | |
| repository-url: https://test.pypi.org/legacy/ | |
| packages-dir: dist | |
| skip-existing: true | |
| verbose: true |