Test and Publish #76
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: Test and Publish | |
on: | |
push: | |
workflow_dispatch: | |
schedule: # Run once a week to detect any regressions | |
- cron: '0 0 * * 1' | |
jobs: | |
test: | |
strategy: | |
fail-fast: false | |
matrix: | |
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"] | |
os: ["ubuntu-latest"] | |
include: | |
- python-version: "3.8" | |
os: "windows-latest" | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
cache: "pip" | |
allow-prereleases: true | |
- name: Install dependencies | |
run: | | |
pip install .[test,openmdao] | |
- name: Run flake8 | |
run: | | |
flake8 | |
- name: Run tests | |
run: | | |
pytest | |
# ------------------------------------------------------------ | |
# Build the distribution and publish (on release tag). | |
# ------------------------------------------------------------ | |
publish: | |
runs-on: ubuntu-latest | |
needs: [test] | |
steps: | |
- name: Checkout source | |
uses: actions/checkout@v4 | |
- name: Get minimum Python version | |
run: | | |
PYTHON_VERSION=$(cat pyproject.toml | grep "requires-python" | grep -Eo "[0-9]+\.[0-9]+") | |
echo "PYTHON_VERSION=${PYTHON_VERSION}" >> $GITHUB_ENV | |
- name: Set up Python ${{ env.PYTHON_VERSION }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ env.PYTHON_VERSION }} | |
cache: "pip" | |
- name: Install build dependencies | |
run: | | |
pip install --upgrade pip | |
pip install --upgrade build wheel setuptools | |
- name: Validate links | |
uses: gaurav-nelson/github-action-markdown-link-check@v1 | |
with: | |
file-path: README.md | |
folder-path: examples/ | |
- name: Build distributions | |
run: python -m build | |
- name: Publish package | |
if: github.repository == 'Project-Platypus/Rhodium' && github.event_name == 'push' && startsWith(github.ref, 'refs/tags') | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
password: ${{ secrets.PYPI_API_TOKEN }} |