name: Build, Test, and Publish on: push: branches: - main tags: - "v*.*.*" # Trigger publish on version tags pull_request: branches: - main jobs: build: runs-on: ubuntu-latest strategy: matrix: python-version: ["3.8", "3.9", "3.10"] steps: - name: Checkout code uses: actions/checkout@v3 - name: Set up Python uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} - name: Install dependencies run: | python -m pip install --upgrade pip python -m pip install .[dev] || pip install pytest # Use extras_require if available - name: Run Tests run: | pytest publish: runs-on: ubuntu-latest needs: build # Publish only if tests pass steps: - name: Checkout code uses: actions/checkout@v3 - name: Set up Python uses: actions/setup-python@v4 with: python-version: "3.10" # Use a single Python version for publishing - name: Install dependencies run: | python -m pip install --upgrade pip python -m pip install build twine - name: Build Package run: python -m build - name: Publish to PyPI env: TWINE_USERNAME: __token__ TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} run: twine upload dist/*