@devries-cameron20 / composio-1 / commits / 08f707211
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.

fix(ci): make CLI releases reliably ship binary assets (#3515)

## Summary Permanently stops the recurring *"release published with zero assets → install/upgrade 404s"* outage (https://github.com/ComposioHQ/composio/issues/3408, https://github.com/ComposioHQ/composio/issues/3269; regressions of https://github.com/ComposioHQ/composio/issues/2625 and https://github.com/ComposioHQ/composio/issues/1820 — 3 of the last 5 stable releases shipped empty). **Root cause:** a concurrent-writer race. On a CLI version bump, `changesets/action` creates an empty `@composio/cli@x.y.z` GitHub Release in seconds, then the slower `build-cli-binaries.yml` fails its `gh release create` because the release already exists — so binaries never attach. > 🥞 **Stacked on #3415** (`pi/exclude-cli-ts-release-42161920`), which removes the *second writer* (changesets no longer creates CLI releases). Review/merge #3415 first; this PR targets that branch. This PR hardens the now-sole writer so a *partial* build can't publish either, and fixes the monitoring that hid the failure. ## What changed (`build-cli-binaries.yml` + canary) - **Draft → verify → publish.** The release is built as a **draft**, then a gate asserts all 6 canonical assets are present **and** `state == "uploaded"` (loud `::error::` + fail otherwise), and only the final step flips it to published. Drafts fire no `release: published` event and are excluded from `/releases/latest`, so no install.sh / Homebrew / redirect consumer can observe an incomplete release. - **`fail-fast: false`** on the build matrix → a single platform failure can never publish a partial set (`needs.build.result` is `success` only if all legs pass). - **Per-tag job-level `concurrency`** so re-runs / quick pushes can't interleave uploads on the same tag, without serializing unrelated betas. - **Beta-safe:** `--prerelease` is set on the draft so betas stay prereleases through the publish flip. - **`promote-stable` guard** uses `gh release view --json isDraft` (the REST tags endpoint 404s on drafts) to resume an existing draft but refuse an already-published tag. - **Least privilege:** workflow defaults to `contents: read`; only the release job opts up to `contents: write`. - **Canary fix** (`cli.install-health-check.yml`): install the newest stable **pinned** tag (`npm view @composio/cli version`) instead of the asset-aware no-arg flow, which self-heals to the last good release and kept the canary green through every outage. ## Idempotency note Re-running a run that failed **before publish** is safe (reuse draft + `--clobber`). An already-**published** tag is refused, not mutated — by design. ## Testing - Extended `test/release-workflow.test.ts` (run via `pnpm test:release-workflow`) to lock in: draft→verify→publish ordering, `fail-fast: false`, per-tag concurrency, preserved `--prerelease`, and the pinned-tag canary. ✅ passes. - `shellcheck` clean on the new `run:` scripts; YAML validated. `actionlint` runs in CI. - Runtime verification of the full green path happens on the next release CI run. ## Out of scope (deferred to their own PRs) Per reviewer consensus, these are real but *not this bug*: a per-release npm↔GitHub asset auditor (needs a grace window), the Homebrew trigger constraint (folds into #3355), `composio upgrade` missing-asset back-off (https://github.com/ComposioHQ/composio/issues/3269), and a rollback runbook. --------- Co-authored-by: Rahul Tarak <cryogenicplanet@gmail.com>

Alberto Schiabel committed Jun 16, 2026 at 15:07 UTC 08f70721100b00200dd4ab1efeef5392d087ce7a
9 files changed +801 -184
.github/scripts/cli-release/create-or-resume-draft.sh new
+45
@@ -0,0 +1,45 @@
1 +#!/usr/bin/env bash
2 +#
3 +# Create the GitHub Release as a DRAFT with every asset attached, or resume an existing
4 +# draft by re-uploading (--clobber). Refuse to mutate a tag that is already published.
5 +#
6 +# Drafts fire no `release: published` event and are excluded from `/releases/latest`, so no
7 +# anonymous consumer (install.sh, Homebrew, the redirect) can observe a release before its
8 +# assets are attached and verified. The release is only flipped to published by a later step.
9 +#
10 +# Inputs (env): RELEASE_TAG, RELEASE_NAME, CHECKOUT_REF, PRERELEASE, GH_TOKEN
11 +# BINARIES_DIR (optional, defaults to the CLI dist dir)
12 +set -euo pipefail
13 +
14 +binaries_dir="${BINARIES_DIR:-ts/packages/cli/dist/binaries}"
15 +
16 +flags=(
17 + --draft
18 + --title "$RELEASE_NAME"
19 + --target "$CHECKOUT_REF"
20 + --generate-notes
21 +)
22 +# Preserve prerelease status on the draft so betas stay prereleases once published.
23 +if [[ "$PRERELEASE" == "true" ]]; then
24 + flags+=(--prerelease)
25 +fi
26 +
27 +# Idempotent for re-runs of a not-yet-published release: reuse an existing draft and clobber
28 +# its assets. Refuse to mutate a tag that is already published.
29 +if gh release view "$RELEASE_TAG" --json isDraft --jq '.isDraft' 2>/dev/null | grep -qx true; then
30 + echo "Draft $RELEASE_TAG already exists — re-uploading assets with --clobber"
31 + gh release upload "$RELEASE_TAG" \
32 + "$binaries_dir"/*.zip \
33 + "$binaries_dir/checksums.txt" --clobber
34 +elif gh release view "$RELEASE_TAG" >/dev/null 2>&1; then
35 + # A red ❌ here is EXPECTED, not a bug, when two runs target the same tag (e.g. two quick CLI
36 + # version bumps): per-tag `concurrency` serializes them, the first publishes, and the second —
37 + # finding the tag already published — fails loudly here rather than silently clobbering a live
38 + # release. If you hit this, confirm the tag is genuinely published before re-running.
39 + echo "::error::Release $RELEASE_TAG is already published — refusing to mutate it. Investigate the publish path."
40 + exit 1
41 +else
42 + gh release create "$RELEASE_TAG" "${flags[@]}" \
43 + "$binaries_dir"/*.zip \
44 + "$binaries_dir/checksums.txt"
45 +fi
.github/scripts/cli-release/resolve-release-target.sh new
+148
@@ -0,0 +1,148 @@
1 +#!/usr/bin/env bash
2 +#
3 +# Resolve the CLI release target and write its metadata to $GITHUB_OUTPUT for the
4 +# build/release jobs of build-cli-binaries.yml. Three modes:
5 +#
6 +# - push to `next` with a ts/packages/cli/package.json version bump → stable release
7 +# - push to `next` without a bump, or workflow_dispatch build-beta → rolling beta
8 +# - workflow_dispatch promote-stable <beta tag> → stable promotion
9 +#
10 +# Inputs (env): EVENT_NAME, ACTION_INPUT, BETA_TAG_INPUT, GITHUB_TOKEN,
11 +# REPOSITORY, RUN_NUMBER, COMMIT_SHA
12 +# Output: key=value lines appended to $GITHUB_OUTPUT
13 +set -euo pipefail
14 +
15 +# Latest STABLE @composio/cli release tag, by true semver order (empty if none).
16 +#
17 +# A lexical sort is wrong here: "@composio/cli@0.2.9" sorts AFTER "0.2.10", so once a
18 +# patch reaches double digits `last` would pick the older release and beta versions
19 +# would regress. Parse the version triplet to numbers and sort numerically instead.
20 +latest_stable_tag() {
21 + gh release list \
22 + --repo "$REPOSITORY" \
23 + --exclude-drafts \
24 + --limit 1000 \
25 + --json tagName,isPrerelease \
26 + --jq '[.[]
27 + | select(.tagName | startswith("@composio/cli@"))
28 + | select(.isPrerelease == false)]
29 + | sort_by(.tagName | ltrimstr("@composio/cli@") | split(".") | map(tonumber))
30 + | last | .tagName // empty'
31 +}
32 +
33 +# Echo the next "<major>.<minor>.<patch+1>" off the latest stable release, falling
34 +# back to the working-tree package.json when no stable release exists yet.
35 +next_beta_base_version() {
36 + local latest current
37 + latest=$(latest_stable_tag)
38 + if [[ -z "$latest" ]]; then
39 + echo "No stable @composio/cli release found, falling back to package.json" >&2
40 + current=$(node -p "require('./ts/packages/cli/package.json').version")
41 + else
42 + current=${latest#@composio/cli@}
43 + fi
44 +
45 + local major minor patch
46 + IFS='.' read -r major minor patch <<<"$current"
47 + echo "${major}.${minor}.$((patch + 1))"
48 +}
49 +
50 +emit_beta_target() {
51 + local next_version release_tag
52 + next_version=$(next_beta_base_version)
53 + release_tag="@composio/cli@${next_version}-beta.${RUN_NUMBER}"
54 + {
55 + echo "checkout_ref=${COMMIT_SHA}"
56 + echo "release_name=CLI Beta ${release_tag}"
57 + echo "release_tag=${release_tag}"
58 + echo "release_version=${next_version}"
59 + echo "prerelease=true"
60 + echo "make_latest=false"
61 + } >>"$GITHUB_OUTPUT"
62 +}
63 +
64 +emit_stable_target() {
65 + local release_tag=$1 release_version=$2 checkout_ref=$3
66 + {
67 + echo "checkout_ref=${checkout_ref}"
68 + echo "release_name=CLI ${release_tag}"
69 + echo "release_tag=${release_tag}"
70 + echo "release_version=${release_version}"
71 + echo "prerelease=false"
72 + echo "make_latest=true"
73 + } >>"$GITHUB_OUTPUT"
74 +}
75 +
76 +# ── Push to next ──
77 +if [[ "$EVENT_NAME" == "push" ]]; then
78 + current_version=$(node -p "require('./ts/packages/cli/package.json').version")
79 + previous_version=$(git show HEAD^:ts/packages/cli/package.json 2>/dev/null \
80 + | node -p "JSON.parse(require('fs').readFileSync('/dev/stdin','utf8')).version" 2>/dev/null || echo "")
81 +
82 + # A version bump on push is a stable release; anything else is a rolling beta.
83 + if [[ -n "$previous_version" && "$current_version" != "$previous_version" ]]; then
84 + emit_stable_target "@composio/cli@${current_version}" "$current_version" "$COMMIT_SHA"
85 + else
86 + emit_beta_target
87 + fi
88 + exit 0
89 +fi
90 +
91 +# ── workflow_dispatch: build-beta ──
92 +if [[ "$EVENT_NAME" == "workflow_dispatch" && "$ACTION_INPUT" == "build-beta" ]]; then
93 + emit_beta_target
94 + exit 0
95 +fi
96 +
97 +# ── workflow_dispatch: promote-stable ──
98 +if [[ "$ACTION_INPUT" != "promote-stable" ]]; then
99 + echo "Unknown action: $ACTION_INPUT" >&2
100 + exit 1
101 +fi
102 +
103 +if [[ -z "$BETA_TAG_INPUT" ]]; then
104 + echo "beta_tag input is required for promote-stable" >&2
105 + exit 1
106 +fi
107 +
108 +encoded_beta_tag=$(python3 -c 'import os, urllib.parse; print(urllib.parse.quote(os.environ["BETA_TAG_INPUT"], safe=""))')
109 +
110 +release_json=$(curl -fsSL \
111 + -H "Authorization: Bearer ${GITHUB_TOKEN}" \
112 + -H "Accept: application/vnd.github+json" \
113 + "https://api.github.com/repos/${REPOSITORY}/releases/tags/${encoded_beta_tag}")
114 +
115 +is_prerelease=$(jq -r '.prerelease' <<<"$release_json")
116 +if [[ "$is_prerelease" != "true" ]]; then
117 + echo "Release ${BETA_TAG_INPUT} is not a beta prerelease" >&2
118 + exit 1
119 +fi
120 +
121 +if [[ ! "$BETA_TAG_INPUT" =~ ^@composio/cli@([0-9]+\.[0-9]+\.[0-9]+)-beta\.[0-9]+$ ]]; then
122 + echo "Beta tag must match @composio/cli@<version>-beta.<number>" >&2
123 + exit 1
124 +fi
125 +
126 +stable_version="${BASH_REMATCH[1]}"
127 +stable_tag="@composio/cli@${stable_version}"
128 +
129 +# Refuse to re-promote an already-PUBLISHED stable release, but allow resuming an
130 +# existing DRAFT (a prior promote run that built assets but did not publish). The
131 +# REST `/releases/tags/{tag}` endpoint returns 404 for drafts, so use `gh release view`
132 +# — it resolves drafts by name and exposes `isDraft`.
133 +if isdraft=$(gh release view "$stable_tag" --json isDraft --jq '.isDraft' 2>/dev/null); then
134 + if [[ "$isdraft" == "true" ]]; then
135 + echo "Stable release ${stable_tag} exists as a draft — resuming (assets will be re-uploaded)."
136 + else
137 + echo "Stable release ${stable_tag} is already published" >&2
138 + exit 1
139 + fi
140 +fi
141 +
142 +target_commitish=$(jq -r '.target_commitish' <<<"$release_json")
143 +if [[ -z "$target_commitish" || "$target_commitish" == "null" ]]; then
144 + echo "Beta release ${BETA_TAG_INPUT} does not expose target_commitish" >&2
145 + exit 1
146 +fi
147 +
148 +emit_stable_target "$stable_tag" "$stable_version" "$target_commitish"
.github/scripts/cli-release/verify-assets.sh new
+48
@@ -0,0 +1,48 @@
1 +#!/usr/bin/env bash
2 +#
3 +# Loud failure gate: assert the full canonical asset set is attached to the release AND fully
4 +# uploaded (state == "uploaded"). An asset can appear in the listing while still processing,
5 +# which is exactly how a release ends up serving 404s — so require state == "uploaded", with a
6 +# bounded retry while uploads settle.
7 +#
8 +# Inputs (env): RELEASE_TAG, GH_TOKEN
9 +# VERIFY_ATTEMPTS / VERIFY_SLEEP_SECONDS (optional, for fast tests)
10 +set -euo pipefail
11 +
12 +# Keep this list in lock-step with the build matrix in build-cli-binaries.yml (4 platforms)
13 +# plus the skill bundle and checksums. Adding a platform to the matrix must extend this list.
14 +expected=(
15 + composio-linux-x64.zip
16 + composio-linux-aarch64.zip
17 + composio-darwin-x64.zip
18 + composio-darwin-aarch64.zip
19 + composio-skill.zip
20 + checksums.txt
21 +)
22 +
23 +attempts="${VERIFY_ATTEMPTS:-10}"
24 +sleep_seconds="${VERIFY_SLEEP_SECONDS:-15}"
25 +
26 +for attempt in $(seq 1 "$attempts"); do
27 + # Single snapshot per attempt — querying names and state separately would open a
28 + # time-of-check/time-of-use gap in the very gate meant to close one.
29 + payload=$(gh release view "$RELEASE_TAG" --json assets)
30 + mapfile -t uploaded < <(jq -r '.assets[] | select(.state == "uploaded") | .name' <<<"$payload" | sort)
31 +
32 + missing=()
33 + for want in "${expected[@]}"; do
34 + printf '%s\n' "${uploaded[@]}" | grep -qxF "$want" || missing+=("$want")
35 + done
36 +
37 + if [[ ${#missing[@]} -eq 0 ]]; then
38 + echo "✅ All ${#expected[@]} expected assets present and uploaded."
39 + exit 0
40 + fi
41 +
42 + echo "Attempt ${attempt}/${attempts} — missing or not-yet-uploaded: ${missing[*]}"
43 + if [[ "$attempt" -eq "$attempts" ]]; then
44 + echo "::error::Release $RELEASE_TAG is incomplete — missing or not uploaded: ${missing[*]}"
45 + exit 1
46 + fi
47 + sleep "$sleep_seconds"
48 +done
.github/workflows/build-cli-binaries.yml
+67 -178
@@ -7,6 +7,7 @@ on:
7 - 'ts/packages/cli/**'
8 - 'ts/packages/cli-local-tools/**'
9 - '.github/actions/setup-node-pnpm-bun/action.yml'
10 + - '.github/scripts/cli-release/**'
11 - '.github/workflows/build-cli-binaries.yml'
12 - 'mise.toml'
13 - 'mise.lock'
@@ -23,8 +24,11 @@ on:
24 description: 'Existing beta release tag to promote (only for promote-stable, e.g. @composio/cli@0.2.20-beta.42)'
25 required: false
26
27 +# Least privilege by default: only the release job creates/edits releases and uploads assets.
28 +# `prepare` reads releases (gh release list) and `build` uploads workflow artifacts — both work
29 +# with read access. The release job opts up to `contents: write` for itself.
30 permissions:
27 - contents: write
31 + contents: read
32
33 jobs:
34 prepare:
@@ -54,150 +58,7 @@ jobs:
58 REPOSITORY: ${{ github.repository }}
59 RUN_NUMBER: ${{ github.run_number }}
60 COMMIT_SHA: ${{ github.sha }}
57 - run: |
58 - set -euo pipefail
59 -
60 - # ── Push to next ──
61 - if [[ "$EVENT_NAME" == "push" ]]; then
62 - # Check if ts/packages/cli/package.json version changed → stable release
63 - current_version=$(node -p "require('./ts/packages/cli/package.json').version")
64 - previous_version=$(git show HEAD^:ts/packages/cli/package.json 2>/dev/null | node -p "JSON.parse(require('fs').readFileSync('/dev/stdin','utf8')).version" 2>/dev/null || echo "")
65 -
66 - if [[ -n "$previous_version" && "$current_version" != "$previous_version" ]]; then
67 - release_tag="@composio/cli@${current_version}"
68 - release_name="CLI ${release_tag}"
69 - {
70 - echo "checkout_ref=${COMMIT_SHA}"
71 - echo "release_name=${release_name}"
72 - echo "release_tag=${release_tag}"
73 - echo "release_version=${current_version}"
74 - echo "prerelease=false"
75 - echo "make_latest=true"
76 - } >> "$GITHUB_OUTPUT"
77 - exit 0
78 - fi
79 -
80 - # Otherwise → beta release
81 - # Find the latest stable CLI release to determine next version
82 - latest_stable_tag=$(gh release list \
83 - --repo "$REPOSITORY" \
84 - --json tagName,isPrerelease \
85 - --jq '[.[] | select(.tagName | startswith("@composio/cli@")) | select(.isPrerelease == false)] | sort_by(.tagName) | last | .tagName // empty')
86 -
87 - if [[ -z "$latest_stable_tag" ]]; then
88 - echo "No stable @composio/cli release found, falling back to package.json"
89 - current_version=$(node -p "require('./ts/packages/cli/package.json').version")
90 - else
91 - current_version=$(echo "$latest_stable_tag" | sed 's/@composio\/cli@//')
92 - fi
93 -
94 - # Bump patch version for the beta
95 - IFS='.' read -r major minor patch <<< "$current_version"
96 - next_version="${major}.${minor}.$((patch + 1))"
97 -
98 - release_tag="@composio/cli@${next_version}-beta.${RUN_NUMBER}"
99 - release_name="CLI Beta ${release_tag}"
100 - {
101 - echo "checkout_ref=${COMMIT_SHA}"
102 - echo "release_name=${release_name}"
103 - echo "release_tag=${release_tag}"
104 - echo "release_version=${next_version}"
105 - echo "prerelease=true"
106 - echo "make_latest=false"
107 - } >> "$GITHUB_OUTPUT"
108 - exit 0
109 - fi
110 -
111 - # ── workflow_dispatch: build-beta ──
112 - if [[ "$EVENT_NAME" == "workflow_dispatch" ]] && [[ "$ACTION_INPUT" == "build-beta" ]]; then
113 - latest_stable_tag=$(gh release list \
114 - --repo "$REPOSITORY" \
115 - --json tagName,isPrerelease \
116 - --jq '[.[] | select(.tagName | startswith("@composio/cli@")) | select(.isPrerelease == false)] | sort_by(.tagName) | last | .tagName // empty')
117 -
118 - if [[ -z "$latest_stable_tag" ]]; then
119 - current_version=$(node -p "require('./ts/packages/cli/package.json').version")
120 - else
121 - current_version=$(echo "$latest_stable_tag" | sed 's/@composio\/cli@//')
122 - fi
123 -
124 - IFS='.' read -r major minor patch <<< "$current_version"
125 - next_version="${major}.${minor}.$((patch + 1))"
126 -
127 - release_tag="@composio/cli@${next_version}-beta.${RUN_NUMBER}"
128 - release_name="CLI Beta ${release_tag}"
129 - {
130 - echo "checkout_ref=${COMMIT_SHA}"
131 - echo "release_name=${release_name}"
132 - echo "release_tag=${release_tag}"
133 - echo "release_version=${next_version}"
134 - echo "prerelease=true"
135 - echo "make_latest=false"
136 - } >> "$GITHUB_OUTPUT"
137 - exit 0
138 - fi
139 -
140 - # ── Promote stable (workflow_dispatch with promote-stable) ──
141 - if [[ "$ACTION_INPUT" != "promote-stable" ]]; then
142 - echo "Unknown action: $ACTION_INPUT"
143 - exit 1
144 - fi
145 -
146 - if [[ -z "$BETA_TAG_INPUT" ]]; then
147 - echo "beta_tag input is required for promote-stable"
148 - exit 1
149 - fi
150 -
151 - encoded_beta_tag=$(python3 -c 'import os, urllib.parse; print(urllib.parse.quote(os.environ["BETA_TAG_INPUT"], safe=""))')
152 -
153 - release_json=$(curl -fsSL \
154 - -H "Authorization: Bearer ${GITHUB_TOKEN}" \
155 - -H "Accept: application/vnd.github+json" \
156 - "https://api.github.com/repos/${REPOSITORY}/releases/tags/${encoded_beta_tag}")
157 -
158 - is_prerelease=$(jq -r '.prerelease' <<<"$release_json")
159 - if [[ "$is_prerelease" != "true" ]]; then
160 - echo "Release ${BETA_TAG_INPUT} is not a beta prerelease"
161 - exit 1
162 - fi
163 -
164 - if [[ ! "$BETA_TAG_INPUT" =~ ^@composio/cli@([0-9]+\.[0-9]+\.[0-9]+)-beta\.[0-9]+$ ]]; then
165 - echo "Beta tag must match @composio/cli@<version>-beta.<number>"
166 - exit 1
167 - fi
168 -
169 - stable_version="${BASH_REMATCH[1]}"
170 - stable_tag="@composio/cli@${stable_version}"
171 - export stable_tag
172 -
173 - stable_status=$(curl -sS -o /tmp/stable-release.json -w "%{http_code}" \
174 - -H "Authorization: Bearer ${GITHUB_TOKEN}" \
175 - -H "Accept: application/vnd.github+json" \
176 - "https://api.github.com/repos/${REPOSITORY}/releases/tags/$(python3 -c 'import os, urllib.parse; print(urllib.parse.quote(os.environ["stable_tag"], safe=""))')")
177 - if [[ "$stable_status" == "200" ]]; then
178 - echo "Stable release ${stable_tag} already exists"
179 - exit 1
180 - fi
181 - if [[ "$stable_status" != "404" ]]; then
182 - echo "Unexpected response while checking stable release ${stable_tag}: HTTP ${stable_status}"
183 - cat /tmp/stable-release.json
184 - exit 1
185 - fi
186 -
187 - target_commitish=$(jq -r '.target_commitish' <<<"$release_json")
188 - if [[ -z "$target_commitish" || "$target_commitish" == "null" ]]; then
189 - echo "Beta release ${BETA_TAG_INPUT} does not expose target_commitish"
190 - exit 1
191 - fi
192 -
193 - {
194 - echo "checkout_ref=${target_commitish}"
195 - echo "release_name=CLI ${stable_tag}"
196 - echo "release_tag=${stable_tag}"
197 - echo "release_version=${stable_version}"
198 - echo "prerelease=false"
199 - echo "make_latest=true"
200 - } >> "$GITHUB_OUTPUT"
61 + run: bash .github/scripts/cli-release/resolve-release-target.sh
62
63 build:
64 name: Build ${{ matrix.artifact }}
@@ -205,6 +66,11 @@ jobs:
66 if: needs.prepare.result == 'success'
67 runs-on: ${{ matrix.runner }}
68 strategy:
69 + # Never publish a partial platform set: with fail-fast disabled, the build job's
70 + # result is `success` only when EVERY matrix leg passes, so a single failure makes
71 + # `needs.build.result != 'success'` and the release job is skipped. It also surfaces
72 + # all platform failures at once instead of cancelling siblings on the first error.
73 + fail-fast: false
74 matrix:
75 include:
76 - target: bun-linux-x64
@@ -305,10 +171,30 @@ jobs:
171 retention-days: 7
172
173 release:
308 - name: Create Release
174 + name: Release (draft → verify → publish)
175 needs: [prepare, build]
176 runs-on: ubuntu-latest
177 + permissions:
178 + contents: write # create/edit the GitHub Release and upload assets
179 + # fail-fast: false on the build matrix ⇒ this is `success` only if ALL platforms built,
180 + # so a partial set can never reach the release path.
181 if: needs.build.result == 'success'
182 + # Serialize runs that target the SAME release tag (e.g. two quick pushes, or a re-run
183 + # racing the original) so they cannot interleave uploads. Keyed on the resolved tag so
184 + # unrelated beta builds are not serialized behind each other. Job-level concurrency may
185 + # read `needs.*` outputs (workflow-level cannot). The serialized loser fails loudly at the
186 + # "already published" guard in create-or-resume-draft.sh — that red ❌ is by design.
187 + concurrency:
188 + group: cli-release-${{ needs.prepare.outputs.release_tag }}
189 + cancel-in-progress: false
190 + env:
191 + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
192 + RELEASE_TAG: ${{ needs.prepare.outputs.release_tag }}
193 + RELEASE_NAME: ${{ needs.prepare.outputs.release_name }}
194 + PRERELEASE: ${{ needs.prepare.outputs.prerelease }}
195 + MAKE_LATEST: ${{ needs.prepare.outputs.make_latest }}
196 + CHECKOUT_REF: ${{ needs.prepare.outputs.checkout_ref }}
197 + RELEASE_HELPERS_DIR: ${{ github.workspace }}/.release-workflow/.github/scripts/cli-release
198
199 steps:
200 - name: Checkout
@@ -328,13 +214,9 @@ jobs:
214 path: ts/packages/cli/dist/binaries
215 merge-multiple: true
216
331 - - name: Generate checksums
332 - working-directory: ts/packages/cli
333 - run: bun run ./scripts/generate-checksums.ts
334 -
335 - - name: Display checksums
336 - run: cat ts/packages/cli/dist/binaries/checksums.txt
337 -
217 + # Package skills BEFORE generating checksums so composio-skill.zip is included in
218 + # checksums.txt alongside the platform binaries (generate-checksums hashes every .zip
219 + # in dist/binaries).
220 - name: Package skill files
221 working-directory: ts/packages/cli
222 env:
@@ -349,33 +231,40 @@ jobs:
231 pnpm run build:skills -- --channel "$channel" --output-dir ./dist/skills
232 cd dist/skills && zip -r ../binaries/composio-skill.zip composio-cli/
233
352 - - name: Create GitHub Release
353 - env:
354 - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
355 - RELEASE_TAG: ${{ needs.prepare.outputs.release_tag }}
356 - RELEASE_NAME: ${{ needs.prepare.outputs.release_name }}
357 - PRERELEASE: ${{ needs.prepare.outputs.prerelease }}
358 - MAKE_LATEST: ${{ needs.prepare.outputs.make_latest }}
359 - CHECKOUT_REF: ${{ needs.prepare.outputs.checkout_ref }}
360 - run: |
361 - set -euo pipefail
362 -
363 - flags=(
364 - --title "$RELEASE_NAME"
365 - --target "$CHECKOUT_REF"
366 - --generate-notes
367 - )
234 + - name: Generate checksums
235 + working-directory: ts/packages/cli
236 + run: bun run ./scripts/generate-checksums.ts
237
369 - if [[ "$PRERELEASE" == "true" ]]; then
370 - flags+=(--prerelease)
371 - flags+=(--latest=false)
372 - else
373 - flags+=(--latest)
374 - fi
238 + - name: Display checksums
239 + run: cat ts/packages/cli/dist/binaries/checksums.txt
240
376 - gh release create "$RELEASE_TAG" "${flags[@]}" \
377 - ts/packages/cli/dist/binaries/*.zip \
378 - ts/packages/cli/dist/binaries/checksums.txt
241 + - name: Checkout workflow release helpers
242 + uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
243 + with:
244 + ref: ${{ github.workflow_sha }}
245 + path: .release-workflow
246 + sparse-checkout: |
247 + .github/scripts/cli-release
248 + sparse-checkout-cone-mode: false
249 +
250 + # Build the release as a DRAFT first. Drafts fire no `release: published` event and are
251 + # excluded from the `/releases/latest` redirect, so no anonymous consumer (install.sh,
252 + # Homebrew, the redirect) can ever observe a release before its assets are attached and
253 + # verified. The release is only flipped to published as the final step below.
254 + - name: Create draft release with all assets
255 + run: bash "$RELEASE_HELPERS_DIR/create-or-resume-draft.sh"
256 +
257 + # Loud failure gate: assert the full canonical asset set is attached AND fully uploaded.
258 + # An asset can appear in the list while still processing (`state != "uploaded"`), which is
259 + # exactly how a release ends up serving 404s, so we require state == "uploaded".
260 + - name: Verify all release assets are present and uploaded
261 + run: bash "$RELEASE_HELPERS_DIR/verify-assets.sh"
262 +
263 + # Publishing is the ONLY step that exposes the release. Do not edit the body here: a known
264 + # GitHub PATCH race drops body changes made in the same call as the draft flip, and the
265 + # notes were already generated at draft creation. Prerelease status was set on the draft.
266 + - name: Publish release (flip draft → published)
267 + run: gh release edit "$RELEASE_TAG" --draft=false --latest="$MAKE_LATEST"
268
269 test-installation:
270 name: Test Installation
.github/workflows/cli.install-health-check.yml
+43 -3
@@ -5,24 +5,64 @@ on:
5 - cron: '0 * * * *'
6 workflow_dispatch:
7
8 +permissions:
9 + contents: read # gh release list reads the published releases
10 +
11 jobs:
12 health-check:
13 name: Test CLI Installation
14 runs-on: ubuntu-latest
15 + env:
16 + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
17 steps:
13 - - name: Run install script
18 + # Resolve the newest PUBLISHED stable @composio/cli release — exactly what install.sh and
19 + # the /releases/latest redirect (Homebrew, humans) resolve and download from.
20 + #
21 + # Deliberately NOT `npm view @composio/cli version`: npm's latest dist-tag is bumped by
22 + # changesets minutes before the binary workflow finishes the draft build and publishes the
23 + # GitHub release. Pinning to the npm version would 404 during that healthy publish gap and
24 + # false-page hourly. Drafts are excluded here, so this only ever resolves a fully-published
25 + # release — the in-flight one stays invisible until its assets are verified and attached.
26 + - name: Resolve newest published release
27 + id: resolve
28 run: |
29 set -euo pipefail
16 - curl -fsSL https://composio.dev/install | bash
30 + tag=$(gh release list --repo "${{ github.repository }}" --limit 1000 --exclude-drafts --exclude-pre-releases --json tagName \
31 + --jq '.[] | select(.tagName | startswith("@composio/cli@")) | .tagName' \
32 + | sed -n '1p')
33 + if [[ -z "$tag" ]]; then
34 + echo "::error::No published @composio/cli release found"
35 + exit 1
36 + fi
37 + echo "tag=${tag}" >> "$GITHUB_OUTPUT"
38 + echo "Latest published release: ${tag}"
39 +
40 + # Install the PINNED newest tag. This is the path that 404s when a release ships without
41 + # assets. The no-arg `curl | bash` below is asset-aware and silently falls back to the
42 + # previous good release, so it would stay green even when the newest release is broken —
43 + # which is exactly why the previous canary never caught the recurring outage.
44 + - name: Install newest stable (pinned — fails on a release with missing assets)
45 + run: |
46 + set -euo pipefail
47 + curl -fsSL https://composio.dev/install | bash -s -- "${{ steps.resolve.outputs.tag }}"
48 echo "$HOME/.composio" >> "$GITHUB_PATH"
49
19 - - name: Verify installation
50 + - name: Verify pinned installation
51 run: |
52 set -euo pipefail
53 ls -la "$HOME/.composio" || true
54 which composio
55 composio --version
56
57 + # Secondary: the default no-arg flow most users run. Asset-aware and self-healing, so it
58 + # is a coverage net rather than the primary signal.
59 + - name: Install via default no-arg flow
60 + run: |
61 + set -euo pipefail
62 + rm -rf "$HOME/.composio"
63 + curl -fsSL https://composio.dev/install | bash
64 + "$HOME/.composio/composio" --version
65 +
66 - name: Send Slack Notification (Failure)
67 if: failure()
68 uses: slackapi/slack-github-action@45a88b9581bfab2566dc881e2cd66d334e621e2c # v3.0.3
package.json
+3 -2
@@ -20,8 +20,9 @@
20 "build:packages": "turbo build --filter=./ts/packages/**",
21 "cli:record": "turbo run record --filter=./ts/packages/cli",
22 "record": "turbo run record",
23 - "test": "pnpm run test:install-sh && turbo test --filter=./ts/packages/** --filter=!@e2e-tests/* && pnpm run test:examples",
23 + "test": "pnpm run test:install-sh && pnpm run test:release-workflow && turbo test --filter=./ts/packages/** --filter=!@e2e-tests/* && pnpm run test:examples",
24 "test:install-sh": "bash test/install-sh-release-resolution.test.sh",
25 + "test:release-workflow": "bun run test/release-workflow.test.ts",
26 "test:examples": "tsx ts/scripts/validate-examples.ts",
27 "test:e2e": "turbo test:e2e --filter='@e2e-tests/*'",
28 "test:e2e:node": "turbo test:e2e:node --filter='@e2e-tests/node-*'",
@@ -45,7 +46,7 @@
46 "prepublish": "pnpm run build:packages",
47 "changeset": "changeset",
48 "changeset:version": "changeset version",
48 - "changeset:release": "pnpm run build:packages && changeset publish",
49 + "changeset:release": "bash ts/scripts/changeset-release.sh",
50 "changeset:pre-enter": "changeset pre enter",
51 "changeset:pre-exit": "changeset pre exit",
52 "clean": "git clean -xdf .turbo node_modules ts/packages/**/.turbo ts/packages/**/node_modules ts/packages/**/dist",
test/release-workflow.test.ts new
+421
@@ -0,0 +1,421 @@
1 +#!/usr/bin/env node
2 +import { chmodSync, mkdtempSync, rmSync, writeFileSync, readFileSync } from 'node:fs';
3 +import { tmpdir } from 'node:os';
4 +import { join } from 'node:path';
5 +import { spawnSync } from 'node:child_process';
6 +
7 +const packageJson = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8'));
8 +const tsReleaseWorkflow = readFileSync(
9 + new URL('../.github/workflows/ts.release.yml', import.meta.url),
10 + 'utf8'
11 +);
12 +const releaseScriptUrl = new URL('../ts/scripts/changeset-release.sh', import.meta.url);
13 +const releaseScriptPath = releaseScriptUrl.pathname;
14 +const releaseScript = readFileSync(releaseScriptUrl, 'utf8');
15 +const buildCliWorkflow = readFileSync(
16 + new URL('../.github/workflows/build-cli-binaries.yml', import.meta.url),
17 + 'utf8'
18 +);
19 +const installHealthCheck = readFileSync(
20 + new URL('../.github/workflows/cli.install-health-check.yml', import.meta.url),
21 + 'utf8'
22 +);
23 +const resolveTargetScriptUrl = new URL(
24 + '../.github/scripts/cli-release/resolve-release-target.sh',
25 + import.meta.url
26 +);
27 +const resolveTargetScriptPath = resolveTargetScriptUrl.pathname;
28 +const resolveTargetScript = readFileSync(resolveTargetScriptUrl, 'utf8');
29 +const createDraftScript = readFileSync(
30 + new URL('../.github/scripts/cli-release/create-or-resume-draft.sh', import.meta.url),
31 + 'utf8'
32 +);
33 +const verifyAssetsScript = readFileSync(
34 + new URL('../.github/scripts/cli-release/verify-assets.sh', import.meta.url),
35 + 'utf8'
36 +);
37 +
38 +if (!tsReleaseWorkflow.includes('publish: pnpm changeset:release')) {
39 + throw new Error('ts.release.yml must use the repository-controlled changeset:release script');
40 +}
41 +
42 +if (packageJson.scripts?.['changeset:release'] !== 'bash ts/scripts/changeset-release.sh') {
43 + throw new Error('changeset:release must use the CLI-release filtering script');
44 +}
45 +
46 +if (!releaseScript.includes('pnpm changeset publish')) {
47 + throw new Error('release script must still publish non-CLI changeset packages');
48 +}
49 +
50 +if (!releaseScript.includes('New tag:[[:space:]]*@composio\\/cli@')) {
51 + throw new Error('release script must filter @composio/cli tag output before changesets/action creates GitHub releases');
52 +}
53 +
54 +// --- build-cli-binaries.yml: the CLI binary workflow is the sole, hardened release writer ---
55 +
56 +// A single failed platform must never publish a partial set: fail-fast: false makes the build
57 +// job `success` only when every matrix leg passes, gating the release job.
58 +if (!buildCliWorkflow.includes('fail-fast: false')) {
59 + throw new Error('build-cli-binaries.yml build matrix must set fail-fast: false');
60 +}
61 +
62 +// The release must be built as a draft and only flipped to published after verification, so no
63 +// anonymous consumer can observe a release before its assets are attached. The draft and verify
64 +// logic live in standalone scripts checked out from the workflow revision; the workflow must
65 +// invoke them in helper checkout → draft → verify → publish order.
66 +const helperCheckoutIdx = buildCliWorkflow.indexOf('name: Checkout workflow release helpers');
67 +const draftStepIdx = buildCliWorkflow.indexOf(
68 + 'bash "$RELEASE_HELPERS_DIR/create-or-resume-draft.sh"'
69 +);
70 +const verifyStepIdx = buildCliWorkflow.indexOf('bash "$RELEASE_HELPERS_DIR/verify-assets.sh"');
71 +const publishIdx = buildCliWorkflow.indexOf('gh release edit "$RELEASE_TAG" --draft=false');
72 +
73 +if (!buildCliWorkflow.includes("- '.github/scripts/cli-release/**'")) {
74 + throw new Error('build-cli-binaries.yml must trigger when CLI release helper scripts change');
75 +}
76 +if (helperCheckoutIdx === -1) {
77 + throw new Error('build-cli-binaries.yml must checkout workflow release helpers before publishing');
78 +}
79 +if (!buildCliWorkflow.includes('ref: ${{ github.workflow_sha }}')) {
80 + throw new Error('build-cli-binaries.yml must checkout release helpers from the workflow revision');
81 +}
82 +if (draftStepIdx === -1) {
83 + throw new Error('build-cli-binaries.yml must create the draft via create-or-resume-draft.sh');
84 +}
85 +if (verifyStepIdx === -1) {
86 + throw new Error('build-cli-binaries.yml must verify assets via verify-assets.sh');
87 +}
88 +if (publishIdx === -1) {
89 + throw new Error('build-cli-binaries.yml must publish by flipping the draft (gh release edit --draft=false)');
90 +}
91 +if (!(helperCheckoutIdx < draftStepIdx && draftStepIdx < verifyStepIdx && verifyStepIdx < publishIdx)) {
92 + throw new Error('build-cli-binaries.yml must order steps helper checkout → draft → verify → publish');
93 +}
94 +
95 +// The draft script must actually create a draft, and the verify gate must require fully-uploaded
96 +// assets (not merely present) — that distinction is what stops a release serving 404s.
97 +if (!createDraftScript.includes('--draft')) {
98 + throw new Error('create-or-resume-draft.sh must create the release as a draft (--draft)');
99 +}
100 +if (!verifyAssetsScript.includes('select(.state == "uploaded")')) {
101 + throw new Error('verify-assets.sh must require assets be fully uploaded (state == "uploaded")');
102 +}
103 +
104 +// Beta status must survive the draft→publish flip (regression: the old single create set
105 +// --prerelease at creation; the new flow must set it on the draft).
106 +if (!createDraftScript.includes('flags+=(--prerelease)')) {
107 + throw new Error('create-or-resume-draft.sh must preserve --prerelease on the draft for beta releases');
108 +}
109 +
110 +// Skills must be packaged BEFORE checksums are generated, so composio-skill.zip is hashed into
111 +// checksums.txt rather than shipping unverifiable.
112 +const packageSkillsIdx = buildCliWorkflow.indexOf('name: Package skill files');
113 +const generateChecksumsIdx = buildCliWorkflow.indexOf('name: Generate checksums');
114 +if (packageSkillsIdx === -1 || generateChecksumsIdx === -1) {
115 + throw new Error('build-cli-binaries.yml must package skills and generate checksums');
116 +}
117 +if (!(packageSkillsIdx < generateChecksumsIdx)) {
118 + throw new Error('build-cli-binaries.yml must package skills before generating checksums so the skill zip is checksummed');
119 +}
120 +
121 +// Per-tag concurrency prevents two runs clobbering the same release without serializing betas.
122 +if (!buildCliWorkflow.includes('group: cli-release-${{ needs.prepare.outputs.release_tag }}')) {
123 + throw new Error('build-cli-binaries.yml release job must use per-tag concurrency keyed on the release tag');
124 +}
125 +
126 +// Release-target resolution lives in a standalone, unit-tested script (see executable tests
127 +// below) rather than inline YAML bash, so the branching logic is reviewable and testable.
128 +if (!buildCliWorkflow.includes('bash .github/scripts/cli-release/resolve-release-target.sh')) {
129 + throw new Error('build-cli-binaries.yml prepare job must delegate to resolve-release-target.sh');
130 +}
131 +
132 +// The "latest stable" lookup must sort by numeric semver, not lexically: a lexical sort ranks
133 +// @composio/cli@0.2.9 above 0.2.10 and would regress beta versioning once a patch hits 2 digits.
134 +if (!resolveTargetScript.includes('map(tonumber)')) {
135 + throw new Error('resolve-release-target.sh must sort releases by numeric semver (map(tonumber)), not lexically');
136 +}
137 +if (!resolveTargetScript.includes('--exclude-drafts')) {
138 + throw new Error('resolve-release-target.sh must exclude draft stable releases from beta base selection');
139 +}
140 +
141 +// --- cli.install-health-check.yml: canary must exercise the failure-prone pinned path ---
142 +
143 +// The bare no-arg `curl | bash` is asset-aware and self-heals to the previous good release, so
144 +// the canary must additionally install the newest PUBLISHED release PINNED to actually catch a
145 +// release shipped with missing assets.
146 +//
147 +// It must resolve the newest *published* GitHub release (drafts excluded), NOT `npm view`: npm's
148 +// latest is bumped minutes before the binary workflow publishes the GitHub release, so pinning to
149 +// it would 404 during the healthy publish gap and false-page.
150 +if (installHealthCheck.includes('$(npm view')) {
151 + throw new Error('cli.install-health-check.yml must not pin to npm (races ahead of the GitHub release)');
152 +}
153 +if (!installHealthCheck.includes('gh release list')) {
154 + throw new Error('cli.install-health-check.yml must resolve the newest published release (drafts excluded)');
155 +}
156 +if (!installHealthCheck.includes('--repo "${{ github.repository }}"')) {
157 + throw new Error('cli.install-health-check.yml must pass repository context to gh release list');
158 +}
159 +if (!installHealthCheck.includes('--limit 1000')) {
160 + throw new Error('cli.install-health-check.yml must look beyond the gh release list default limit');
161 +}
162 +if (
163 + !installHealthCheck.includes('--exclude-drafts') ||
164 + !installHealthCheck.includes('--exclude-pre-releases')
165 +) {
166 + throw new Error('cli.install-health-check.yml must resolve the newest published release (drafts excluded)');
167 +}
168 +if (installHealthCheck.includes('.[0].tagName')) {
169 + throw new Error('cli.install-health-check.yml must not let jq null bypass the empty tag guard');
170 +}
171 +if (!installHealthCheck.includes("| sed -n '1p'")) {
172 + throw new Error('cli.install-health-check.yml must convert no matching release into empty output');
173 +}
174 +if (!installHealthCheck.includes('bash -s -- "${{ steps.resolve.outputs.tag }}"')) {
175 + throw new Error('cli.install-health-check.yml must install the resolved tag via the pinned path');
176 +}
177 +
178 +const fakeBin = mkdtempSync(join(tmpdir(), 'composio-release-test-'));
179 +try {
180 + const fakePnpmPath = join(fakeBin, 'pnpm');
181 + writeFileSync(
182 + fakePnpmPath,
183 + `#!/usr/bin/env bash
184 +set -euo pipefail
185 +case "$*" in
186 + "run build:packages")
187 + exit 0
188 + ;;
189 + "changeset publish")
190 + echo 'New tag: @composio/core@1.2.3'
191 + echo 'New tag: @composio/cli@9.9.9'
192 + echo 'release warning preserved' >&2
193 + exit 0
194 + ;;
195 + *)
196 + echo "unexpected pnpm invocation: $*" >&2
197 + exit 1
198 + ;;
199 +esac
200 +`
201 + );
202 + chmodSync(fakePnpmPath, 0o755);
203 +
204 + const result = spawnSync('bash', [releaseScriptPath], {
205 + encoding: 'utf8',
206 + env: { ...process.env, PATH: `${fakeBin}:${process.env.PATH}` },
207 + });
208 +
209 + if (result.status !== 0) {
210 + throw new Error(`release script failed unexpectedly\nstdout:\n${result.stdout}\nstderr:\n${result.stderr}`);
211 + }
212 +
213 + if (!result.stdout.includes('New tag: @composio/core@1.2.3')) {
214 + throw new Error('release script must preserve non-CLI changeset tags');
215 + }
216 +
217 + if (result.stdout.includes('@composio/cli@9.9.9')) {
218 + throw new Error('release script must hide @composio/cli tags from changesets/action');
219 + }
220 +
221 + if (!result.stderr.includes('release warning preserved')) {
222 + throw new Error('release script must preserve changeset publish stderr');
223 + }
224 +} finally {
225 + rmSync(fakeBin, { recursive: true, force: true });
226 +}
227 +
228 +// --- resolve-release-target.sh: executable tests for the release-target branching ---
229 +//
230 +// The script shells out to `gh` and `curl`; we stub both on PATH and feed fixtures, so these
231 +// exercise the real branching/version logic (not just substring presence). `jq`/`python3` stay
232 +// real because the script's correctness depends on them.
233 +
234 +const FAKE_GH = `#!/usr/bin/env bash
235 +set -euo pipefail
236 +if [[ "\${1:-}" == "release" && "\${2:-}" == "list" ]]; then
237 + shift 2
238 + jqexpr=""
239 + exclude_drafts=false
240 + limit=""
241 + while [[ \$# -gt 0 ]]; do
242 + if [[ "\$1" == "--exclude-drafts" ]]; then exclude_drafts=true; shift; continue; fi
243 + if [[ "\$1" == "--limit" ]]; then limit="\$2"; shift 2; continue; fi
244 + if [[ "\$1" == "--jq" ]]; then jqexpr="\$2"; shift 2; continue; fi
245 + shift
246 + done
247 + if [[ "\$exclude_drafts" != "true" ]]; then
248 + echo "release list must pass --exclude-drafts" >&2
249 + exit 1
250 + fi
251 + if [[ "\$limit" != "1000" ]]; then
252 + echo "release list must pass --limit 1000" >&2
253 + exit 1
254 + fi
255 + jq -r '[.[] | select(.isDraft != true)] | '"\$jqexpr" "\$GH_RELEASES_FIXTURE"
256 + exit 0
257 +fi
258 +if [[ "\${1:-}" == "release" && "\${2:-}" == "view" ]]; then
259 + # An existing release: echo its isDraft flag. Unset fixture ⇒ exit non-zero (release absent).
260 + if [[ -n "\${GH_VIEW_ISDRAFT:-}" ]]; then
261 + echo "\$GH_VIEW_ISDRAFT"
262 + exit 0
263 + fi
264 + exit 1
265 +fi
266 +echo "unexpected gh invocation: \$*" >&2
267 +exit 1
268 +`;
269 +
270 +const FAKE_CURL = `#!/usr/bin/env bash
271 +set -euo pipefail
272 +cat "\$CURL_FIXTURE"
273 +`;
274 +
275 +function parseOutputs(text) {
276 + const outputs = {};
277 + for (const line of text.split('\n')) {
278 + const idx = line.indexOf('=');
279 + if (idx === -1) continue;
280 + outputs[line.slice(0, idx)] = line.slice(idx + 1);
281 + }
282 + return outputs;
283 +}
284 +
285 +function runResolver({ env, releasesFixture, curlFixture, ghViewIsDraft }) {
286 + const fakeBin = mkdtempSync(join(tmpdir(), 'composio-fakebin-'));
287 + const workdir = mkdtempSync(join(tmpdir(), 'composio-resolver-'));
288 + try {
289 + for (const [name, body] of [['gh', FAKE_GH], ['curl', FAKE_CURL]]) {
290 + const p = join(fakeBin, name);
291 + writeFileSync(p, body);
292 + chmodSync(p, 0o755);
293 + }
294 +
295 + const outputPath = join(workdir, 'github_output');
296 + writeFileSync(outputPath, '');
297 +
298 + const fixtures = {};
299 + if (releasesFixture !== undefined) {
300 + const fixturePath = join(workdir, 'releases.json');
301 + writeFileSync(fixturePath, JSON.stringify(releasesFixture));
302 + fixtures.GH_RELEASES_FIXTURE = fixturePath;
303 + }
304 + if (curlFixture !== undefined) {
305 + const fixturePath = join(workdir, 'curl.json');
306 + writeFileSync(fixturePath, JSON.stringify(curlFixture));
307 + fixtures.CURL_FIXTURE = fixturePath;
308 + }
309 + if (ghViewIsDraft !== undefined) fixtures.GH_VIEW_ISDRAFT = ghViewIsDraft;
310 +
311 + const result = spawnSync('bash', [resolveTargetScriptPath], {
312 + encoding: 'utf8',
313 + env: {
314 + ...process.env,
315 + PATH: `${fakeBin}:${process.env.PATH}`,
316 + GITHUB_OUTPUT: outputPath,
317 + ...fixtures,
318 + ...env,
319 + },
320 + });
321 +
322 + const output = readFileSync(outputPath, 'utf8');
323 + return { ...result, output, outputs: parseOutputs(output) };
324 + } finally {
325 + rmSync(fakeBin, { recursive: true, force: true });
326 + rmSync(workdir, { recursive: true, force: true });
327 + }
328 +}
329 +
330 +// build-beta bumps off the NUMERIC-latest stable release. The fixture deliberately interleaves
331 +// 0.2.10 and 0.2.9: a lexical sort would pick 0.2.9 and resolve 0.2.10 here — regression lock.
332 +{
333 + const r = runResolver({
334 + env: {
335 + EVENT_NAME: 'workflow_dispatch',
336 + ACTION_INPUT: 'build-beta',
337 + REPOSITORY: 'ComposioHQ/composio',
338 + RUN_NUMBER: '42',
339 + COMMIT_SHA: 'deadbeef',
340 + },
341 + releasesFixture: [
342 + { tagName: '@composio/cli@0.2.2', isPrerelease: false },
343 + { tagName: '@composio/cli@0.2.10', isPrerelease: false },
344 + { tagName: '@composio/cli@0.2.9', isPrerelease: false },
345 + // Draft stables must not become the base for rolling betas.
346 + { tagName: '@composio/cli@0.2.11', isPrerelease: false, isDraft: true },
347 + { tagName: '@composio/cli@0.3.0-beta.1', isPrerelease: true },
348 + ],
349 + });
350 + if (r.status !== 0) {
351 + throw new Error(`resolve-release-target.sh build-beta failed\nstderr:\n${r.stderr}`);
352 + }
353 + if (r.outputs.release_version !== '0.2.11') {
354 + throw new Error(
355 + `build-beta must bump off the numeric-latest stable (0.2.10 → 0.2.11), got release_version=${r.outputs.release_version}. A lexical sort would regress.`
356 + );
357 + }
358 + if (r.outputs.release_tag !== '@composio/cli@0.2.11-beta.42') {
359 + throw new Error(`build-beta release_tag wrong: ${r.outputs.release_tag}`);
360 + }
361 + if (r.outputs.prerelease !== 'true' || r.outputs.make_latest !== 'false') {
362 + throw new Error('build-beta must emit prerelease=true and make_latest=false');
363 + }
364 +}
365 +
366 +// promote-stable must REFUSE a tag that is already published (isDraft=false) and emit nothing.
367 +{
368 + const r = runResolver({
369 + env: {
370 + EVENT_NAME: 'workflow_dispatch',
371 + ACTION_INPUT: 'promote-stable',
372 + BETA_TAG_INPUT: '@composio/cli@0.3.0-beta.5',
373 + GITHUB_TOKEN: 'fake-token',
374 + REPOSITORY: 'ComposioHQ/composio',
375 + RUN_NUMBER: '1',
376 + COMMIT_SHA: 'unused',
377 + },
378 + curlFixture: { prerelease: true, target_commitish: 'abc123' },
379 + ghViewIsDraft: 'false',
380 + });
381 + if (r.status === 0) {
382 + throw new Error('promote-stable must refuse an already-published stable tag');
383 + }
384 + if (!r.stderr.includes('already published')) {
385 + throw new Error(`promote-stable refusal must explain itself\nstderr:\n${r.stderr}`);
386 + }
387 + if (r.output.trim() !== '') {
388 + throw new Error('a refused promotion must not emit release outputs');
389 + }
390 +}
391 +
392 +// promote-stable happy path: no existing release ⇒ emit a stable target off the beta's commitish.
393 +{
394 + const r = runResolver({
395 + env: {
396 + EVENT_NAME: 'workflow_dispatch',
397 + ACTION_INPUT: 'promote-stable',
398 + BETA_TAG_INPUT: '@composio/cli@0.3.0-beta.5',
399 + GITHUB_TOKEN: 'fake-token',
400 + REPOSITORY: 'ComposioHQ/composio',
401 + RUN_NUMBER: '1',
402 + COMMIT_SHA: 'unused',
403 + },
404 + curlFixture: { prerelease: true, target_commitish: 'abc123' },
405 + // ghViewIsDraft unset ⇒ `gh release view` exits non-zero ⇒ no existing release to refuse.
406 + });
407 + if (r.status !== 0) {
408 + throw new Error(`resolve-release-target.sh promote-stable failed\nstderr:\n${r.stderr}`);
409 + }
410 + if (r.outputs.release_tag !== '@composio/cli@0.3.0' || r.outputs.release_version !== '0.3.0') {
411 + throw new Error(`promote-stable must strip the -beta suffix, got ${r.outputs.release_tag}`);
412 + }
413 + if (r.outputs.prerelease !== 'false' || r.outputs.make_latest !== 'true') {
414 + throw new Error('promote-stable must emit prerelease=false and make_latest=true');
415 + }
416 + if (r.outputs.checkout_ref !== 'abc123') {
417 + throw new Error(`promote-stable must check out the beta's target_commitish, got ${r.outputs.checkout_ref}`);
418 + }
419 +}
420 +
421 +console.log('release workflow test passed');
ts/packages/cli/AGENTS.md
+1 -1
@@ -185,7 +185,7 @@ Also triggerable from any branch via `workflow_dispatch` → `build-beta`. Users
185 2. Merge into `next`
186 3. Changeset bot opens "Release: update version" PR bumping `package.json`
187 4. Merge that PR → push to `next` detects version change → builds **stable** release (`@composio/cli@X.Y.Z`, marked `latest`)
188 -5. `ts.release.yml` also publishes to npm
188 +5. `ts.release.yml` publishes via the repository-controlled `changeset:release` script, which filters `@composio/cli` tag output so only `build-cli-binaries.yml` can create CLI GitHub Releases
189
190 Promote an existing beta to stable via `workflow_dispatch` → `promote-stable` with the beta tag (e.g. `@composio/cli@0.2.20-beta.42`).
191
ts/scripts/changeset-release.sh new
+25
@@ -0,0 +1,25 @@
1 +#!/usr/bin/env bash
2 +set -euo pipefail
3 +
4 +# changesets/action infers which GitHub tags/releases to push from `New tag:`
5 +# lines printed by `changeset publish`. The CLI binary workflow owns
6 +# @composio/cli GitHub Releases because those releases must include platform
7 +# binary assets. Let changesets publish/tag every other package, but hide the
8 +# private CLI tag from changesets/action so ts.release.yml cannot create an
9 +# empty @composio/cli GitHub Release.
10 +
11 +stdout_file=$(mktemp)
12 +stderr_file=$(mktemp)
13 +trap 'rm -f "$stdout_file" "$stderr_file"' EXIT
14 +
15 +pnpm run build:packages
16 +
17 +set +e
18 +pnpm changeset publish >"$stdout_file" 2>"$stderr_file"
19 +status=$?
20 +set -e
21 +
22 +sed '/New tag:[[:space:]]*@composio\/cli@/d' "$stdout_file"
23 +cat "$stderr_file" >&2
24 +
25 +exit "$status"