Skip to content

ENH: Migrate CI to use cibuildwheel for building wheels #186

ENH: Migrate CI to use cibuildwheel for building wheels

ENH: Migrate CI to use cibuildwheel for building wheels #186

Workflow file for this run

# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: Python package
on:
push:
branches: [ master ]
tags:
- 'v*'
pull_request:
branches: [ master ]
jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-latest
python-version: 3.8
- os: ubuntu-latest
python-version: 3.9
- os: ubuntu-latest
python-version: '3.10'
- os: ubuntu-latest
python-version: '3.11'
- os: macos-latest
python-version: 3.9
- os: windows-latest
python-version: 3.9
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e ".[dev]"
- name: Lint with pysen
run: |
pysen run lint
- name: Test with pytest
run: |
pip install pytest
pytest
build-wheels-for-publish:
name: Build distribution πŸ“¦
if: "startsWith(github.ref, 'refs/tags')"
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, ubuntu-latest-arm, windows-latest, macos-latest]
needs: test
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install cibuildwheel==2.16.2
- name: Build wheels
env:
CIBW_SKIP: "pp* *-musllinux_*"
run: python -m cibuildwheel --output-dir wheelhouse
- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }}
path: ./wheelhouse/*.whl
build-sdist-for-publish:
name: Build source distribution πŸ“¦
if: "startsWith(github.ref, 'refs/tags')"
runs-on: ubuntu-latest
needs: test
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e ".[dev]"
- name: Install build tool
run: python -m pip install sdist
- name: Build source distribution
run: python setup.py sdist
- name: Upload sdist artifact
uses: actions/upload-artifact@v4
with:
name: sdist-artifact
path: dist/*.tar.gz
publish-to-pypi:
name: >-
Publish Python 🐍 distribution πŸ“¦ to PyPI
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
needs:
- build-wheels-for-publish
- build-sdist-for-publish
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/pyopenjtalk
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing
steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
# unpacks all CIBW artifacts into dist/
path: dist
pattern: cibw-wheels-*
merge-multiple: true
- name: Download sdist artifact
uses: actions/download-artifact@v4
with:
name: sdist-artifact
path: dist
- name: Publish distribution πŸ“¦ to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
verbose: true
password: ${{ secrets.PYPI_TOKEN }}
# NOTE: for testing purposes only
# publish-to-testpypi:
# name: Publish Python 🐍 distribution πŸ“¦ to TestPyPI
# needs:
# - build-for-publish
# runs-on: ubuntu-latest
# environment:
# name: testpypi
# url: https://test.pypi.org/p/pyopenjtalk
# permissions:
# id-token: write # IMPORTANT: mandatory for trusted publishing
# steps:
# - name: Download all the dists
# uses: actions/download-artifact@v4
# with:
# name: python-package-distributions
# path: dist/
# - name: Publish distribution πŸ“¦ to TestPyPI
# uses: pypa/gh-action-pypi-publish@release/v1
# with:
# repository-url: https://test.pypi.org/legacy/
# verbose: true