copp 0.2.2

Convex-objective path parameterization for robotic trajectory planning.
Documentation
name: Python

on:
  push:
    branches:
      - "**"
    tags:
      - "v*"
  pull_request:
  workflow_dispatch:
  release:
    types: [published]

permissions:
  contents: read

concurrency:
  group: python-${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

env:
  CARGO_TERM_COLOR: always
  RUSTFLAGS: "-C target-cpu=generic"
  MATURIN_VERSION: v1.13.3

jobs:
  build-sdist:
    name: Build sdist
    runs-on: ubuntu-24.04

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

      - name: Build source distribution
        uses: PyO3/maturin-action@v1
        with:
          maturin-version: ${{ env.MATURIN_VERSION }}
          command: sdist
          args: --out dist

      - name: Upload sdist artifact
        uses: actions/upload-artifact@v4
        with:
          name: python-sdist
          path: dist/*.tar.gz
          if-no-files-found: error

  build-wheels:
    name: ${{ matrix.platform.name }} / Python ${{ matrix.python-version }}
    runs-on: ${{ matrix.platform.os }}

    strategy:
      fail-fast: false
      matrix:
        python-version:
          - "3.9"
          - "3.10"
          - "3.11"
          - "3.12"
          - "3.13"
          - "3.14"
        platform:
          - name: linux-x86_64
            os: ubuntu-24.04
            target: x86_64-unknown-linux-gnu
            manylinux: "2014"
            test-wheel: true
          - name: linux-aarch64
            os: ubuntu-24.04
            target: aarch64-unknown-linux-gnu
            manylinux: "2014"
            test-wheel: false
          - name: windows-x86_64
            os: windows-2022
            target: x86_64-pc-windows-msvc
            manylinux: auto
            test-wheel: true

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

      - name: Set up Python
        uses: actions/setup-python@v5
        with:
          python-version: ${{ matrix.python-version }}

      - name: Build wheel
        uses: PyO3/maturin-action@v1
        with:
          maturin-version: ${{ env.MATURIN_VERSION }}
          command: build
          target: ${{ matrix.platform.target }}
          manylinux: ${{ matrix.platform.manylinux }}
          args: >-
            --release
            --locked
            --features python
            --out dist
            --interpreter ${{ runner.os == 'Linux' && format('python{0}', matrix.python-version) || 'python' }}
            --compatibility pypi
            --auditwheel repair
            --strip

      - name: Install wheel
        if: matrix.platform.test-wheel
        run: |
          python -m pip install --upgrade pip
          python -m pip install numpy pytest
          python -m pip install --no-index --find-links dist --no-deps --force-reinstall copp-py

      - name: Run Python tests
        if: matrix.platform.test-wheel
        run: python -m pytest bindings/python/tests

      - name: Upload wheel artifact
        uses: actions/upload-artifact@v4
        with:
          name: wheels-${{ matrix.platform.name }}-py${{ matrix.python-version }}
          path: dist/*.whl
          if-no-files-found: error

  publish-pypi:
    name: Publish to PyPI
    needs:
      - build-sdist
      - build-wheels
    if: github.event_name == 'release' && github.event.action == 'published'
    runs-on: ubuntu-24.04
    permissions:
      contents: read
      id-token: write

    steps:
      - name: Download distribution artifacts
        uses: actions/download-artifact@v4
        with:
          path: dist
          merge-multiple: true

      - name: Publish distributions to PyPI
        uses: pypa/gh-action-pypi-publish@release/v1
        with:
          packages-dir: dist
          user: __token__
          password: ${{ secrets.PYPI_API_TOKEN }}