Publish to PyPI #13
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: Publish to PyPI | |
on: | |
workflow_dispatch: | |
jobs: | |
test: | |
name: Test Python ${{ matrix.python-version }} on ${{ matrix.os }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
# os: [ubuntu-latest, windows-latest, macos-latest] | |
os: [ubuntu-latest, macos-latest] | |
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install test dependencies | |
run: | | |
python -m pip install pytest numpy | |
python -m pip install scikit-build-core pybind11 cmake | |
python -m pip install -e . | |
- name: Run tests | |
run: python -m pytest tests/ | |
build_wheels: | |
needs: test | |
name: Build wheels on ${{ matrix.os }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
# os: [ubuntu-latest, windows-latest, macos-latest] | |
os: [ubuntu-latest, macos-latest] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.12' | |
- name: Install build dependencies | |
run: | | |
python -m pip install cibuildwheel cmake | |
- name: Build wheels | |
run: python -m cibuildwheel --output-dir dist | |
env: | |
CIBW_BUILD: cp38-* cp39-* cp310-* cp311-* cp312-* cp313-* pp38-* pp39-* pp310-* | |
CIBW_ARCHS_LINUX: x86_64 i686 | |
# CIBW_ARCHS_WINDOWS: AMD64 x86 | |
CIBW_ARCHS_MACOS: x86_64 arm64 | |
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014 | |
CIBW_MANYLINUX_I686_IMAGE: manylinux2014 | |
CIBW_BEFORE_BUILD: pip install scikit-build-core pybind11 cmake | |
- name: Build sdist | |
run: | | |
pip install setuptools | |
python setup.py sdist --formats=gztar | |
env: | |
CIBW_BEFORE_BUILD: pip install pybind11 cmake | |
- name: Upload wheels as artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: wheels | |
path: | | |
dist/*.whl | |
dist/*.tar.gz | |
upload_pypi: | |
needs: build_wheels | |
runs-on: ubuntu-latest | |
environment: | |
name: pypi | |
url: https://pypi.org/p/simple-ans | |
permissions: | |
id-token: write | |
steps: | |
- name: Download artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
name: wheels | |
path: dist | |
- name: Publish to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 |