name: PyDev.Debugger [Windows, MacOS] Release

on:
  push:
    branches:
      - "release-pydev-debugger-test"
    tags:
      - "pydev_debugger_*"
env:
    DISPLAY: ":99"

jobs:
  build:
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [macos-latest, windows-latest]
        python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
    steps:
      - uses: actions/checkout@v3
      - name: Set up Python
        uses: actions/setup-python@v4
        with:
          python-version: ${{ matrix.python-version }}
          
      - name: Display Python version
        run: python --version
        
      - name: Install common Python deps
        run: |
          pip install --upgrade pip
          pip install wheel "cython>3" setuptools psutil twine --no-warn-script-location
          
      - name: Build cython
        env:
          PYTHONPATH: .
          PYDEVD_USE_CYTHON: yes
        run: python build_tools/build.py
          
      - name: Check cython unchanged
        env:
          PYTHONPATH: .
          PYDEVD_USE_CYTHON: yes
        run: python build_tools/check_no_git_modifications.py
        
      - name: Create sdist
        run: python setup.py sdist bdist_wheel

      - uses: actions/upload-artifact@v4
        with:
          name: dist-${{ matrix.os }}-${{ matrix.python-version }}
          path: dist/*
          
      - name: Upload to PyPI .whl
        run: twine upload dist/*.whl
        env:
          TWINE_USERNAME: __token__
          TWINE_PASSWORD: ${{ secrets.TWINE_KEY }}
          
      - name: Upload to PyPI .tar.gz
        if: ${{ (matrix.os == 'windows-latest') && (matrix.python-version == '3.9') }}
        run: twine upload dist/*.tar.gz
        env:
          TWINE_USERNAME: __token__
          TWINE_PASSWORD: ${{ secrets.TWINE_KEY }}
            
