|
| 1 | +name: Sync Homebrew Formula |
| 2 | + |
| 3 | +# Manual sync of deepgram/homebrew-tap/Formula/deepgram.rb when the auto-bump |
| 4 | +# path didn't fire (e.g. no root v* release was cut, but we still need the |
| 5 | +# live formula updated — typically to ship a build-time deps fix that breaks |
| 6 | +# `brew install` for users right now). |
| 7 | +# |
| 8 | +# This is the manual escape hatch. The standard flow is: |
| 9 | +# release-please opens a release PR -> merging it cuts a tag -> |
| 10 | +# the bump-brew-formula job in release.yml regenerates and PRs the formula. |
| 11 | +# Use this workflow only when that flow can't be used. |
| 12 | + |
| 13 | +on: |
| 14 | + workflow_dispatch: |
| 15 | + |
| 16 | +permissions: |
| 17 | + contents: read |
| 18 | + |
| 19 | +jobs: |
| 20 | + sync: |
| 21 | + name: Sync formula to deepgram/homebrew-tap |
| 22 | + runs-on: ubuntu-latest |
| 23 | + steps: |
| 24 | + - name: Checkout deepgram/homebrew-tap |
| 25 | + uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 |
| 26 | + with: |
| 27 | + repository: deepgram/homebrew-tap |
| 28 | + token: ${{ secrets.CLI_TAP_SYNC_PAT }} |
| 29 | + path: tap |
| 30 | + |
| 31 | + - name: Apply rust + pkgconf build deps (idempotent) |
| 32 | + working-directory: tap |
| 33 | + run: | |
| 34 | + set -euo pipefail |
| 35 | +
|
| 36 | + if grep -q 'depends_on "rust" => :build' Formula/deepgram.rb; then |
| 37 | + echo "Formula already has rust build dep; nothing to do" |
| 38 | + exit 0 |
| 39 | + fi |
| 40 | +
|
| 41 | + # Insert the build-time deps before the existing ffmpeg comment block. |
| 42 | + # Hardcoded patch (not template-driven) because this workflow runs in |
| 43 | + # situations where the template change has not yet shipped. |
| 44 | + python3 - <<'PY' |
| 45 | + path = "Formula/deepgram.rb" |
| 46 | + content = open(path).read() |
| 47 | + insert = ( |
| 48 | + ' # Build-time deps for the `cryptography` and `pydantic_core` resources,\n' |
| 49 | + ' # which compile Rust extensions via `maturin`. Language::Python::Virtualenv\n' |
| 50 | + ' # defaults to --no-binary :all: so precompiled wheels are bypassed and the\n' |
| 51 | + ' # Rust toolchain has to be available during install.\n' |
| 52 | + ' depends_on "pkgconf" => :build\n' |
| 53 | + ' depends_on "rust" => :build\n' |
| 54 | + '\n' |
| 55 | + ) |
| 56 | + marker = " # Used by `dg debug probe`" |
| 57 | + if marker not in content: |
| 58 | + raise SystemExit( |
| 59 | + f"Could not find expected marker {marker!r} in formula; " |
| 60 | + "tap formula may have been hand-edited. Inspect manually." |
| 61 | + ) |
| 62 | + if content.count(marker) != 1: |
| 63 | + raise SystemExit( |
| 64 | + f"Marker {marker!r} appears multiple times; refusing to patch ambiguously." |
| 65 | + ) |
| 66 | + open(path, "w").write(content.replace(marker, insert + marker, 1)) |
| 67 | + print("Patched formula with rust + pkgconf build deps") |
| 68 | + PY |
| 69 | +
|
| 70 | + - name: Commit and push if changed |
| 71 | + working-directory: tap |
| 72 | + env: |
| 73 | + GH_TOKEN: ${{ secrets.CLI_TAP_SYNC_PAT }} |
| 74 | + run: | |
| 75 | + set -euo pipefail |
| 76 | +
|
| 77 | + if git diff --quiet -- Formula/deepgram.rb; then |
| 78 | + echo "No changes to commit; formula is already up to date" |
| 79 | + exit 0 |
| 80 | + fi |
| 81 | +
|
| 82 | + # Attribute the commit to whoever owns CLI_TAP_SYNC_PAT so the change |
| 83 | + # has a clear, linkable author. Same pattern as bump-brew-formula in |
| 84 | + # release.yml — we want the credential owner, not ${{ github.actor }} |
| 85 | + # (which would attribute to whoever clicked Run workflow). |
| 86 | + PAT_LOGIN=$(gh api /user --jq .login) |
| 87 | + PAT_ID=$(gh api /user --jq .id) |
| 88 | + git config user.name "${PAT_LOGIN}" |
| 89 | + git config user.email "${PAT_ID}+${PAT_LOGIN}@users.noreply.github.com" |
| 90 | +
|
| 91 | + git add Formula/deepgram.rb |
| 92 | + git commit -m "Add rust + pkgconf as build-time deps for cryptography and pydantic_core |
| 93 | +
|
| 94 | +Manual sync from deepgram/cli's sync-brew-formula workflow. Fixes |
| 95 | +'brew install deepgram/tap/deepgram' failing during cryptography and |
| 96 | +pydantic_core source builds: both compile Rust extensions via maturin, |
| 97 | +and Language::Python::Virtualenv defaults to --no-binary :all: so the |
| 98 | +precompiled wheels are bypassed and the Rust toolchain has to be |
| 99 | +available during install. |
| 100 | + |
| 101 | +Same pattern homebrew-core's Aider, ansible, azure-cli use." |
| 102 | + git push |
0 commit comments