name: Homebrew Bump Formula
on:
  workflow_dispatch:
  release:
    types: [released]
jobs:
  homebrew:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout Repository
        uses: actions/checkout@v7
      - name: Get Latest Tag
        id: ltag
        run: |
          git fetch --tags
          echo "GIT_TAG=$(git describe --tags "$(git rev-list --tags --max-count=1)")" >> "$GITHUB_OUTPUT"
      - name: Debug tag
        run: |
          echo "-------------------------------------------------------------"
          echo ${{ steps.ltag.outputs.GIT_TAG }}
          echo "-------------------------------------------------------------"

      - name: Bump Homebrew Formula
        uses: dawidd6/action-homebrew-bump-formula@v7
        with:
          token: ${{ secrets.HOMEBREW_GITHUB_API_TOKEN }}
          tap: AmmarAbouZor/homebrew-tui-journal
          formula: tui-journal
          tag: ${{ steps.ltag.outputs.GIT_TAG }}
          force: true
