name: Publish to PyPI

on:
  push:
    tags:
      - '*'

permissions:
  id-token: write  # Required for trusted publishing

jobs:
  build_and_deploy:
    runs-on: ubuntu-latest
    environment:
      name: pypi
      url: https://pypi.org/project/condastats/
    steps:
      - name: Checkout
        uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
        with:
          fetch-depth: 0
      - name: Set up Python
        uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
        with:
          python-version: "3.12"
      - name: Install build dependencies
        run: python -m pip install build
      - name: Build wheel and sdist
        run: python -m build
      - name: Publish to PyPI
        uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0
