name: Release
on:
  push:
    tags:
      - '*'

jobs:
  release:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v2
      - name: Install Poetry
        run: pipx install poetry
      - name: Setup Python
        uses: actions/setup-python@v4
        with:
          python-version: "3.11"
          cache: 'poetry'
      - name: Setup environment
        run: poetry install
      - name: Style
        run: make style
      - name: Test
        run: make test
      - name: Publish on PyPI
        run: |
          poetry config pypi-token.pypi $PYPI_TOKEN
          poetry build
          poetry publish
        env:
          PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
