|
| 1 | +name: Update Homebrew Formula |
| 2 | + |
| 3 | +on: |
| 4 | + release: |
| 5 | + types: [published] |
| 6 | + workflow_dispatch: |
| 7 | + inputs: |
| 8 | + version: |
| 9 | + description: 'Version to update to (e.g., 1.0.1)' |
| 10 | + required: true |
| 11 | + type: string |
| 12 | + |
| 13 | +jobs: |
| 14 | + update-homebrew: |
| 15 | + name: Update Homebrew Formula |
| 16 | + runs-on: macos-latest |
| 17 | + if: contains(github.event.release.tag_name, 'quickmark-cli@') || github.event_name == 'workflow_dispatch' |
| 18 | + |
| 19 | + steps: |
| 20 | + - name: Extract version |
| 21 | + id: version |
| 22 | + run: | |
| 23 | + if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then |
| 24 | + echo "version=${{ inputs.version }}" >> $GITHUB_OUTPUT |
| 25 | + else |
| 26 | + # Extract version from tag (quickmark-cli@1.0.0 -> 1.0.0) |
| 27 | + version="${{ github.event.release.tag_name }}" |
| 28 | + version="${version#quickmark-cli@}" |
| 29 | + echo "version=$version" >> $GITHUB_OUTPUT |
| 30 | + fi |
| 31 | +
|
| 32 | + - name: Setup Homebrew |
| 33 | + id: set-up-homebrew |
| 34 | + uses: Homebrew/actions/setup-homebrew@master |
| 35 | + |
| 36 | + - name: Update Homebrew formula using bump-formula-pr |
| 37 | + env: |
| 38 | + HOMEBREW_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 39 | + run: | |
| 40 | + # Use brew bump-formula-pr to automatically update the formula |
| 41 | + brew bump-formula-pr \ |
| 42 | + --tap=ekropotin/homebrew-formula \ |
| 43 | + --version="${{ steps.version.outputs.version }}" \ |
| 44 | + --message="chore(brew): quickmark-cli ${{ steps.version.outputs.version }} |
| 45 | +
|
| 46 | + Updates quickmark-cli to version ${{ steps.version.outputs.version }}. |
| 47 | +
|
| 48 | + This PR was automatically created by the quickmark release workflow." \ |
| 49 | + --no-browse \ |
| 50 | + --no-fork \ |
| 51 | + quickmark-cli || { |
| 52 | + echo "Failed to create PR. Possible reasons:" |
| 53 | + echo "1. The version is already up to date" |
| 54 | + echo "2. The release assets are not yet available" |
| 55 | + echo "3. There was a network issue" |
| 56 | + echo "4. The formula doesn't exist or has issues" |
| 57 | + exit 1 |
| 58 | + } |
0 commit comments