Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 17 additions & 12 deletions .github/workflows/update-homebrew-tap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,24 @@ on:
workflow_run:
workflows: [Build Binaries]
types: [completed]
workflow_dispatch:
inputs:
release_tag:
description: Release tag to publish to Homebrew
required: true
type: string

permissions: {}

jobs:
update-tap:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' && startsWith(github.event.workflow_run.head_branch, 'v') }}
if: ${{ github.event_name == 'workflow_dispatch' || (github.event.workflow_run.conclusion == 'success' && startsWith(github.event.workflow_run.head_branch, 'v')) }}
steps:
- name: Update Homebrew formula
env:
GH_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}
RELEASE_TAG: ${{ github.event.workflow_run.head_branch }}
RELEASE_TAG: ${{ github.event_name == 'workflow_dispatch' && inputs.release_tag || github.event.workflow_run.head_branch }}
run: |
set -euo pipefail

Expand All @@ -31,11 +37,8 @@ jobs:
SHAS["${asset}"]="${sha}"
done

# Clone tap repo
git clone "https://x-access-token:${GH_TOKEN}@github.com/${TAP_REPO}.git" tap
cd tap

# Generate formula
mkdir -p "$(dirname "${FORMULA_PATH}")"
cat > "${FORMULA_PATH}" << RUBY
class Openabcode < Formula
desc "AI coding agent with task routing and hosted gateway"
Expand Down Expand Up @@ -77,9 +80,11 @@ jobs:
# Remove leading whitespace from heredoc
sed -i 's/^ //' "${FORMULA_PATH}"

# Commit and push
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add "${FORMULA_PATH}"
git commit -m "openabcode ${VERSION}"
git push
# Update the tap with the fine-grained PAT as a Bearer token.
formula_sha=$(gh api "repos/${TAP_REPO}/contents/${FORMULA_PATH}" --jq '.sha')
formula_content=$(base64 -w 0 "${FORMULA_PATH}")
gh api --method PUT "repos/${TAP_REPO}/contents/${FORMULA_PATH}" \
-f message="openabcode ${VERSION}" \
-f content="${formula_content}" \
-f sha="${formula_sha}" \
-f branch=main
Loading