publish #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: publish | |
on: | |
workflow_dispatch: | |
jobs: | |
build-and-test: | |
strategy: | |
fail-fast: false | |
matrix: | |
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Clone this repository | |
uses: actions/checkout@v4 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
cache: 'pip' | |
cache-dependency-path: 'requirements.txt' | |
- name: Upgrade pip and install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
- name: Install package | |
run: pip install -e ."[dev]" | |
- name: Test package | |
id: pytest | |
run: | | |
python3 -m pytest . -c pyproject.toml | |
continue-on-error: true | |
- name: Test package 2 | |
id: pytest2 | |
if: steps.pytest.outcome != 'success' | |
run: | | |
python3 -m pytest . --lf -c pyproject.toml --cov-report term-missing --cov=src/pru | |
continue-on-error: true | |
- name: Fail the job if tests fail | |
if: steps.pytest.outcome != 'success' && steps.pytest2.outcome != 'success' | |
run: exit 1 | |
deploy: | |
needs: build-and-test | |
if: needs.build-and-test.result == 'success' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Clone this repository | |
uses: actions/checkout@v4 | |
- name: Set up Python 3.12 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.12 | |
cache: 'pip' | |
cache-dependency-path: 'requirements.txt' | |
- name: Install build dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install build | |
- name: Build package | |
run: | | |
python -m build | |
- name: Publish package to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
user: __token__ | |
password: ${{ secrets.PYPI_API_TOKEN }} |