@devries-cameron20 / composio-1 / commits / 417d614ef
Fork 0

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

ci: add bump-homebrew-tap workflow (#3355)

## Summary - New workflow that auto-bumps the Homebrew formula in [ComposioHQ/homebrew-tap](https://github.com/ComposioHQ/homebrew-tap) whenever a stable CLI release is published. - Triggers on `release: published` for tags matching `@composio/cli@*`. Skips beta/rc/alpha tags. Also exposes `workflow_dispatch` for manual replay. - Pulls SHA256s from the release's `checksums.txt`, edits `Formula/composio.rb` in the tap repo, and commits/pushes (no-op if already current). ## Setup required before this can run - Create a fine-grained PAT scoped to `ComposioHQ/homebrew-tap` only, with `Contents: read/write`. - Add it as a repo secret named `HOMEBREW_TAP_TOKEN` in this repo. Without that secret the checkout step will fail; the workflow won't break anything else. ## Test plan - [ ] Land this PR - [ ] Add `HOMEBREW_TAP_TOKEN` secret - [ ] Manually run via `workflow_dispatch` with tag `@composio/cli@0.2.28` — should be a no-op (formula already at 0.2.28) - [ ] Verify next CLI release auto-bumps the formula --------- Co-authored-by: Alberto Schiabel <jkomyno@users.noreply.github.com> Co-authored-by: jkomyno <alberto@composio.dev>

Sarah Simionescu committed Jun 24, 2026 at 16:23 UTC 417d614ef9c5a04db26bcb122e455b952a0be2a7
2 files changed +231
.github/scripts/bump-homebrew-formula.py new
+111
@@ -0,0 +1,111 @@
1 +#!/usr/bin/env python3
2 +"""Bump version, release-tag URLs, and per-platform sha256 in a Composio Homebrew formula.
3 +
4 +Used by .github/workflows/cli.bump-homebrew-tap.yml. Reads inputs from env vars
5 +so the bash side has a clean interface; can be run locally for testing:
6 +
7 + TAG=@composio/cli@0.2.29 VERSION=0.2.29 \\
8 + DARWIN_ARM=<sha> DARWIN_X86=<sha> LINUX_ARM=<sha> LINUX_X86=<sha> \\
9 + .github/scripts/bump-homebrew-formula.py path/to/Formula/composio.rb
10 +
11 +Exits non-zero if any required env var is missing/invalid or if no edits land.
12 +"""
13 +
14 +from __future__ import annotations
15 +
16 +import os
17 +import re
18 +import sys
19 +
20 +
21 +REQUIRED_ENV = ("TAG", "VERSION", "DARWIN_ARM", "DARWIN_X86", "LINUX_ARM", "LINUX_X86")
22 +SHA256_RE = re.compile(r"[0-9a-f]{64}")
23 +
24 +
25 +def main(argv: list[str]) -> int:
26 + if len(argv) != 2:
27 + print(f"usage: {argv[0]} <formula-path>", file=sys.stderr)
28 + return 2
29 +
30 + path = argv[1]
31 + missing = [k for k in REQUIRED_ENV if not os.environ.get(k)]
32 + if missing:
33 + print(f"missing env vars: {', '.join(missing)}", file=sys.stderr)
34 + return 2
35 +
36 + tag = os.environ["TAG"]
37 + version = os.environ["VERSION"]
38 + shas = {
39 + "darwin-aarch64": os.environ["DARWIN_ARM"],
40 + "darwin-x64": os.environ["DARWIN_X86"],
41 + "linux-aarch64": os.environ["LINUX_ARM"],
42 + "linux-x64": os.environ["LINUX_X86"],
43 + }
44 + for plat, sha in shas.items():
45 + if not SHA256_RE.fullmatch(sha):
46 + print(f"invalid sha for {plat}: {sha!r}", file=sys.stderr)
47 + return 2
48 +
49 + with open(path) as f:
50 + src = f.read()
51 +
52 + # Bump version line. Lambda avoids replacement-string backreference parsing
53 + # (e.g. a hostile tag containing \g<1>); same defense on tag/sha below.
54 + src, n_ver = re.subn(
55 + r'^(\s*version\s+)"[^"]+"',
56 + lambda m: f'{m.group(1)}"{version}"',
57 + src,
58 + count=1,
59 + flags=re.M,
60 + )
61 +
62 + # Bump the release-tag segment of each download URL.
63 + src, n_url = re.subn(
64 + r"(releases/download/)@composio/cli@[^/]+(/composio-)",
65 + lambda m: f"{m.group(1)}{tag}{m.group(2)}",
66 + src,
67 + )
68 +
69 + # Bump each sha256 by pairing it with the URL line directly above.
70 + updated_platforms: set[str] = set()
71 +
72 + def repl_sha(match: re.Match[str]) -> str:
73 + url_line, sha_line = match.group(1), match.group(2)
74 + for plat, sha in shas.items():
75 + if f"composio-{plat}.zip" in url_line:
76 + updated_platforms.add(plat)
77 + return url_line + re.sub(
78 + r'"[0-9a-f]{64}"',
79 + lambda _m: f'"{sha}"',
80 + sha_line,
81 + )
82 + return match.group(0)
83 +
84 + src, n_sha = re.subn(
85 + r'(url\s+"[^"]+"\s*\n)(\s*sha256\s+"[0-9a-f]{64}")',
86 + repl_sha,
87 + src,
88 + )
89 +
90 + expected_platforms = set(shas)
91 + if (
92 + n_ver != 1
93 + or n_url != len(shas)
94 + or n_sha != len(shas)
95 + or updated_platforms != expected_platforms
96 + ):
97 + print(
98 + "bump produced unexpected edits "
99 + f"(version={n_ver}, url={n_url}, sha={n_sha}, "
100 + f"updated_platforms={sorted(updated_platforms)})",
101 + file=sys.stderr,
102 + )
103 + return 1
104 +
105 + with open(path, "w") as f:
106 + f.write(src)
107 + return 0
108 +
109 +
110 +if __name__ == "__main__":
111 + sys.exit(main(sys.argv))
.github/workflows/cli.bump-homebrew-tap.yml new
+120
@@ -0,0 +1,120 @@
1 +name: Bump Homebrew Tap
2 +
3 +on:
4 + release:
5 + types: [published]
6 + workflow_dispatch:
7 + inputs:
8 + tag:
9 + description: 'Release tag to sync (e.g. @composio/cli@0.2.28)'
10 + required: true
11 + type: string
12 +
13 +permissions:
14 + contents: read
15 +
16 +concurrency:
17 + group: bump-homebrew-tap
18 + cancel-in-progress: false
19 +
20 +jobs:
21 + bump:
22 + if: github.event_name == 'workflow_dispatch' || startsWith(github.event.release.tag_name, '@composio/cli@')
23 + runs-on: ubuntu-latest
24 + steps:
25 + - name: Resolve release tag and version
26 + id: meta
27 + env:
28 + TAG_INPUT: ${{ inputs.tag }}
29 + TAG_RELEASE: ${{ github.event.release.tag_name }}
30 + run: |
31 + set -euo pipefail
32 + tag="${TAG_INPUT:-$TAG_RELEASE}"
33 + if [[ -z "$tag" ]]; then
34 + echo "::error::No tag resolved"; exit 1
35 + fi
36 + if [[ ! "$tag" =~ ^@composio/cli@ ]]; then
37 + echo "::notice::Tag $tag is not a CLI release, skipping."
38 + echo "skip=true" >> "$GITHUB_OUTPUT"
39 + exit 0
40 + fi
41 + # Skip beta/prerelease tags — only stable bumps the formula.
42 + if [[ "$tag" == *"-beta."* || "$tag" == *"-rc."* || "$tag" == *"-alpha."* ]]; then
43 + echo "::notice::Tag $tag is a prerelease, skipping."
44 + echo "skip=true" >> "$GITHUB_OUTPUT"
45 + exit 0
46 + fi
47 + version="${tag#@composio/cli@}"
48 + echo "tag=$tag" >> "$GITHUB_OUTPUT"
49 + echo "version=$version" >> "$GITHUB_OUTPUT"
50 + echo "skip=false" >> "$GITHUB_OUTPUT"
51 +
52 + - name: Download checksums
53 + if: steps.meta.outputs.skip != 'true'
54 + id: sha
55 + env:
56 + TAG: ${{ steps.meta.outputs.tag }}
57 + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
58 + run: |
59 + set -euo pipefail
60 + gh release download "$TAG" \
61 + --repo "${{ github.repository }}" \
62 + --pattern checksums.txt \
63 + --output checksums.txt
64 + extract() {
65 + grep " $1\$" checksums.txt | awk '{print $1}' || true
66 + }
67 + {
68 + echo "darwin_arm=$(extract composio-darwin-aarch64.zip)"
69 + echo "darwin_x86=$(extract composio-darwin-x64.zip)"
70 + echo "linux_arm=$(extract composio-linux-aarch64.zip)"
71 + echo "linux_x86=$(extract composio-linux-x64.zip)"
72 + } >> "$GITHUB_OUTPUT"
73 +
74 + - name: Checkout source repo (for bump script)
75 + if: steps.meta.outputs.skip != 'true'
76 + uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
77 +
78 + - name: Checkout homebrew tap
79 + if: steps.meta.outputs.skip != 'true'
80 + uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
81 + with:
82 + repository: ComposioHQ/homebrew-tap
83 + token: ${{ secrets.HOMEBREW_TAP_TOKEN }}
84 + path: tap
85 +
86 + - name: Update formula
87 + if: steps.meta.outputs.skip != 'true'
88 + env:
89 + VERSION: ${{ steps.meta.outputs.version }}
90 + TAG: ${{ steps.meta.outputs.tag }}
91 + DARWIN_ARM: ${{ steps.sha.outputs.darwin_arm }}
92 + DARWIN_X86: ${{ steps.sha.outputs.darwin_x86 }}
93 + LINUX_ARM: ${{ steps.sha.outputs.linux_arm }}
94 + LINUX_X86: ${{ steps.sha.outputs.linux_x86 }}
95 + run: |
96 + set -euo pipefail
97 + formula="tap/Formula/composio.rb"
98 + [[ -f "$formula" ]] || { echo "::error::$formula not found"; exit 1; }
99 +
100 + .github/scripts/bump-homebrew-formula.py "$formula"
101 +
102 + echo "--- updated formula ---"
103 + cat "$formula"
104 +
105 + - name: Commit and push
106 + if: steps.meta.outputs.skip != 'true'
107 + working-directory: tap
108 + env:
109 + VERSION: ${{ steps.meta.outputs.version }}
110 + run: |
111 + set -euo pipefail
112 + git config user.name "composio-release-bot"
113 + git config user.email "composio-release-bot@users.noreply.github.com"
114 + if git diff --quiet; then
115 + echo "Formula already up to date for $VERSION; nothing to commit."
116 + exit 0
117 + fi
118 + git add Formula/composio.rb
119 + git commit -m "composio $VERSION"
120 + git push origin HEAD