Fix windows and alpine aarch64 #353
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: pypi-build | |
| on: | |
| # For PRs: | |
| pull_request: {} | |
| # For releases: | |
| push: | |
| branches: | |
| - 'release/*' | |
| concurrency: | |
| group: build-${{ github.head_ref }} | |
| defaults: | |
| run: | |
| shell: bash | |
| jobs: | |
| sdist: | |
| name: Build sdist | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: astral-sh/setup-uv@v7 | |
| - uses: actions/checkout@v3 | |
| with: | |
| # Fetch all tags | |
| fetch-depth: 0 | |
| - name: Build | |
| run: uv build --sdist | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: sdist | |
| path: dist/* | |
| if-no-files-found: error | |
| build-dll: | |
| name: Build dll for ${{ matrix.config.name }} | |
| runs-on: ${{ matrix.config.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| config: | |
| - name: win-x64_64 | |
| os: windows-2022 | |
| target_cpu: x64 | |
| - name: win-aarch64 | |
| os: windows-2022 | |
| target_cpu: arm64 | |
| - name: linux-x64_64 | |
| os: ubuntu-24.04 | |
| target_cpu: x64 | |
| - name: linux-aarch64 | |
| os: ubuntu-24.04 | |
| target_cpu: arm64 | |
| - name: macos-x64_64 | |
| os: macos-15-intel | |
| target_cpu: x64 | |
| - name: macos-aarch64 | |
| os: macos-15 | |
| target_cpu: arm64 | |
| - name: linux-aarch64-musl-compat | |
| os: ubuntu-24.04 | |
| target_cpu: arm64 | |
| steps: | |
| - uses: extractions/setup-just@v3 | |
| - uses: astral-sh/setup-uv@v7 | |
| - uses: actions/checkout@v3 | |
| with: | |
| # Fetch all tags | |
| fetch-depth: 0 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| # the v8 build still doesn't work with a system Python > 3.11: | |
| python-version: '3.11' | |
| - run: just git-config-global | |
| - uses: maxim-lobanov/setup-xcode@v1 | |
| if: contains(matrix.config.os, 'macos') | |
| with: | |
| xcode-version: latest-stable | |
| - name: Build dll with v8 | |
| run: just build-dll "--out-path=_dll" "--target-cpu=${{ matrix.config.target_cpu }}" | |
| if: matrix.config.name != 'linux-aarch64-musl-compat' | |
| - name: Build dll with v8 | |
| run: just build-dll "--out-path=_dll" "--target-cpu=${{ matrix.config.target_cpu }}" --aarch64-musl-compat | |
| if: matrix.config.name == 'linux-aarch64-musl-compat' | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: dll-${{ matrix.config.name }} | |
| path: _dll | |
| if-no-files-found: error | |
| build-wheel: | |
| name: Build and test wheel for ${{ matrix.config.name }} | |
| # needs: build-dll | |
| runs-on: ${{ matrix.config.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| config: | |
| - name: win-x64_64 | |
| os: windows-2022 | |
| - name: win-aarch64 | |
| os: windows-11-arm | |
| - name: linux-x64_64 | |
| os: ubuntu-24.04 | |
| - name: linux-aarch64 | |
| os: ubuntu-24.04-arm | |
| - name: macos-x64_64 | |
| os: macos-15-intel | |
| - name: macos-aarch64 | |
| os: macos-15 | |
| steps: | |
| - uses: extractions/setup-just@v3 | |
| if: matrix.config.os != 'windows-11-arm' | |
| - run: choco install just # no Github cargo action for windows-11-arm yet; use choco: | |
| if: matrix.config.os == 'windows-11-arm' | |
| - uses: astral-sh/setup-uv@v7 | |
| - uses: actions/checkout@v3 | |
| with: | |
| # Fetch all tags | |
| fetch-depth: 0 | |
| # By default, uv still uses the x86_64 python in emulation on Windows. | |
| # https://github.com/astral-sh/uv/issues/12906 | |
| # Override this behavior to build an actual aarch64 wheel: | |
| # temp hack remove this | |
| - run: UV_PYTHON=arm64 just build-wheel | |
| if: matrix.config.os == 'windows-11-arm' | |
| # temp hack remove this too | |
| - name: Test wheel (force aarch64) | |
| if: matrix.config.os == 'windows-11-arm' | |
| run: UV_PYTHON=arm64 just test-matrix --python-platform aarch64-pc-windows-msvc | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| name: dll-${{ matrix.config.name }} | |
| path: src/py_mini_racer | |
| - run: just build-wheel | |
| - name: Test wheel | |
| run: just test-matrix | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: wheels-${{ matrix.config.name }} | |
| path: dist/* | |
| if-no-files-found: error | |
| build-alpine-wheel: | |
| name: Build wheel for ${{ matrix.config.name }} | |
| needs: build-dll | |
| runs-on: ${{ matrix.config.image }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| config: | |
| - name: alpine-x64_64 | |
| image: ubuntu-22.04 | |
| dll: linux-x64_64 | |
| - name: alpine-aarch64 | |
| image: ubuntu-22.04-arm | |
| dll: linux-aarch64-musl-compat | |
| container: | |
| image: alpine | |
| options: --user root | |
| # From https://github.com/actions/runner/issues/801?timeline_page=1 | |
| volumes: | |
| - /opt:/opt:rw,rshared | |
| - /opt:/__e/node20:ro,rshared | |
| steps: | |
| # From https://github.com/actions/runner/issues/801?timeline_page=1 | |
| - name: Allow Linux musl containers on ARM64 runners | |
| shell: /bin/sh {0} | |
| if: contains(matrix.config.image, 'arm') | |
| run: | | |
| sed -i "/^ID=/s/alpine/NotpineForGHA/" /etc/os-release | |
| apk add nodejs --update-cache | |
| mkdir /opt/bin | |
| ln -s /usr/bin/node /opt/bin/node | |
| - name: Install deps | |
| shell: /bin/sh {0} | |
| run: | | |
| apk update | |
| apk add bash curl gcompat libgcc uv just | |
| - uses: actions/checkout@v3 | |
| with: | |
| # Fetch all tags | |
| fetch-depth: 0 | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| name: dll-${{ matrix.config.dll }} | |
| path: src/py_mini_racer | |
| - run: just build-wheel | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: wheels-${{ matrix.config.name }} | |
| path: dist/* | |
| if-no-files-found: error | |
| - name: Test wheel | |
| run: | | |
| # We have to use this twisted formulation of sync and then run, splitting | |
| # up what uv normally does for us, because the LD_PRELOAD accidentally | |
| # confuses uv into thinking we're on a glibc Linux and thus it rejects our | |
| # musl wheel. | |
| uv sync --python 3.10 | |
| LD_PRELOAD="/lib/libgcompat.so.0" uv run --frozen --python 3.10 pytest tests | |
| uv sync --python 3.11 | |
| LD_PRELOAD="/lib/libgcompat.so.0" uv run --frozen --python 3.11 pytest tests | |
| uv sync --python 3.12 | |
| LD_PRELOAD="/lib/libgcompat.so.0" uv run --frozen --python 3.12 pytest tests | |
| uv sync --python 3.13 | |
| LD_PRELOAD="/lib/libgcompat.so.0" uv run --frozen --python 3.13 pytest tests | |
| uv sync --python 3.14 | |
| LD_PRELOAD="/lib/libgcompat.so.0" uv run --frozen --python 3.14 pytest tests | |
| release: | |
| name: Create GitHub release | |
| if: startsWith(github.ref, 'refs/heads/release') | |
| needs: | |
| - build-wheel | |
| - build-alpine-wheel | |
| - sdist | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| merge-multiple: true | |
| - name: Compute release version | |
| run: | | |
| VERSION=${GITHUB_REF_NAME#release/} | |
| echo Version: $VERSION | |
| echo "VERSION=$VERSION" >> $GITHUB_ENV | |
| - name: Make release | |
| uses: ncipollo/release-action@v1 | |
| with: | |
| artifacts: "wheels/*,sdist/*" | |
| commit: ${{ github.ref }} | |
| tag: ${{ env.VERSION }} | |
| publish: | |
| name: Upload release to PyPI | |
| if: startsWith(github.ref, 'refs/heads/release') | |
| needs: | |
| - release | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: pypi | |
| url: https://pypi.org/p/mini-racer | |
| permissions: | |
| id-token: write # IMPORTANT: this permission is mandatory for trusted publishing | |
| steps: | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| merge-multiple: true | |
| - name: Make dist directory | |
| run: mkdir dist && cp wheels/* sdist/* dist/ | |
| - name: Publish package distributions to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 |