name: pypi-release

on:
  release:
    types: [released]
  workflow_dispatch:

jobs:
  build-and-publish:
    runs-on: ubuntu-latest
    environment: production
    permissions:
      id-token: write
    steps:
      - uses: actions/checkout@v4
      - name: Set up Python
        uses: actions/setup-python@v5
        with:
          python-version-file: "pyproject.toml"
      - name: Install uv
        uses: astral-sh/setup-uv@v6
      - name: Install dependencies
        run: uv sync
      - name: Build package
        run: uv build
      - name: Publish package
        uses: pypa/gh-action-pypi-publish@release/v1
