name: Publish Python 🐍 distributions 📦 to TestPyPI

on:
  push:
    branches:
      - develop

jobs:
  build-n-publish:
    name: Build and publish Python 🐍 distributions 📦 to TestPyPI
    runs-on: ubuntu-20.04
    steps:
    - name: Checkout repository
      uses: actions/checkout@v3
    - name: Set up Python
      uses: actions/setup-python@v4
      with:
        python-version: "3.8"
    - name: Upgrade pip
      run: >-
        python -m
        pip install
        pip --upgrade
        --user
    - name: Install pypi/build
      run: >-
        python -m
        pip install
        build
        --user
    - name: Build a binary wheel and a source tarball
      run: >-
        python -m
        build
        --sdist
        --wheel
        --outdir dist/
        .
    - name: Publish distribution 📦 to TestPyPI
      uses: pypa/gh-action-pypi-publish@release/v1
      with:
        repository-url: https://test.pypi.org/legacy/
        password: ${{ secrets.TEST_PYPI_API_TOKEN }}
        verbose: true
