name: Publish

on:
  release:
    types: ["published"]
  workflow_dispatch:

permissions:
  contents: read

jobs:
  pypi-publish:
    name: Upload release to PyPI
    runs-on: ubuntu-latest

    environment:
      name: release
      url: https://pypi.org/project/minestrone/

    permissions:
      id-token: write

    steps:
      - uses: actions/checkout@v4

      - name: Install uv
        uses: astral-sh/setup-uv@v3
        with:
          enable-cache: true

      - name: Set up Python
        run: uv python install 3.10

      - name: Build
        run: uv build

      # - name: Publish package distributions to Test PyPI
      #   uses: pypa/gh-action-pypi-publish@release/v1
      #   with:
      #     repository-url: https://test.pypi.org/legacy/
      #     skip-existing: true

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