Skip to content

feat(cli): move Homebrew formula to dedicated homebrew-appwrite tap#1459

Merged
ChiragAgg5k merged 2 commits intomasterfrom
feat/cli-migrate-formula-to-homebrew-tap
Apr 17, 2026
Merged

feat(cli): move Homebrew formula to dedicated homebrew-appwrite tap#1459
ChiragAgg5k merged 2 commits intomasterfrom
feat/cli-migrate-formula-to-homebrew-tap

Conversation

@ChiragAgg5k
Copy link
Copy Markdown
Member

Summary

The CLI's Homebrew formula has lived in the generated sdk-for-cli repository itself, which meant users could not actually `brew install appwrite` — a Homebrew tap must live in a repo named `homebrew-`. The new tap is appwrite/homebrew-appwrite and this PR rewires the generator to publish into it.

What this changes

  • Remove the formula generator. Deletes `templates/cli/Formula/formula.rb.twig`, the matching `getFiles()` entry in `src/SDK/Language/CLI.php`, the `homebrewMacArm64Sha256` / `homebrewMacX64Sha256` / `homebrewLinuxArm64Sha256` / `homebrewLinuxX64Sha256` language params, and the `APPWRITE_CLI_HOMEBREW_*_SHA256` env-var overrides in `example.php`. Renames `setHomebrewSha256()` → `setHomebrewTap($owner, $name)` and introduces `homebrewTapOwner` / `homebrewTapName` params (defaulting to `appwrite` / `appwrite`).
  • Rewrite the publish workflow. `templates/cli/.github/workflows/publish.yml` now computes the per-target SHA256 checksums, checks out `appwrite/homebrew-appwrite` via a dedicated `HOMEBREW_TAP_GH_TOKEN` secret, rewrites `Formula/appwrite.rb` in the tap, and opens (or updates) a PR on the tap's default branch. The same Ruby snippet we used to patch version + SHA256 is reused, just pointed at the tap checkout.
  • Update user-facing install instructions. `README.md.twig` now reads `brew install appwrite/appwrite/appwrite` and links to the new tap. Self-update (`lib/commands/update.ts`) and version detection (`lib/utils.ts`) now use the fully-qualified `/` reference exposed via new `HOMEBREW_TAP` / `HOMEBREW_FORMULA` constants, so `brew info` / `brew upgrade` keep resolving to the Appwrite tap even if another tap ever ships an `appwrite` formula.

Required secrets

The generated workflow reads a new secret in sdk-for-cli:

  • `HOMEBREW_TAP_GH_TOKEN` — a GitHub token (fine-grained PAT or app token) with `contents: write` + `pull-requests: write` on `appwrite/homebrew-appwrite`. This is what the workflow uses to push the release branch and open the PR.

The existing `GH_TOKEN` secret continues to be used for the sdk-for-cli checkout + the GitHub release upload.

Related PRs

  • Bootstrap the tap repo: Bump actions/cache from 4 to 5 homebrew-appwrite#1 (see companion PR that seeds `Formula/appwrite.rb`, `README.md`, `LICENSE`, `.github/workflows/tests.yml`).
  • Delete the now-stale `Formula/` directory from `appwrite/sdk-for-cli` (cleanup PR opened separately).

Test plan

  • `docker run --rm -v $(pwd):/app -w /app php:8.3-cli php example.php cli` regenerates `examples/cli` with no `Formula/` directory and the new `brew install appwrite/appwrite/appwrite` README copy.
  • `uvx djlint templates/ --lint` → 0 errors across 520 templates.
  • `python -c 'import yaml; yaml.safe_load(open("examples/cli/.github/workflows/publish.yml"))'` parses cleanly (14 steps).
  • `HOMEBREW_TAP_GH_TOKEN` added to sdk-for-cli secrets before the next release (required for the new workflow step).
  • Dry-run of the tap workflow on the next release → verify it opens a PR titled `appwrite ` on `appwrite/homebrew-appwrite` with the four updated SHA256 values and correct `version`.

The CLI's Homebrew formula was checked in to sdk-for-cli itself, which
meant users could not `brew install` it because sdk-for-cli is not a
Homebrew tap. The official tap lives at appwrite/homebrew-appwrite, so
this change:

- Drops the `Formula/appwrite.rb` generator (template, `getFiles()`
  entry, example output, and the `APPWRITE_CLI_HOMEBREW_*_SHA256` env
  overrides in `example.php`).
- Rewrites the CLI publish workflow to compute the per-target SHA256
  checksums, check out `appwrite/homebrew-appwrite` with a dedicated
  `HOMEBREW_TAP_GH_TOKEN`, update `Formula/<executable>.rb` in the tap,
  and open a pull request back to the tap's default branch.
- Points the generated README at the new tap
  (`brew install appwrite/appwrite/appwrite`) and wires a new
  `setHomebrewTap($owner, $name)` helper + `homebrewTapOwner` /
  `homebrewTapName` params on the CLI language class.
- Qualifies the self-update and `brew info` calls in `utils.ts` and
  `update.ts` with the fully-qualified `<tap>/<formula>` reference via
  new `HOMEBREW_TAP` / `HOMEBREW_FORMULA` constants so lookups keep
  resolving to the Appwrite tap if another tap ever ships an `appwrite`
  formula.
@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented Apr 17, 2026

Greptile Summary

