name: Publish to PyPI
on:
  workflow_dispatch:

jobs:
  test_pypi_release:
    runs-on: ubuntu-latest
    steps:
      - name: Check out code from GitHub
        uses: actions/checkout@v2
      - name : Setup Python
        uses: actions/setup-python@v2
      - name: Install Poetry
        run: pipx install Poetry
      - name: Install dependencies
        run: poetry install --no-interaction
      - name: Run pytest
        run: poetry run pytest tests/test.py
      - name: Build package
        run: poetry build --no-interaction
      - name: Set test PyPi repository
        run: poetry config repositories.pypi https://test.pypi.org/legacy/
      - name: Add token
        run: poetry config pypi-token.pypi ${{ secrets.PYPI_API_KEY }}
      - name: Publish package
        run: poetry publish