Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify GH actions #170

Draft
wants to merge 13 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
124 changes: 76 additions & 48 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,89 +1,117 @@
name: Build wheels
name: CI/CD

on:
on:
push:
branches: [master]
pull_request:
branches: [master]
workflow_dispatch:

jobs:
build_wheels:
name: Build wheels on ${{ matrix.os }}
test_and_build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false # Allow one of the matrix builds to fail without failing others
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v4
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: 3.11
python-version: ${{ matrix.python-version }}
cache: 'pip' # Enable built-in pip caching

- name: Install cibuildwheel
- name: Install dependencies
run: |
pip install --upgrade pip
pip install -e .[dev,test,lint]
pip install cibuildwheel==2.21.3
continue-on-error: false

- name: Run tests and linting
run: |
black KDEpy -l 120 --check
flake8 --show-source --ignore=F811,W293,W391,W292,W291,W504,W503,E231 --max-line-length=120 --exclude="*examples.py,testing.py,*kde.py" KDEpy
pytest KDEpy --doctest-modules --capture=sys

- name: Build wheels
env:
CIBW_BUILD: 'cp38-* cp39-* cp310-* cp311-* cp312-* cp313-*'
CIBW_BUILD: >-
cp${{
matrix.python-version == '3.8' && '38' ||
matrix.python-version == '3.9' && '39' ||
matrix.python-version == '3.10' && '310' ||
matrix.python-version == '3.11' && '311' ||
matrix.python-version == '3.12' && '312' ||
matrix.python-version == '3.13' && '313'
}}*
CIBW_ARCHS_MACOS: x86_64 arm64
CIBW_SKIP: pp* *-musllinux_* *-manylinux_i686 # skip PyPy, musllinux, 32-bit Linux
CIBW_SKIP: pp* *-musllinux_* *-manylinux_i686
run: |
python -m cibuildwheel --output-dir wheelhouse

- name: Build source distribution
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.13'
run: |
pip install cibuildwheel --upgrade;
python -m cibuildwheel --output-dir dist;
pip install build
python -m build --sdist --outdir dist

- name: Store artifacts
uses: actions/upload-artifact@v3
with:
name: python-package-distributions
path: dist/*.whl
path: |
wheelhouse/*.whl
dist/*.tar.gz

package_source:
name: Package source distribution
build_docs:
runs-on: ubuntu-latest

if: >-
${{
github.event_name == 'push' &&
github.ref == 'refs/heads/master'
}}
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Python
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.11

- name: Install build
run: python -m pip install build

- name: Run sdist
run: python -m build --sdist

- name: Store artifacts
python-version: '3.11'
- name: Cache pip packages
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-docs-${{ hashFiles('pyproject.toml') }}
restore-keys: |
${{ runner.os }}-pip-docs-
- name: Install dependencies
run: |
pip install --upgrade pip
pip install -e .[dev]
sudo apt install pandoc -y
- name: Build docs
run: sphinx-build docs/source _build/html -W
- name: Store documentation
uses: actions/upload-artifact@v3
with:
name: python-package-distributions
path: ./dist/*.tar.gz
name: documentation
path: _build/html

publish_to_pypi:
needs:
- build_wheels
- package_source
publish:
needs: [test_and_build, build_docs]
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master' # Only publish from the master branch

if: github.event_name == 'push' && github.ref == 'refs/heads/master'
steps:
- name: Download build files
uses: actions/download-artifact@v3
- uses: actions/download-artifact@v3
with:
name: python-package-distributions
path: dist/

# https://github.com/pypa/gh-action-pypi-publish
- name: Publish Python distribution to PyPI
uses: pypa/gh-action-pypi-publish@e53eb8b103ffcb59469888563dc324e3c8ba6f06
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@v1
with:
skip-existing: true
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
28 changes: 0 additions & 28 deletions .github/workflows/build_docs.yml

This file was deleted.

33 changes: 0 additions & 33 deletions .github/workflows/test_base.yml

This file was deleted.

13 changes: 0 additions & 13 deletions .github/workflows/test_develop.yml

This file was deleted.

13 changes: 0 additions & 13 deletions .github/workflows/test_master.yml

This file was deleted.

Loading