c-kzg-4844/.github/workflows/python-release.yml

121 lines
3.2 KiB
YAML
Raw Permalink Normal View History

2024-02-26 15:48:04 +00:00
name: Python Package
2024-02-21 20:05:47 +00:00
on:
release:
types:
- published
2024-02-21 20:05:47 +00:00
branches:
- main
# Allows us run the action manually.
workflow_dispatch:
2024-02-21 20:05:47 +00:00
jobs:
2024-02-26 16:18:37 +00:00
build-wheels:
2024-02-26 15:48:04 +00:00
name: Build wheels for ${{ matrix.os }}
runs-on: ${{ matrix.os }}
2024-02-21 20:05:47 +00:00
strategy:
matrix:
2024-02-26 15:48:04 +00:00
os:
- ubuntu-latest
- windows-latest
2024-03-04 16:01:25 +00:00
- macos-13 # x86_64
- macos-14 # aarch64
2024-02-21 20:05:47 +00:00
steps:
2024-02-26 15:48:04 +00:00
- uses: actions/checkout@v4
2024-02-21 20:05:47 +00:00
with:
submodules: recursive
2024-02-26 15:48:04 +00:00
2024-03-04 16:01:25 +00:00
# On Linux, use QEMU to build multiple platforms.
2024-02-26 16:18:37 +00:00
- name: Setup QEMU
if: runner.os == 'Linux'
uses: docker/setup-qemu-action@v3
with:
platforms: all
2024-03-04 16:01:25 +00:00
# Need this for macos-14, which doesn't come with python for some reason.
2024-02-26 16:18:37 +00:00
- name: Setup Python
uses: actions/setup-python@v4
2024-03-04 16:01:25 +00:00
with:
python-version: '3.10'
2024-03-04 16:01:25 +00:00
# Need this to get cl.exe on the path.
- name: Set up Visual Studio shell
if: runner.os == 'Windows'
uses: egor-tensin/vs-shell@v2
2024-02-26 15:48:04 +00:00
- name: Install cibuildwheel
run: python -m pip install cibuildwheel==2.16.5
- name: Build wheels
run: python -m cibuildwheel --output-dir wheelhouse
2024-02-26 16:18:37 +00:00
env:
2024-03-04 16:01:25 +00:00
# We have QEMU setup and can build everything.
2024-02-27 22:48:54 +00:00
CIBW_ARCHS_LINUX: x86_64 i686 aarch64
2024-03-04 16:01:25 +00:00
# For some reason these don't use the same distro.
# musllinux uses apk & manylinux uses yum.
2024-02-27 22:48:54 +00:00
CIBW_BEFORE_BUILD_LINUX: |
if command -v apk > /dev/null; then
2024-03-04 16:01:25 +00:00
apk add --update clang && make -C src blst
2024-02-27 22:48:54 +00:00
elif command -v yum > /dev/null; then
2024-03-04 16:01:25 +00:00
yum install -y clang && make -C src blst
2024-02-27 22:48:54 +00:00
fi
2024-03-04 16:01:25 +00:00
# Building x86 (32-bit) package is difficult.
# We're missing the 32-bit Python library.
CIBW_ARCHS_WINDOWS: AMD64
# We need blst.lib (via MSVC) which our Makefile doesn't support.
2024-02-27 22:48:54 +00:00
CIBW_BEFORE_BUILD_WINDOWS: |
2024-03-04 16:01:25 +00:00
cd blst && build.bat && cp blst.lib ../lib && cp bindings/*.h ../inc
2024-02-27 22:48:54 +00:00
CIBW_BEFORE_BUILD_MACOS: |
2024-03-04 16:01:25 +00:00
make -C src blst
2024-02-26 15:48:04 +00:00
- name: Upload wheels as artifacts
uses: actions/upload-artifact@v2
with:
name: wheels
path: wheelhouse/*
# Build the source distribution under Linux
build-sdist:
name: Source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Build source distribution
run: python setup.py sdist
- name: Store artifacts
uses: actions/upload-artifact@v3
with:
path: dist/*.tar.gz
name: wheels
publish:
needs: [build-wheels, build-sdist]
runs-on: ubuntu-latest
steps:
- name: Download artifacts
uses: actions/download-artifact@v2
with:
name: wheels
path: wheelhouse
2024-02-26 15:48:04 +00:00
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
2024-02-21 20:05:47 +00:00
with:
2024-02-26 15:48:04 +00:00
password: ${{ secrets.PYPI_PASSWORD }}
packages-dir: wheelhouse