on:
  workflow_dispatch:
  push:
    branches:
      - main
  pull_request:

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3
    - name: Set up Python
      uses: actions/setup-python@v4
      with:
        python-version: 3.9
    - name: Install dependencies
      run: |
        python -m pip install --upgrade pip
        pip install twine
    - name: Build manylinux Python wheels
      uses: RalfG/python-wheels-manylinux-build@v0.5.0-manylinux2014_x86_64
      with:
        python-versions: 'cp37-cp37m cp38-cp38 cp39-cp39 cp310-cp310'
        system-packages: 'guile-devel zlib-devel gettext portaudio-devel portmidi-devel libsndfile-devel autogen libdb-devel wget'
        pre-build-command: 'sh manylinux-pre-build-script.sh'
        pip-wheel-args: '-w ./dist --build-option --use-double --build-option --use-jack'
    - name: Publish wheels to test PyPI
      env:
        TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
        TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
      run: |
        twine upload --repository testpypi dist/*-manylinux*.whl