Skip to content

Commit

Permalink
ci: Use cibuildwheel to build wheels
Browse files Browse the repository at this point in the history
  • Loading branch information
AbdealiLoKo committed Oct 28, 2022
1 parent 604f4d1 commit 095a549
Showing 1 changed file with 72 additions and 55 deletions.
127 changes: 72 additions & 55 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,81 +11,98 @@ concurrency:
cancel-in-progress: true

jobs:
test:
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04, macos-11, windows-2019]
python-version: [ "3.6", "3.7", "3.8", "3.9", "3.10", "pypy3.7", "pypy3.8", "pypy3.9", ]
runs-on: ${{ matrix.os }}
# test:
# strategy:
# fail-fast: false
# matrix:
# os: [ubuntu-20.04, macos-11, windows-2019]
# python-version: [ "3.6", "3.7", "3.8", "3.9", "3.10", "pypy3.7", "pypy3.8", "pypy3.9", ]
# runs-on: ${{ matrix.os }}
# steps:
# - name: Check out repository
# uses: actions/checkout@v3
# - name: Set up python
# id: setup-python
# uses: actions/setup-python@v4
# with:
# python-version: ${{ matrix.python-version }}
# - name: Print Python Information
# run: python -VV
# - name: install TinyTeX
# uses: r-lib/actions/setup-tinytex@v2
# - name: Install and configure Poetry
# run: |
# pip3 install poetry
# poetry config virtualenvs.in-project true
# - name: Set up cache
# uses: actions/cache@v3
# id: cached-poetry-dependencies
# with:
# path: .venv
# key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock') }}
# - name: Install dependencies
# run: poetry install
# if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
# - name: Download pandoc
# run: poetry run python setup_binary.py download_pandoc
# - name: run tests
# run: poetry run python tests.py

builder_pypandoc:
# needs: [test]
# if: github.ref == 'refs/heads/master'
runs-on: ubuntu-20.04 # Any OS is fine as this wheel is not OS dependent
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Set up python
id: setup-python
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Print Python Information
run: python -VV
- name: install TinyTeX
uses: r-lib/actions/setup-tinytex@v2
- name: Install and configure Poetry
run: |
pip3 install poetry
poetry config virtualenvs.in-project true
- name: Set up cache
uses: actions/cache@v3
id: cached-poetry-dependencies
python-version: 3.9 # Build any 1 python version as this wheel is not version dependent
- name: Update dependencies
run: python -m pip install -U pip wheel setuptools
- name: Build wheel
run: python setup.py sdist bdist_wheel
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock') }}
- name: Install dependencies
run: poetry install
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
- name: Download pandoc
run: poetry run python setup_binary.py download_pandoc
- name: run tests
run: poetry run python tests.py
name: python-package-distributions
path: dist/

builder:
needs: [test]
if: github.ref == 'refs/heads/master'
builder_pypandoc_binary:
# needs: [test]
# if: github.ref == 'refs/heads/master'
strategy:
matrix:
os: [macos-11, windows-2019]
# Ref: https://cibuildwheel.readthedocs.io/en/stable/options/#archs
# macos-11 - Creates macosx_x86_64
# windows-2019 - Creates {win_amd64,win32}
# ubuntu-20.04 - Creates {manylinux,musllinux}_{x86_64,i686}
# In CIBW_SKIP we skip 32bit linux
os: [macos-11, windows-2019, ubuntu-20.04]
runs-on: ${{ matrix.os }}
steps:
- name: Check out repository
uses: actions/checkout@v2
- name: Discover python architecture
run: |
if [ "$RUNNER_OS" == "Windows" ]; then
echo "PYTHON_ARCHITECTURE=x86" >> $GITHUB_ENV
else
echo "PYTHON_ARCHITECTURE=x64" >> $GITHUB_ENV
fi
- name: Set up python
uses: actions/setup-python@v4
with:
python-version: "3.9.x"
architecture: "${{ env.PYTHON_ARCHITECTURE }}"
- name: Print Python Information
run: python -VV
- name: Update dependencies
run: python -m pip install -U pip wheel setuptools twine
- name: Build universal source Archive and wheel
run: python setup.py sdist bdist_wheel
uses: actions/checkout@v3
- name: Remove pyproject and use setuptools
run: rm pyproject.toml
- name: Build binary Archive
run: python setup_binary.py download_pandoc bdist_wheel
uses: pypa/[email protected]
env:
CIBW_BEFORE_ALL: "mv setup_binary.py setup.py && python3 setup.py download_pandoc"
CIBW_BUILD: cp39-* # Build any 1 python version as this wheel is not version dependent
# We skip some variants because:
# - pandoc does not publish binaries for Linux 32bit
CIBW_SKIP: "*-{manylinux_i686,musllinux_i686}"
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: python-package-distributions
path: dist/
path: wheelhouse/

publisher_release:
needs: [builder]
needs: [builder_pypandoc, builder_pypandoc_binary]
if: startsWith(github.event.ref, 'refs/tags/v') && github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
steps:
Expand All @@ -104,7 +121,7 @@ jobs:
password: ${{ secrets.PYPI_API_TOKEN }}

publisher_latest:
needs: [builder]
needs: [builder_pypandoc, builder_pypandoc_binary]
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
steps:
Expand Down

0 comments on commit 095a549

Please sign in to comment.