name: Release

permissions:
  # To create the follow-up PR.
  contents: write
  pull-requests: write

on:
  release:
    types:
      - released

concurrency: release

jobs:
  info:
    name: gather
    runs-on: ubuntu-latest
    outputs:
      version: "${{ fromJSON(steps.version.outputs.version) }}"
    steps:
      - uses: actions/checkout@v3
        # Uses release ref (tag)
      - name: Info
        id: version
        run: |
          TAG="${{ github.event.release.tag_name }}"
          PULUMI_VERSION="${TAG#v}" # remove prefix

          ./.github/scripts/set-output version "${PULUMI_VERSION}"

  release:
    name: release
    needs: [info]
    uses: ./.github/workflows/release.yml
    with:
      ref: ${{ github.event.release.tag_name }}
      version: ${{ needs.info.outputs.version }}
      release-notes: ${{ github.event.release.body }}
      queue-merge: true
      run-dispatch-commands: true
    secrets: inherit