This PR migrates the CLI's Homebrew formula from the generated sdk-for-cli repo into a dedicated appwrite/homebrew-appwrite tap, rewiring the publish workflow to check out the tap, compute SHA256s, patch the formula, and open a PR there. The homebrewTapOwner / homebrewTapName params and derived HOMEBREW_FORMULA / HOMEBREW_TAP TypeScript constants are a clean generalization, and the Ruby heredoc reuse for formula patching is well-designed.

The one inconsistency: HOMEBREW_TAP_REPO on line 20 of publish.yml is hardcoded to appwrite/homebrew-appwrite rather than using the new Twig params, so overriding the tap owner/name via setHomebrewTap() would produce mismatched output across the workflow vs the generated TypeScript constants.

Confidence Score: 4/5

Safe to merge for Appwrite's current setup; one template inconsistency should be fixed for correctness of the generator abstraction.

All P2 finding: HOMEBREW_TAP_REPO hardcoded instead of using the new Twig params. With defaults of appwrite/appwrite this generates the correct value today, but breaks the abstraction if setHomebrewTap() is ever called with different values. No P0/P1 logic bugs found.

templates/cli/.github/workflows/publish.yml — line 20 HOMEBREW_TAP_REPO should use Twig params

Important Files Changed

Filename Overview
templates/cli/.github/workflows/publish.yml New steps check out the homebrew tap, compute SHA256s, update the formula via a Ruby heredoc, and open/update a PR on the tap — logic is sound but HOMEBREW_TAP_REPO is hardcoded instead of using the new Twig params
src/SDK/Language/CLI.php Replaces four SHA256 params with homebrewTapOwner/homebrewTapName defaults; renames setHomebrewSha256 → setHomebrewTap; removes the formula getFiles() entry cleanly
templates/cli/lib/constants.ts.twig Adds HOMEBREW_TAP and HOMEBREW_FORMULA constants derived from the new Twig params; template literal composition is correct
templates/cli/lib/utils.ts Replaces local HOMEBREW_FORMULA_NAME with the imported HOMEBREW_FORMULA constant for brew info lookup; removes redundant local variable
templates/cli/lib/commands/update.ts Replaces hardcoded "appwrite" strings in brew upgrade commands and hint messages with HOMEBREW_FORMULA / EXECUTABLE_NAME constants
templates/cli/README.md.twig Updates install instructions to brew install appwrite/appwrite/appwrite with a link to the new tap repo, using Twig params correctly
example.php Removes SHA256 env-var injection loop that is no longer needed after the formula is moved to the tap
templates/cli/Formula/formula.rb.twig File deleted — the formula now lives in the appwrite/homebrew-appwrite tap and is no longer generated into the SDK repo

Reviews (2): Last reviewed commit: "Make CLI tap workflow generic and trim c..." | Re-trigger Greptile

Comment thread templates/cli/.github/workflows/publish.yml Outdated
Comment thread templates/cli/.github/workflows/publish.yml Outdated
Addresses review feedback on PR #1459:
- Discover EXECUTABLE_NAME from the tap's Formula/*.rb at runtime (replaces
  the hardcoded `appwrite` used by the earlier checksum step). Publishing
  works for any CLI whose formula filename matches its binary prefix.
- PR body now builds the source-release URL from `github.server_url` +
  `github.repository`, and derives the workflow-repo short name via bash
  parameter expansion — no more hardcoded `appwrite/sdk-for-cli`.
- Promote the tap coordinate to a single `HOMEBREW_TAP_REPO` job-level env
  var, consumed by `actions/checkout@v4`.
- Fold the separate "Compute native binary checksums" step into the tap
  update step now that formula discovery lives in the tap checkout.
- Drop redundant prose: the 4-line block comment above the Homebrew steps,
  the 3-line param comment in CLI.php, the verbose setHomebrewTap docblock,
  the HOMEBREW_FORMULA_NAME alias + its comment in utils.ts, and the
  needless `first time: brew tap` hint in update.ts manual instructions.
ChiragAgg5k pushed a commit to appwrite/sdk-for-cli that referenced this pull request Apr 17, 2026
Companion to appwrite/sdk-generator#1459. Drops the stub `Formula/appwrite.rb`
(sdk-for-cli is not a Homebrew tap, so `brew install` never actually worked
against this repo) and rewires the release flow to the dedicated tap at
appwrite/homebrew-appwrite.

- Remove `Formula/appwrite.rb`. The canonical formula now lives in
  appwrite/homebrew-appwrite (generated there on bootstrap).
- Replace the "Update Homebrew formula checksums" step with a tap-PR flow:
  check out appwrite/homebrew-appwrite with a new HOMEBREW_TAP_GH_TOKEN
  secret, recompute SHA256s for the four native binaries, patch the
  formula in place, and open (or update) a PR on the tap.
- README: switch install command to `brew install appwrite/appwrite/appwrite`
  and link out to the tap repo; the section now covers both macOS and Linux.
- lib/constants.ts: add HOMEBREW_TAP + HOMEBREW_FORMULA so self-update and
  `brew info` consistently use the fully-qualified `<tap>/<formula>` form.
- lib/utils.ts, lib/commands/update.ts: use HOMEBREW_FORMULA everywhere
  we previously hardcoded `appwrite`.

Requires the new `HOMEBREW_TAP_GH_TOKEN` secret (fine-grained PAT with
`contents: write` + `pull-requests: write` on appwrite/homebrew-appwrite)
to be added to this repo before the next release.
@ChiragAgg5k ChiragAgg5k merged commit 906ed43 into master Apr 17, 2026
57 checks passed
@ChiragAgg5k ChiragAgg5k deleted the feat/cli-migrate-formula-to-homebrew-tap branch April 17, 2026 12:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant