name: Build Publish to PyPI


# run when pushing tags or manually run
on:
  push:
    tags:
    - 'rv*'
  workflow_dispatch:



jobs:

  build-and-publish:
    name: Build and publish to PyPI
    runs-on: ubuntu-latest

    steps:
    - name: Checkout main
      uses: actions/checkout@main
    
    - name: Setup Python
      uses: actions/setup-python@v4
      with:
        python-version: "3.7"
    
    - name: Build package
      run: |
        python -m pip install --upgrade pip
        pip install --upgrade setuptools build wheel twine
        python -m build
            
    - name: Publish PyPI
      uses: pypa/gh-action-pypi-publish@release/v1
      with:
        password: ${{ secrets.PYPI_API_TOKEN }}
