Skip to content

[pre-commit.ci] pre-commit autoupdate #158

[pre-commit.ci] pre-commit autoupdate

[pre-commit.ci] pre-commit autoupdate #158

Workflow file for this run

name: Test and publish
on:
- push
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.8, 3.9]
steps:
- uses: actions/checkout@v1
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install tox dependencies
run: |
python -m pip install --upgrade pip
pip install tox tox-gh-actions
- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
- name: Load cached poetry venv
id: cached-poetry-dependencies
uses: actions/cache@v2
with:
path: |
.venv
.tox
~/.cache/pip
key: venv-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }}
- name: Install package dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root
- name: Install library
run: poetry install --no-interaction
- name: Test with tox
run: tox
publish:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.9]
needs: test
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
steps:
- uses: actions/checkout@v1
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true
- name: Load cached poetry venv
id: cached-poetry-dependencies
uses: actions/cache@v2
with:
path: |
.venv
.tox
~/.cache/pip
key: venv-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }}
- name: Check pyproject.toml validity
run: poetry check --no-interaction
- name: Check if tag version matches project version
run: |
TAG=$(git describe HEAD --tags --abbrev=0)
PROJECT_VERSION=$(poetry version --short)
echo $TAG
echo $PROJECT_VERSION
if [[ "$TAG" != "v$PROJECT_VERSION" ]]; then exit 1; fi
- name: Build
run: poetry build
- name: Publish
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}