Update Homebrew Formula #2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Purpose: GitHub Actions workflow to update the Homebrew formula on release. | |
| # Docs: .github/workflows/homebrew.yml.doc.md | |
| name: Update Homebrew Formula | |
| on: | |
| release: | |
| types: [published] | |
| workflow_dispatch: | |
| inputs: | |
| tag: | |
| description: 'Release tag to update the formula for (e.g. v0.4.0)' | |
| required: false | |
| default: '' | |
| permissions: | |
| contents: write | |
| jobs: | |
| update-formula: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout main | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: main | |
| fetch-depth: 0 | |
| - name: Install dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y jq curl | |
| - name: Update Homebrew formula | |
| env: | |
| TAG: ${{ github.event.inputs.tag || github.event.release.tag_name }} | |
| run: ./scripts/homebrew/update_formula.sh | |
| - name: Configure Git | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| - name: Commit and push updated formula | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| git add scripts/homebrew/sin-websearch.rb | |
| if git diff --cached --quiet; then | |
| echo "No formula changes to commit." | |
| exit 0 | |
| fi | |
| git commit -m "chore(homebrew): update formula for ${TAG:-latest}" | |
| git remote set-url origin "https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" | |
| git push origin HEAD:main |