name: Bump Dolt on Homebrew

on:
  workflow_dispatch:
    inputs:
      version:
        description: 'SemVer format release tag, i.e. 0.24.5'
        required: true
  repository_dispatch:
    types: [ bump-homebrew ]

jobs:
  homebrew-bump:
    name: Bump Dolt Homebrew formula
    runs-on: ubuntu-18.04
    steps:
      - name: Create Homebrew PR
        uses: mislav/bump-homebrew-formula-action@v1
        if: ${{ github.event_name == 'repository_dispatch' }}
        with:
          formula-name: dolt
          homebrew-tap: Homebrew/homebrew-core
          base-branch: master
          tag-name: ${{format('refs/tags/v{0}', github.event.client_payload.version)}}
          download-url: ${{format('https://github.com/dolthub/dolt/archive/v{0}.tar.gz', github.event.client_payload.version)}}
          commit-message: |
            ${{format('dolt {0}', github.event.client_payload.version)}}

            Created by https://github.com/mislav/bump-homebrew-formula-action
        env:
          COMMITTER_TOKEN: ${{secrets.REPO_ACCESS_TOKEN}}
      - name: Create Homebrew PR
        uses: mislav/bump-homebrew-formula-action@v1
        if: ${{ github.event_name == 'workflow_dispatch' }}
        with:
          formula-name: dolt
          homebrew-tap: Homebrew/homebrew-core
          base-branch: master
          tag-name: ${{format('refs/tags/v{0}', github.event.inputs.version)}}
          download-url: ${{format('https://github.com/dolthub/dolt/archive/v{0}.tar.gz', github.event.inputs.version)}}
          commit-message: |
            ${{format('dolt {0}', github.event.inputs.version)}}

            Created by https://github.com/mislav/bump-homebrew-formula-action
        env:
          COMMITTER_TOKEN: ${{secrets.REPO_ACCESS_TOKEN}}
