:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(cli): install posthog-cli with Homebrew (#105186)
Hugues Pouillot76b821efb4dc
diff --git a/.github/workflows/release-cli.yml b/.github/workflows/release-cli.ymlindex 989eb70c4ea5..d4251ee9b8c7 100644--- a/.github/workflows/release-cli.yml+++ b/.github/workflows/release-cli.yml@@ -1145,12 +1145,60 @@ jobs:NPM_CONFIG_PROVENANCE: trueNODE_AUTH_TOKEN: ''+ publish-homebrew:+ needs:+ - release+ - plan-release+ - host-release+ runs-on: 'ubuntu-22.04'+ timeout-minutes: 10+ # Stable releases only, deliberately stricter than publish-npm. A tap has+ # one formula and no channels, so a prerelease formula is what every+ # `brew install` resolves. npm can at least carry a prerelease on a+ # separate dist-tag. Do not "fix" this to match publish-npm.+ if: ${{ needs.plan-release.result == 'success' && !fromJson(needs.plan-release.outputs.val).announcement_is_prerelease }}+ steps:+ # cargo-dist generates the formula complete with per-platform URLs and+ # checksums, so unlike the phrocs formula there is no template to fill.+ - name: Fetch the generated formula+ uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0+ with:+ pattern: artifacts-*+ path: artifacts/+ merge-multiple: true+ # Stashed outside the workspace because checking out the tap cleans it.+ - name: Stash the formula+ run: cp artifacts/posthog-cli.rb "$RUNNER_TEMP/posthog-cli.rb"+ - name: Generate Homebrew tap token+ id: app-token+ uses: actions/create-github-app-token@1b10c78c7865c340bc4f6099eb2f838309f1e8c3 # v3.1.1+ with:+ client-id: ${{ secrets.GH_APP_HOMEBREW_TAP_RELEASER_APP_ID }}+ private-key: ${{ secrets.GH_APP_HOMEBREW_TAP_RELEASER_PRIVATE_KEY }}+ owner: PostHog+ repositories: homebrew-tap+ - name: Checkout Homebrew tap+ uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2+ with:+ repository: PostHog/homebrew-tap+ token: ${{ steps.app-token.outputs.token }}+ - name: Update the formula+ run: cp "$RUNNER_TEMP/posthog-cli.rb" Formula/posthog-cli.rb+ - name: Commit the formula+ uses: planetscale/ghcommit-action@25309d8005ac7c3bcd61d3fe19b69e0fe47dbdde # v0.2.20+ with:+ commit_message: 'chore: update posthog-cli formula to ${{ needs.release.outputs.new-version }}'+ repo: PostHog/homebrew-tap+ branch: main+ env:+ GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}+notify-released:name: Notify Slack - Release Published- needs: [notify-approval-needed, release, host-release, publish-npm]+ needs: [notify-approval-needed, release, host-release, publish-npm, publish-homebrew]runs-on: ubuntu-24.04timeout-minutes: 5- if: always() && needs.host-release.result == 'success' && (needs.publish-npm.result == 'success' || needs.publish-npm.result == 'skipped') && needs.notify-approval-needed.outputs.slack_ts != ''+ if: always() && needs.host-release.result == 'success' && (needs.publish-npm.result == 'success' || needs.publish-npm.result == 'skipped') && (needs.publish-homebrew.result == 'success' || needs.publish-homebrew.result == 'skipped') && needs.notify-approval-needed.outputs.slack_ts != ''steps:- name: Notify Slack - Release Publisheduses: posthog/.github/.github/actions/slack-thread-reply@03565438486849ac0d19543de36c248a27d32a2f@@ -1174,12 +1222,13 @@ jobs:- build-global-artifacts- host-release- publish-npm+ - publish-homebrewruns-on: ubuntu-24.04timeout-minutes: 5if: >-always() && (needs.plan-release.result == 'failure' || needs.build-local-artifacts.result == 'failure'|| needs.build-global-artifacts.result == 'failure' || needs.host-release.result == 'failure'- || needs.publish-npm.result == 'failure')+ || needs.publish-npm.result == 'failure' || needs.publish-homebrew.result == 'failure')steps:- name: Collect failed jobsid: failure-metadatadiff --git a/cli/README.md b/cli/README.mdindex b5c5254d0158..ef4c8857e2d3 100644--- a/cli/README.md+++ b/cli/README.md@@ -16,6 +16,12 @@ If you'd rather not use our wizard, you can install the CLI by running:npm install -g @posthog/cli@latest```+Or with Homebrew:++```bash+brew install posthog/tap/posthog-cli+```+Note: if you are installing the CLI for use with a coding agent, you should follow our [setup for agents](https://posthog.com/docs/cli#setup-for-agents) instructions.## Usagediff --git a/cli/RELEASING.md b/cli/RELEASING.mdindex ea68f22d49ab..792716924d40 100644--- a/cli/RELEASING.md+++ b/cli/RELEASING.md@@ -54,6 +54,17 @@ It needs three repository variables:The role is scoped to the `posthog-cli/` prefix and to invalidations on that one distribution, so the workflow cannot touch another project's artifacts.+### Homebrew++`installers` includes `homebrew`, so cargo-dist generates `posthog-cli.rb` with per-platform URLs and checksums already filled in.+The `publish-homebrew` job copies it into `PostHog/homebrew-tap`, which is the same tap phrocs and hogland use.++Do not hand-edit `Formula/posthog-cli.rb` in that repo; the next release overwrites it.+A prerelease does not move the formula, because Homebrew has no notion of one.++Users install with `brew install posthog/tap/posthog-cli`.+A Homebrew install is managed by Homebrew, so `brew upgrade` is how it updates.+If you need to cut a release by hand, merge a CLI changeset to `master` and let `Release CLI` run from there.Do not push `posthog-cli/vX.Y.Z` tags manually; cargo-dist tag-push releases are disabled.If cargo-dist fails after `Release CLI` commits the release bump, rerun the failed jobs from the same workflow run.diff --git a/dist-workspace.toml b/dist-workspace.tomlindex e5c6cc5ed7c3..37772b108d00 100644--- a/dist-workspace.toml+++ b/dist-workspace.toml@@ -12,7 +12,7 @@ ci = "github"# Keep generated release workflows off tag-push publishing; Release CLI owns publishingdispatch-releases = true# The installers to generate for each app-installers = ["shell", "powershell", "npm"]+installers = ["shell", "powershell", "npm", "homebrew"]# Target platforms to build apps for (Rust target-triple syntax)targets = ["aarch64-apple-darwin",@@ -29,6 +29,9 @@ install-path = "~/.posthog"install-updater = true# A namespace to use when publishing this package to the npm registrynpm-scope = "@posthog"+# The tap the generated formula is published to. It has to exist already,+# and it is the same one phrocs and hogland use.+tap = "PostHog/homebrew-tap"# Publish jobs to run in CIpublish-jobs = ["npm"]unix-archive = ".tar.gz"