Skip to content

Merge pull request #56 from diegoferigo/diegoferigo-patch-1 #318

Merge pull request #56 from diegoferigo/diegoferigo-patch-1

Merge pull request #56 from diegoferigo/diegoferigo-patch-1 #318

Workflow file for this run

name: Python CI/CD
on:
push:
pull_request:
release:
types:
- published
jobs:
build-and-test:
name: 'Python${{ matrix.python-version }}@${{ matrix.os }}'
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version:
- 3.8
- 3.9
- "3.10"
- "3.11"
- "3.12"
- "3.13"
os:
- ubuntu-22.04
- macos-latest
- windows-latest
include:
- optional: false
steps:
- uses: actions/checkout@v4
- run: git fetch --prune --unshallow
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install cmake-build-extensions
run: pip install wheel && pip install -v .[all]
- name: Example dependencies [Windows]
if: contains(matrix.os, 'windows')
shell: bash
run: |
choco install -y swig
vcpkg install --triplet x64-windows eigen3
- name: Example dependencies [macOS]
if: contains(matrix.os, 'macOS')
run: |
brew install swig eigen
# https://cibuildwheel.readthedocs.io/en/stable/cpp_standards
echo "MACOSX_DEPLOYMENT_TARGET=10.14" >> $GITHUB_ENV
- name: Example dependencies [Ubuntu]
if: contains(matrix.os, 'ubuntu')
run: |
sudo apt update
sudo apt install build-essential swig libeigen3-dev
- name: Build and install example
continue-on-error: ${{ matrix.optional }}
working-directory: example
run: pip install -v .[all]
env:
# Pretend to be using cibuildwheel
CIBUILDWHEEL: 1
- name: Test example
continue-on-error: ${{ matrix.optional }}
working-directory: example
run: pytest
publish:
name: Publish to PyPI
needs: build-and-test
runs-on: ubuntu-22.04
permissions:
id-token: write
steps:
- uses: actions/checkout@master
- run: git fetch --prune --unshallow
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.10
- name: Install Python tools
run: pip install build
- name: Create distributions
run: python -m build -o dist/
- name: Inspect dist folder
run: ls -lah dist/
- name: Check wheel
run: test $(find dist/ -name *-none-any.whl | wc -l) -gt 0
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
path: dist/*
name: dist
- name: Publish to PyPI
if: |
github.repository == 'diegoferigo/cmake-build-extension' &&
((github.event_name == 'push' && github.ref == 'refs/heads/master') ||
(github.event_name == 'release'))
uses: pypa/gh-action-pypi-publish@release/v1
with:
skip_existing: true