name: Publish to PyPI

on:
  release:
    types: [published]

jobs:
  build-n-publish:
    name: Build and publish to PyPI
    runs-on: ubuntu-latest
    environment:
      name: release
      url: https://pypi.org/project/excel-mcp-server
    permissions:
      id-token: write

    steps:
      - uses: actions/checkout@v4

      - name: Set up Python
        uses: actions/setup-python@v4
        with:
          python-version: "3.x"

      - name: Install hatch dependencies
        run: |
          python -m pip install --upgrade pip
          pip install hatch

      - name: Build package
        run: hatch build

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