name: Deploy to Pypi

on:
  release:
    types:
      - published

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v3
      - name: Set up Python 3.9
        uses: actions/setup-python@v4
        with:
          python-version: 3.9
      - name: Install dependencies
        run: |
          python -m pip install --upgrade pip
          python -m pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cpu
      - name: Install package
        run: |
          python -m pip install -e .
            pip install setuptools wheel
      - name: Build a binary wheel and a source tarball
        run: |
          python setup.py sdist bdist_wheel
      # - name: Publish package to TestPyPI
      #   uses: pypa/gh-action-pypi-publish@master
      #   with:
      #     user: __token__ 
      #     password: ${{ secrets.TEST_PYPI_PASSWORD }}
      #     repository_url: https://test.pypi.org/legacy/
      - name: Publish package to PyPI
        uses: pypa/gh-action-pypi-publish@release/v1
        with:
          user: __token__ 
          password: ${{ secrets.PYPI_PASSWORD }}
