# This workflow will install Python dependencies and upload a version in the PyPI
name: CD - Upload PyPI

on:
  release:
    types: [ published ]

jobs:
  upload:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      id-token: write

    steps:
      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7

      # Sets up python
      - uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v5
        with:
          python-version: 3.12

      # Install dependencies
      - name: "Installs dependencies"
        run: |
          python3 -m pip install --upgrade pip
          python3 -m pip install setuptools build twine
          python3 -m pip install .

      - name: Build distribution
        run: |
          python3 -m build
          python3 -m twine check dist/*

      - name: Publish package distributions to PyPI
        uses: pypa/gh-action-pypi-publish@release/v1
