name: Update Changelog
on:
  workflow_dispatch:
    inputs:
      next_tag:
        description: "Next version tag (`vX.Y.Z`)"
        required: true

jobs:
  changelog:
    runs-on: ubuntu-20.04
    steps:
      - name: Checkout
        uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
      - name: "✏️ Generate release changelog"
        uses: heinrichreimer/github-changelog-generator-action@e60b5a2bd9fcd88dadf6345ff8327863fb8b490f # v2.4
        with:
          futureRelease: ${{ github.event.inputs.next_tag }}
          token: ${{ secrets.GITHUB_TOKEN }}
          repo: napari/npe2
      - name: Create Pull Request
        uses: peter-evans/create-pull-request@c0f553fe549906ede9cf27b5156039d195d2ece0 # v8.1.0
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          commit-message: Automatic changelog update
          title: changelog ${{ github.event.inputs.next_tag }}
          branch: update-changelog
