name: Release

on:
  push:
    tags: ["incremental-*"]

permissions:
  contents: read

jobs:
  build:
    runs-on: ubuntu-24.04

    steps:
    - uses: actions/checkout@v4

    - uses: ./.github/actions/build-dist

  pypi-publish:
    runs-on: ubuntu-24.04
    if: startsWith(github.ref, 'refs/tags/incremental-')
    needs: [build]

    environment:
      name: release
      url: https://pypi.org/p/incremental

    permissions:
      id-token: write

    steps:

    - uses: actions/download-artifact@v4
      with:
        name: dist
        path: dist/

    - uses: pypa/gh-action-pypi-publish@release/v1
