name: Publish to PyPI
 
on:
  release:
    types: [published]   # triggers when you create a GitHub Release
 
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
 
      - name: Set up Python
        uses: actions/setup-python@v5
        with:
          python-version: "3.11"
 
      - name: Install build tools
        run: pip install build
 
      - name: Build distribution
        run: python -m build
 
      - name: Upload distribution artifact
        uses: actions/upload-artifact@v4
        with:
          name: python-package-distributions
          path: dist/
 
  publish:
    runs-on: ubuntu-latest
    needs: build
    environment:
      name: pypi
      url: https://pypi.org/p/abaudit
    permissions:
      id-token: write   # required for Trusted Publishing
 
    steps:
      - name: Download distribution artifact
        uses: actions/download-artifact@v4
        with:
          name: python-package-distributions
          path: dist/
 
      - name: Publish to PyPI
        uses: pypa/gh-action-pypi-publish@release/v1