name: Publish to PyPI

on:
  release:
    types: [published]

jobs:
  pypi_release:
    name: Build and Publish to PyPI
    runs-on: ubuntu-latest
    environment:
      name: pypi
      url: https://pypi.org/p/ttls
    permissions:
      id-token: write
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with:
          python-version: "3.12"
      - name: Install the latest version of uv
        uses: astral-sh/setup-uv@v5
        with:
          version: latest
      - name: Publish package
        run: uv build
      - name: Publish package distributions to PyPI
        uses: pypa/gh-action-pypi-publish@release/v1
