name: Release

on:
  push:
    tags:
      - v*

jobs:
  pypi:
    name: Publish to PyPI
    runs-on: ubuntu-latest
    # Environment and permissions trusted publishing.
    environment:
      # Create this environment in the GitHub repository under Settings -> Environments
      name: pypi
    permissions:
      id-token: write
      contents: read
    steps:
      - name: Checkout
        uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
      - name: Install uv
        uses: astral-sh/setup-uv@681c641aba71e4a1c380be3ab5e12ad51f415867 # v7.1.6
      - name: Install Python 3.11
        run: uv python install 3.11
      - name: Build
        run: uv build
      - name: Smoke test (wheel)
        run: uv run --isolated --no-project --with dist/*.whl nextcloud-mcp-server --help
      - name: Smoke test (source distribution)
        run: uv run --isolated --no-project --with dist/*.tar.gz nextcloud-mcp-server --help
      - name: Publish
        run: uv publish
