name: Exit Prerelease Mode

on:
  workflow_dispatch:
    inputs:
      branch:
        description: "Exit prerelease mode on release branch"
        type: string
        default: "main"
        required: true

jobs:
  exit_prerelease:
    name: Changesets Exit Prerelease
    runs-on: ubuntu-latest
    # Allow GITHUB_TOKEN to have write permissions
    permissions:
      contents: write

    steps:
      - uses: actions/checkout@v3
        name: Checkout Repo
        with:
          submodules: recursive

      - name: "Setup"
        uses: ./.github/actions/setup
        
      - name: Build repo
        run: bun run build

      - name: Remove pre.json
        run: bun run changeset pre exit

      - uses: stefanzweifel/git-auto-commit-action@v4
        with:
          commit_message: Exit prerelease mode
          # Commit these changes to the branch workflow is running against
          branch: ${{ github.event.inputs.branch }}
