Revamp build to use cross-compilation #24
Workflow file for this run
This file contains 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 | ||
on: | ||
push: | ||
# TODO, uncomment when this is stable | ||
# tags: | ||
# - v* | ||
branches: | ||
- freshen # TODO, switch to main when this is stable | ||
concurrency: | ||
group: build-${{ github.head_ref }} | ||
cancel-in-progress: true | ||
defaults: | ||
run: | ||
shell: bash | ||
jobs: | ||
binary-wheels: | ||
name: Binary wheels for ${{ matrix.config.arch }} on ${{ matrix.config.os }} | ||
runs-on: ${{ matrix.config.os }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
config: | ||
- os: ubuntu-latest | ||
arch: amd64 | ||
- os: windows-latest | ||
arch: amd64 | ||
- os: macos-latest | ||
arch: amd64 | ||
- os: ubuntu-latest | ||
arch: aarch64 | ||
- os: windows-latest | ||
arch: aarch64 | ||
- os: macos-latest | ||
arch: aarch64 | ||
# TODO musl | ||
steps: | ||
- name: Configure git | ||
run: git config --global core.symlinks true | ||
- uses: actions/checkout@v3 | ||
with: | ||
# Fetch all tags | ||
fetch-depth: 0 | ||
- uses: actions/setup-python@v5 | ||
with: | ||
# depot_tools still uses distutils which is gone in 3.12: | ||
python-version: '3.11' | ||
- name: Install deps | ||
run: python -m pip install --upgrade build pytest | ||
- name: Build | ||
run: python -m build --wheel | ||
env: | ||
# The V8 build process is designed for cross-compilation. | ||
# V8 does cross-compilation via a sophisticated system which dynamically copies | ||
# in a wide variety of sysroots (core headers and libraries for build targets). | ||
# In fact, it's somewhat hard to avoid cross-compilition (e.g., as of this | ||
# writing, the V8 *arm64* build config assumes you are cross-compiling from an | ||
# *amd64* build machine). | ||
# So we use cross-compilation in this build; we just run our build on the | ||
# latest Linux, Windows, or Mac image, on amd64, and let V8 build for the | ||
# appropriate target architecture. | ||
# Here we tell V8 what the target is. | ||
# We pass this as an environment variable instead of the wheel --config-setting | ||
# command-line argument because the hatchling build backend drops | ||
# --config-setting on the floor (as opposed to passing it to our build hook): | ||
# https://github.com/pypa/hatch/issues/1072 | ||
MINI_RACER_ARCH: ${{ matrix.config.arch }} | ||
- name: Test wheel | ||
# aarch64 is cross-compiled, so the tests don't work locally: | ||
if: ${{ matrix.config.arch != "aarch64" }} | ||
Check failure on line 79 in .github/workflows/build.yml
|
||
run: | | ||
pip install dist/*.whl | ||
pytest tests | ||
- uses: actions/upload-artifact@v3 | ||
with: | ||
name: artifacts | ||
path: dist/* | ||
if-no-files-found: error | ||
sdist: | ||
name: Build a Python source distribution | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
# Fetch all tags | ||
fetch-depth: 0 | ||
- name: Install deps | ||
run: python -m pip install --upgrade build | ||
- name: Build | ||
run: python -m build --sdist | ||
- uses: actions/upload-artifact@v3 | ||
with: | ||
name: artifacts | ||
path: dist/* | ||
if-no-files-found: error | ||
publish: | ||
name: Publish release | ||
needs: | ||
- binary-wheels | ||
- sdist | ||
runs-on: ubuntu-latest | ||
# TODO uncomment after done testing | ||
# if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags') | ||
steps: | ||
- uses: actions/download-artifact@v3 | ||
with: | ||
name: artifacts | ||
path: dist | ||
- name: Push build artifacts to PyPI | ||
uses: pypa/[email protected] | ||
with: | ||
skip_existing: true | ||
user: __token__ | ||
password: ${{ secrets.PYPI_API_TOKEN }} |