name: Release Dolt

on:
  workflow_dispatch:
    inputs:
      version:
        description: 'SemVer format release tag, i.e. 0.24.5'
        required: true

jobs:
  format-version:
    runs-on: ubuntu-22.04
    outputs:
      version: ${{ steps.format_version.outputs.version }}
    steps:
      - name: Format Input
        id: format_version
        run: |
          version="${{ github.event.inputs.version }}"
          if [[ $version == v* ]];
          then
            version="${version:1}"
          fi
          echo "version=$version" >> $GITHUB_OUTPUT

  profile-benchmark-dolt:
    runs-on: ubuntu-22.04
    needs: format-version
    name: Trigger Benchmark Profile K8s Workflows
    steps:
      - uses: actions/checkout@v4
        with:
          ref: main
      - name: Get sha
        id: get_sha
        run: |
          sha=$(git rev-parse --short HEAD)
          echo "sha=$sha" >> $GITHUB_OUTPUT
      - uses: peter-evans/repository-dispatch@v3
        with:
          token: ${{ secrets.REPO_ACCESS_TOKEN }}
          event-type: profile-dolt
          client-payload: '{"from_version": "${{ steps.get_sha.outputs.sha }}", "future_version": "${{ needs.format-version.outputs.version }}", "mode": "release", "actor": "${{ github.actor }}", "actor_email": "dustin@dolthub.com", "template_script": "./.github/scripts/performance-benchmarking/get-dolt-profile-job-json.sh"}'
