uncommented #1
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: Python CI/CD | |
on: | |
push: | |
branches: ['**'] | |
tags-ignore: ['**'] | |
pull_request: | |
release: | |
types: | |
- published | |
jobs: | |
build_sdist: | |
name: Build source distribution | |
runs-on: ubuntu-20.04 | |
steps: | |
- uses: actions/checkout@master | |
- run: git fetch --prune --unshallow | |
- name: Install Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: 3.8 | |
- name: Install pypa/build | |
run: pip install build | |
- name: Install build dependencies | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y build-essential libace-dev swig | |
- name: Build sdist | |
run: python -m build --sdist --outdir dist/ scripts/pip | |
- name: Install sdist | |
run: pip -v install --use-feature=in-tree-build dist/yarp_middleware-*.tar.gz | |
- name: Test import | |
run: python -c 'import yarp; yarp.Bottle()' | |
- name: Remove external wheels | |
run: find dist/ -type f -not -name 'yarp_middleware-*' -delete -print | |
- name: Inspect dist folder | |
run: ls -lah dist/ | |
- uses: actions/upload-artifact@v2 | |
with: | |
name: dist | |
path: dist/*.tar.gz | |
build_wheels: | |
name: Build wheels [${{ matrix.os }}] | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
python-version: | |
- 3.8 | |
os: | |
- ubuntu-20.04 | |
#- macos-latest | |
#- windows-latest | |
steps: | |
- uses: actions/checkout@master | |
- run: git fetch --prune --unshallow | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install cibuildwheel | |
run: pip install cibuildwheel | |
- name: Build wheels | |
run: python -m cibuildwheel --output-dir wheelhouse scripts/pip | |
env: | |
CIBW_BUILD_VERBOSITY: 1 | |
CIBW_BUILD: cp37-manylinux_x86_64 cp38-manylinux_x86_64 cp39-manylinux_x86_64 cp310-manylinux_x86_64 | |
CIBW_MANYLINUX_X86_64_IMAGE: manylinux_2_24 | |
CIBW_ENVIRONMENT_LINUX: "AUDITWHEEL_PLAT=manylinux_2_24_x86_64 CC=clang-7 CXX=clang++-7" | |
CIBW_BEFORE_ALL_LINUX: | | |
apt-get update &&\ | |
apt-get install -y libace-dev libeigen3-dev &&\ | |
# Use clang: http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1684 | |
apt-get install -y clang-7 | |
CIBW_TEST_COMMAND: "python -c 'import yarp; yarp.Bottle()'" | |
- name: Inspect wheelhouse folder | |
run: ls -lah wheelhouse/ | |
- uses: actions/upload-artifact@v2 | |
with: | |
name: dist | |
path: ./wheelhouse/*.whl | |
upload_pypi: | |
needs: | |
- build_sdist | |
- build_wheels | |
runs-on: ubuntu-latest | |
environment: pypi | |
# Master branch produces pre-releases. | |
# GitHub Releases 'vX.Y.Z' produce stable releases. | |
steps: | |
- uses: actions/download-artifact@v2 | |
with: | |
name: dist | |
path: dist | |
- name: Inspect dist folder | |
run: ls -lah dist/ | |
# Validate the tag accordingly to PEP440 | |
# From https://stackoverflow.com/a/37972030/12150968 | |
- name: Check PEP440 compliance | |
if: github.event_name == 'release' | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y source-highlight | |
last_tag_with_v="$(git describe --abbrev=0 --tags)" | |
last_tag=${last_tag_with_v#v} | |
rel_regexp='^(\d+!)?(\d+)(\.\d+)+([\.\-\_])?((a(lpha)?|b(eta)?|c|r(c|ev)?|pre(view)?)\d*)?(\.?(post|dev)\d*)?$' | |
echo "" | |
echo $last_tag | |
echo "" | |
check-regexp ${rel_regexp} ${last_tag} | |
match=$(check-regexp ${rel_regexp} ${last_tag} | grep matches | cut -d ' ' -f 5) | |
test $match -eq 1 && true | |
- uses: pypa/gh-action-pypi-publish@master | |
if: | | |
github.repository == 'robotology/yarp' && | |
((github.event_name == 'release' && github.event.action == 'published') || | |
(github.event_name == 'push' && github.ref == 'refs/heads/master')) | |
with: | |
user: __token__ | |
password: ${{ secrets.PYPI_TOKEN }} |