name: CI

on:
  push:
    branches:
      - main
    tags:
      - v*
  pull_request:
    branches:
      - main

jobs:
  build-and-push-package:
    runs-on: ubuntu-latest

    steps:
    - name: Check Out Repository
      uses: actions/checkout@v2

    - name: Set up Python
      uses: actions/setup-python@v2
      with:
        python-version: 3.8
    
    - name: Set up FFmpeg
      uses: FedericoCarboni/setup-ffmpeg@v2
    
    - name: Install Additional requirements
      run: |
        sudo apt-get -y install portaudio19-dev wget
      shell: bash

    - name: Install Client Requirements
      run: pip install -r requirements/client.txt

    - name: Install Server Requirements
      run: pip install -r requirements/server.txt

    - name: Install Wheel for build 
      run: pip install wheel twine
    
    - name: Build wheel
      run: |
        python setup.py sdist bdist_wheel
    
    - name: Push package on Test PyPI
      if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
      uses: pypa/gh-action-pypi-publish@release/v1
      with:
        user: __token__
        password: ${{ secrets.PYPI_API_TOKEN }}
