diff --git a/.github/workflows/pyodide.yml b/.github/workflows/pyodide.yml index bbc66e9a..876a7ca5 100644 --- a/.github/workflows/pyodide.yml +++ b/.github/workflows/pyodide.yml @@ -3,16 +3,38 @@ name: Build pyodide wheel on: push: branches: [dev] + pull_request: + branches: [dev] workflow_dispatch: -env: - PYTHON_VERSION: 3.12.2 - PYODIDE_VERSION: 0.26.3 - EMSCRIPTEN_VERSION: 3.1.58 - jobs: build-pyodide: - runs-on: macos-latest + # macOS because setup.py's Linux flags break the Emscripten build. Intel + # because GitHub is short on macOS arm64 runners, and jobs waiting for one + # were cancelled. + runs-on: macos-15-intel + strategy: + fail-fast: false + matrix: + # Each Pyodide ABI needs its own wheel. The host Python has to match the + # Python that Pyodide ships, and Emscripten has to match its build. + # `pyodide xbuildenv search --all` lists all three for each release. + include: + # Wheel used by shinylive releases before the move off Pyodide 0.27. + # Newer pyodide-build names it `pyemscripten_2024_0` instead of + # `pyodide_2024_0`, so keep the old one. It needs `wheel<0.46`. + - pyodide: 0.26.3 + python: "3.12" + emscripten: 3.1.58 + pyodide-build: 'pyodide-build==0.26.3 "wheel<0.46"' + - pyodide: 0.29.5 + python: "3.13" + emscripten: 4.0.9 + pyodide-build: "pyodide-build==0.39.3" + - pyodide: 314.0.7 + python: "3.14" + emscripten: 5.0.3 + pyodide-build: "pyodide-build==0.39.3" steps: - uses: actions/checkout@v4 with: @@ -20,24 +42,41 @@ jobs: - uses: actions/setup-python@v5 with: - python-version: ${{ env.PYTHON_VERSION }} + python-version: ${{ matrix.python }} - run: | - # Match pyodide version - # https://github.com/posit-dev/shinylive/blob/main/Makefile#L20C19-L20C25 - pip install pyodide-build==0.26.3 - if [ -z "${{ env.EMSCRIPTEN_VERSION }}"]; then - echo EMSCRIPTEN_VERSION=$(pyodide config get emscripten_version) >> $GITHUB_ENV - fi + pip install ${{ matrix.pyodide-build }} + pyodide xbuildenv install ${{ matrix.pyodide }} - uses: mymindstorm/setup-emsdk@v14 with: - version: ${{ env.EMSCRIPTEN_VERSION }} + version: ${{ matrix.emscripten }} - run: pyodide build + - uses: actions/upload-artifact@v4 + with: + name: wheel-${{ matrix.pyodide }} + path: dist/*.whl + + deploy: + # Pull requests only build, so the wheels can be checked before they are + # published. + if: github.event_name != 'pull_request' + needs: build-pyodide + runs-on: ubuntu-latest + steps: + - uses: actions/download-artifact@v4 + with: + pattern: wheel-* + path: dist + merge-multiple: true + - name: Deploy uses: peaceiris/actions-gh-pages@v4 with: github_token: ${{ secrets.GITHUB_TOKEN }} publish_dir: ./dist + # Add to the wheels already published instead of replacing them. + # Released versions of shinylive download older wheels from here. + keep_files: true