name: Upload Python Package

on:
  release:
    types: [created]

jobs:
  deploy:
    environment: pypi
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v3
    - name: Install poetry
      run: pipx install poetry
    - name: Set up Python
      uses: actions/setup-python@v4
      with:
        python-version: '3.8'
    - name: Build and publish
      env:
        PYPI_TOKEN: ${{ secrets.PYPI_PASSWORD }}
      run: |
        poetry self add poetry-version-plugin
        poetry config pypi-token.pypi $PYPI_TOKEN
        poetry publish --build
