name: Release

on:
  push:
    tags:
      - "*"

jobs:
  build-package:
    name: Build & inspect our package.
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - uses: hynek/build-and-inspect-python-package@v2

  release-pypi:
    name: Publish released package to pypi.org
    permissions:
      id-token: write
    environment:
      name: release
      url: https://pypi.org/project/resolvelib/${{ github.ref_name }}
    runs-on: ubuntu-latest
    needs: build-package

    steps:
      - name: Download packages built by build-and-inspect-python-package
        uses: actions/download-artifact@v4
        with:
          name: Packages
          path: dist

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