Update Python versions and add deploy step #2
Workflow file for this run
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
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions | |
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions | |
name: CI | |
on: | |
push: | |
branches: [master] | |
tags: | |
- v* | |
pull_request: | |
branches: [master, dev] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: true | |
matrix: | |
python-version: ["3.9", "3.12"] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install Openslide global dependencies | |
run: | | |
sudo apt update | |
sudo apt-get install -y libopenslide-dev openslide-tools libopenjp2-7 libopenjp2-tools | |
- name: Print Version Information | |
run: python -c "import sys; print(sys.version)" | |
- name: Load cached venv if cache exists | |
id: cached-poetry-dependencies | |
uses: actions/cache@v3 | |
with: | |
path: .venv | |
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }} | |
- name: Install Poetry | |
uses: snok/install-poetry@v1 | |
- name: Install dependencies if cache does not exist | |
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' | |
run: poetry install | |
- name: Tests | |
run: poetry run pytest | |
deploy: | |
needs: [build] | |
if: contains(github.ref, 'tags') | |
runs-on: ubuntu-latest | |
steps: | |
- name: Set up Python 3.10 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.10 | |
- name: Install Openslide global dependencies | |
run: | | |
sudo apt update | |
sudo apt-get install -y libopenslide-dev openslide-tools libopenjp2-7 libopenjp2-tools | |
- name: Print Version Information | |
run: python -c "import sys; print(sys.version)" | |
- name: Load cached venv if cache exists | |
id: cached-poetry-dependencies | |
uses: actions/cache@v3 | |
with: | |
path: .venv | |
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }} | |
- name: Install Poetry | |
uses: snok/install-poetry@v1 | |
- name: Install dependencies if cache does not exist | |
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' | |
run: poetry install | |
- name: Install Poetry | |
uses: snok/install-poetry@v1 | |
- name: Deploy doc | |
run: poetry run mkdocs gh-deploy --force | |
publish: | |
needs: [build] | |
if: contains(github.ref, 'tags') | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Build and publish to pypi | |
uses: JRubics/[email protected] | |
with: | |
python_version: "3.10" | |
pypi_token: ${{ secrets.PYPI_TOKEN }} |