Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
TypeScript agentic-aiagentsaiai-agentsaiagentsdeveloper-toolsfunction-callinggpt-4javascriptjsllmllmopsmcppythonremote-mcp-serverssetypescript
fix(ci): make CLI releases reliably ship binary assets (#3515)
Alberto Schiabel08f70721100b
diff --git a/.github/scripts/cli-release/create-or-resume-draft.sh b/.github/scripts/cli-release/create-or-resume-draft.shnew file mode 100755index 000000000..2718460b7--- /dev/null+++ b/.github/scripts/cli-release/create-or-resume-draft.sh@@ -0,0 +1,45 @@+#!/usr/bin/env bash+#+# Create the GitHub Release as a DRAFT with every asset attached, or resume an existing+# draft by re-uploading (--clobber). Refuse to mutate a tag that is already published.+#+# Drafts fire no `release: published` event and are excluded from `/releases/latest`, so no+# anonymous consumer (install.sh, Homebrew, the redirect) can observe a release before its+# assets are attached and verified. The release is only flipped to published by a later step.+#+# Inputs (env): RELEASE_TAG, RELEASE_NAME, CHECKOUT_REF, PRERELEASE, GH_TOKEN+# BINARIES_DIR (optional, defaults to the CLI dist dir)+set -euo pipefail++binaries_dir="${BINARIES_DIR:-ts/packages/cli/dist/binaries}"++flags=(+ --draft+ --title "$RELEASE_NAME"+ --target "$CHECKOUT_REF"+ --generate-notes+)+# Preserve prerelease status on the draft so betas stay prereleases once published.+if [[ "$PRERELEASE" == "true" ]]; then+ flags+=(--prerelease)+fi++# Idempotent for re-runs of a not-yet-published release: reuse an existing draft and clobber+# its assets. Refuse to mutate a tag that is already published.+if gh release view "$RELEASE_TAG" --json isDraft --jq '.isDraft' 2>/dev/null | grep -qx true; then+ echo "Draft $RELEASE_TAG already exists — re-uploading assets with --clobber"+ gh release upload "$RELEASE_TAG" \+ "$binaries_dir"/*.zip \+ "$binaries_dir/checksums.txt" --clobber+elif gh release view "$RELEASE_TAG" >/dev/null 2>&1; then+ # A red ❌ here is EXPECTED, not a bug, when two runs target the same tag (e.g. two quick CLI+ # version bumps): per-tag `concurrency` serializes them, the first publishes, and the second —+ # finding the tag already published — fails loudly here rather than silently clobbering a live+ # release. If you hit this, confirm the tag is genuinely published before re-running.+ echo "::error::Release $RELEASE_TAG is already published — refusing to mutate it. Investigate the publish path."+ exit 1+else+ gh release create "$RELEASE_TAG" "${flags[@]}" \+ "$binaries_dir"/*.zip \+ "$binaries_dir/checksums.txt"+fidiff --git a/.github/scripts/cli-release/resolve-release-target.sh b/.github/scripts/cli-release/resolve-release-target.shnew file mode 100755index 000000000..f51e12401--- /dev/null+++ b/.github/scripts/cli-release/resolve-release-target.sh@@ -0,0 +1,148 @@+#!/usr/bin/env bash+#+# Resolve the CLI release target and write its metadata to $GITHUB_OUTPUT for the+# build/release jobs of build-cli-binaries.yml. Three modes:+#+# - push to `next` with a ts/packages/cli/package.json version bump → stable release+# - push to `next` without a bump, or workflow_dispatch build-beta → rolling beta+# - workflow_dispatch promote-stable <beta tag> → stable promotion+#+# Inputs (env): EVENT_NAME, ACTION_INPUT, BETA_TAG_INPUT, GITHUB_TOKEN,+# REPOSITORY, RUN_NUMBER, COMMIT_SHA+# Output: key=value lines appended to $GITHUB_OUTPUT+set -euo pipefail++# Latest STABLE @composio/cli release tag, by true semver order (empty if none).+#+# A lexical sort is wrong here: "@composio/[email protected]" sorts AFTER "0.2.10", so once a+# patch reaches double digits `last` would pick the older release and beta versions+# would regress. Parse the version triplet to numbers and sort numerically instead.+latest_stable_tag() {+ gh release list \+ --repo "$REPOSITORY" \+ --exclude-drafts \+ --limit 1000 \+ --json tagName,isPrerelease \+ --jq '[.[]+ | select(.tagName | startswith("@composio/cli@"))+ | select(.isPrerelease == false)]+ | sort_by(.tagName | ltrimstr("@composio/cli@") | split(".") | map(tonumber))+ | last | .tagName // empty'+}++# Echo the next "<major>.<minor>.<patch+1>" off the latest stable release, falling+# back to the working-tree package.json when no stable release exists yet.+next_beta_base_version() {+ local latest current+ latest=$(latest_stable_tag)+ if [[ -z "$latest" ]]; then+ echo "No stable @composio/cli release found, falling back to package.json" >&2+ current=$(node -p "require('./ts/packages/cli/package.json').version")+ else+ current=${latest#@composio/cli@}+ fi++ local major minor patch+ IFS='.' read -r major minor patch <<<"$current"+ echo "${major}.${minor}.$((patch + 1))"+}++emit_beta_target() {+ local next_version release_tag+ next_version=$(next_beta_base_version)+ release_tag="@composio/cli@${next_version}-beta.${RUN_NUMBER}"+ {+ echo "checkout_ref=${COMMIT_SHA}"+ echo "release_name=CLI Beta ${release_tag}"+ echo "release_tag=${release_tag}"+ echo "release_version=${next_version}"+ echo "prerelease=true"+ echo "make_latest=false"+ } >>"$GITHUB_OUTPUT"+}++emit_stable_target() {+ local release_tag=$1 release_version=$2 checkout_ref=$3+ {+ echo "checkout_ref=${checkout_ref}"+ echo "release_name=CLI ${release_tag}"+ echo "release_tag=${release_tag}"+ echo "release_version=${release_version}"+ echo "prerelease=false"+ echo "make_latest=true"+ } >>"$GITHUB_OUTPUT"+}++# ── Push to next ──+if [[ "$EVENT_NAME" == "push" ]]; then+ current_version=$(node -p "require('./ts/packages/cli/package.json').version")+ 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 "")++ # A version bump on push is a stable release; anything else is a rolling beta.+ if [[ -n "$previous_version" && "$current_version" != "$previous_version" ]]; then+ emit_stable_target "@composio/cli@${current_version}" "$current_version" "$COMMIT_SHA"+ else+ emit_beta_target+ fi+ exit 0+fi++# ── workflow_dispatch: build-beta ──+if [[ "$EVENT_NAME" == "workflow_dispatch" && "$ACTION_INPUT" == "build-beta" ]]; then+ emit_beta_target+ exit 0+fi++# ── workflow_dispatch: promote-stable ──+if [[ "$ACTION_INPUT" != "promote-stable" ]]; then+ echo "Unknown action: $ACTION_INPUT" >&2+ exit 1+fi++if [[ -z "$BETA_TAG_INPUT" ]]; then+ echo "beta_tag input is required for promote-stable" >&2+ exit 1+fi++encoded_beta_tag=$(python3 -c 'import os, urllib.parse; print(urllib.parse.quote(os.environ["BETA_TAG_INPUT"], safe=""))')++release_json=$(curl -fsSL \+ -H "Authorization: Bearer ${GITHUB_TOKEN}" \+ -H "Accept: application/vnd.github+json" \+ "https://api.github.com/repos/${REPOSITORY}/releases/tags/${encoded_beta_tag}")++is_prerelease=$(jq -r '.prerelease' <<<"$release_json")+if [[ "$is_prerelease" != "true" ]]; then+ echo "Release ${BETA_TAG_INPUT} is not a beta prerelease" >&2+ exit 1+fi++if [[ ! "$BETA_TAG_INPUT" =~ ^@composio/cli@([0-9]+\.[0-9]+\.[0-9]+)-beta\.[0-9]+$ ]]; then+ echo "Beta tag must match @composio/cli@<version>-beta.<number>" >&2+ exit 1+fi++stable_version="${BASH_REMATCH[1]}"+stable_tag="@composio/cli@${stable_version}"++# Refuse to re-promote an already-PUBLISHED stable release, but allow resuming an+# existing DRAFT (a prior promote run that built assets but did not publish). The+# REST `/releases/tags/{tag}` endpoint returns 404 for drafts, so use `gh release view`+# — it resolves drafts by name and exposes `isDraft`.+if isdraft=$(gh release view "$stable_tag" --json isDraft --jq '.isDraft' 2>/dev/null); then+ if [[ "$isdraft" == "true" ]]; then+ echo "Stable release ${stable_tag} exists as a draft — resuming (assets will be re-uploaded)."+ else+ echo "Stable release ${stable_tag} is already published" >&2+ exit 1+ fi+fi++target_commitish=$(jq -r '.target_commitish' <<<"$release_json")+if [[ -z "$target_commitish" || "$target_commitish" == "null" ]]; then+ echo "Beta release ${BETA_TAG_INPUT} does not expose target_commitish" >&2+ exit 1+fi++emit_stable_target "$stable_tag" "$stable_version" "$target_commitish"diff --git a/.github/scripts/cli-release/verify-assets.sh b/.github/scripts/cli-release/verify-assets.shnew file mode 100755index 000000000..da0cb76ff--- /dev/null+++ b/.github/scripts/cli-release/verify-assets.sh@@ -0,0 +1,48 @@+#!/usr/bin/env bash+#+# Loud failure gate: assert the full canonical asset set is attached to the release AND fully+# uploaded (state == "uploaded"). An asset can appear in the listing while still processing,+# which is exactly how a release ends up serving 404s — so require state == "uploaded", with a+# bounded retry while uploads settle.+#+# Inputs (env): RELEASE_TAG, GH_TOKEN+# VERIFY_ATTEMPTS / VERIFY_SLEEP_SECONDS (optional, for fast tests)+set -euo pipefail++# Keep this list in lock-step with the build matrix in build-cli-binaries.yml (4 platforms)+# plus the skill bundle and checksums. Adding a platform to the matrix must extend this list.+expected=(+ composio-linux-x64.zip+ composio-linux-aarch64.zip+ composio-darwin-x64.zip+ composio-darwin-aarch64.zip+ composio-skill.zip+ checksums.txt+)++attempts="${VERIFY_ATTEMPTS:-10}"+sleep_seconds="${VERIFY_SLEEP_SECONDS:-15}"++for attempt in $(seq 1 "$attempts"); do+ # Single snapshot per attempt — querying names and state separately would open a+ # time-of-check/time-of-use gap in the very gate meant to close one.+ payload=$(gh release view "$RELEASE_TAG" --json assets)+ mapfile -t uploaded < <(jq -r '.assets[] | select(.state == "uploaded") | .name' <<<"$payload" | sort)++ missing=()+ for want in "${expected[@]}"; do+ printf '%s\n' "${uploaded[@]}" | grep -qxF "$want" || missing+=("$want")+ done++ if [[ ${#missing[@]} -eq 0 ]]; then+ echo "✅ All ${#expected[@]} expected assets present and uploaded."+ exit 0+ fi++ echo "Attempt ${attempt}/${attempts} — missing or not-yet-uploaded: ${missing[*]}"+ if [[ "$attempt" -eq "$attempts" ]]; then+ echo "::error::Release $RELEASE_TAG is incomplete — missing or not uploaded: ${missing[*]}"+ exit 1+ fi+ sleep "$sleep_seconds"+donediff --git a/.github/workflows/build-cli-binaries.yml b/.github/workflows/build-cli-binaries.ymlindex 6119fc12a..ad0a01389 100644--- a/.github/workflows/build-cli-binaries.yml+++ b/.github/workflows/build-cli-binaries.yml@@ -7,6 +7,7 @@ on:- 'ts/packages/cli/**'- 'ts/packages/cli-local-tools/**'- '.github/actions/setup-node-pnpm-bun/action.yml'+ - '.github/scripts/cli-release/**'- '.github/workflows/build-cli-binaries.yml'- 'mise.toml'- 'mise.lock'@@ -23,8 +24,11 @@ on:description: 'Existing beta release tag to promote (only for promote-stable, e.g. @composio/[email protected])'required: false+# Least privilege by default: only the release job creates/edits releases and uploads assets.+# `prepare` reads releases (gh release list) and `build` uploads workflow artifacts — both work+# with read access. The release job opts up to `contents: write` for itself.permissions:- contents: write+ contents: readjobs:prepare:@@ -54,150 +58,7 @@ jobs:REPOSITORY: ${{ github.repository }}RUN_NUMBER: ${{ github.run_number }}COMMIT_SHA: ${{ github.sha }}- run: |- set -euo pipefail-- # ── Push to next ──- if [[ "$EVENT_NAME" == "push" ]]; then- # Check if ts/packages/cli/package.json version changed → stable release- current_version=$(node -p "require('./ts/packages/cli/package.json').version")- 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 "")-- if [[ -n "$previous_version" && "$current_version" != "$previous_version" ]]; then- release_tag="@composio/cli@${current_version}"- release_name="CLI ${release_tag}"- {- echo "checkout_ref=${COMMIT_SHA}"- echo "release_name=${release_name}"- echo "release_tag=${release_tag}"- echo "release_version=${current_version}"- echo "prerelease=false"- echo "make_latest=true"- } >> "$GITHUB_OUTPUT"- exit 0- fi-- # Otherwise → beta release- # Find the latest stable CLI release to determine next version- latest_stable_tag=$(gh release list \- --repo "$REPOSITORY" \- --json tagName,isPrerelease \- --jq '[.[] | select(.tagName | startswith("@composio/cli@")) | select(.isPrerelease == false)] | sort_by(.tagName) | last | .tagName // empty')-- if [[ -z "$latest_stable_tag" ]]; then- echo "No stable @composio/cli release found, falling back to package.json"- current_version=$(node -p "require('./ts/packages/cli/package.json').version")- else- current_version=$(echo "$latest_stable_tag" | sed 's/@composio\/cli@//')- fi-- # Bump patch version for the beta- IFS='.' read -r major minor patch <<< "$current_version"- next_version="${major}.${minor}.$((patch + 1))"-- release_tag="@composio/cli@${next_version}-beta.${RUN_NUMBER}"- release_name="CLI Beta ${release_tag}"- {- echo "checkout_ref=${COMMIT_SHA}"- echo "release_name=${release_name}"- echo "release_tag=${release_tag}"- echo "release_version=${next_version}"- echo "prerelease=true"- echo "make_latest=false"- } >> "$GITHUB_OUTPUT"- exit 0- fi-- # ── workflow_dispatch: build-beta ──- if [[ "$EVENT_NAME" == "workflow_dispatch" ]] && [[ "$ACTION_INPUT" == "build-beta" ]]; then- latest_stable_tag=$(gh release list \- --repo "$REPOSITORY" \- --json tagName,isPrerelease \- --jq '[.[] | select(.tagName | startswith("@composio/cli@")) | select(.isPrerelease == false)] | sort_by(.tagName) | last | .tagName // empty')-- if [[ -z "$latest_stable_tag" ]]; then- current_version=$(node -p "require('./ts/packages/cli/package.json').version")- else- current_version=$(echo "$latest_stable_tag" | sed 's/@composio\/cli@//')- fi-- IFS='.' read -r major minor patch <<< "$current_version"- next_version="${major}.${minor}.$((patch + 1))"-- release_tag="@composio/cli@${next_version}-beta.${RUN_NUMBER}"- release_name="CLI Beta ${release_tag}"- {- echo "checkout_ref=${COMMIT_SHA}"- echo "release_name=${release_name}"- echo "release_tag=${release_tag}"- echo "release_version=${next_version}"- echo "prerelease=true"- echo "make_latest=false"- } >> "$GITHUB_OUTPUT"- exit 0- fi-- # ── Promote stable (workflow_dispatch with promote-stable) ──- if [[ "$ACTION_INPUT" != "promote-stable" ]]; then- echo "Unknown action: $ACTION_INPUT"- exit 1- fi-- if [[ -z "$BETA_TAG_INPUT" ]]; then- echo "beta_tag input is required for promote-stable"- exit 1- fi-- encoded_beta_tag=$(python3 -c 'import os, urllib.parse; print(urllib.parse.quote(os.environ["BETA_TAG_INPUT"], safe=""))')-- release_json=$(curl -fsSL \- -H "Authorization: Bearer ${GITHUB_TOKEN}" \- -H "Accept: application/vnd.github+json" \- "https://api.github.com/repos/${REPOSITORY}/releases/tags/${encoded_beta_tag}")-- is_prerelease=$(jq -r '.prerelease' <<<"$release_json")- if [[ "$is_prerelease" != "true" ]]; then- echo "Release ${BETA_TAG_INPUT} is not a beta prerelease"- exit 1- fi-- if [[ ! "$BETA_TAG_INPUT" =~ ^@composio/cli@([0-9]+\.[0-9]+\.[0-9]+)-beta\.[0-9]+$ ]]; then- echo "Beta tag must match @composio/cli@<version>-beta.<number>"- exit 1- fi-- stable_version="${BASH_REMATCH[1]}"- stable_tag="@composio/cli@${stable_version}"- export stable_tag-- stable_status=$(curl -sS -o /tmp/stable-release.json -w "%{http_code}" \- -H "Authorization: Bearer ${GITHUB_TOKEN}" \- -H "Accept: application/vnd.github+json" \- "https://api.github.com/repos/${REPOSITORY}/releases/tags/$(python3 -c 'import os, urllib.parse; print(urllib.parse.quote(os.environ["stable_tag"], safe=""))')")- if [[ "$stable_status" == "200" ]]; then- echo "Stable release ${stable_tag} already exists"- exit 1- fi- if [[ "$stable_status" != "404" ]]; then- echo "Unexpected response while checking stable release ${stable_tag}: HTTP ${stable_status}"- cat /tmp/stable-release.json- exit 1- fi-- target_commitish=$(jq -r '.target_commitish' <<<"$release_json")- if [[ -z "$target_commitish" || "$target_commitish" == "null" ]]; then- echo "Beta release ${BETA_TAG_INPUT} does not expose target_commitish"- exit 1- fi-- {- echo "checkout_ref=${target_commitish}"- echo "release_name=CLI ${stable_tag}"- echo "release_tag=${stable_tag}"- echo "release_version=${stable_version}"- echo "prerelease=false"- echo "make_latest=true"- } >> "$GITHUB_OUTPUT"+ run: bash .github/scripts/cli-release/resolve-release-target.shbuild:name: Build ${{ matrix.artifact }}@@ -205,6 +66,11 @@ jobs:if: needs.prepare.result == 'success'runs-on: ${{ matrix.runner }}strategy:+ # Never publish a partial platform set: with fail-fast disabled, the build job's+ # result is `success` only when EVERY matrix leg passes, so a single failure makes+ # `needs.build.result != 'success'` and the release job is skipped. It also surfaces+ # all platform failures at once instead of cancelling siblings on the first error.+ fail-fast: falsematrix:include:- target: bun-linux-x64@@ -305,10 +171,30 @@ jobs:retention-days: 7release:- name: Create Release+ name: Release (draft → verify → publish)needs: [prepare, build]runs-on: ubuntu-latest+ permissions:+ contents: write # create/edit the GitHub Release and upload assets+ # fail-fast: false on the build matrix ⇒ this is `success` only if ALL platforms built,+ # so a partial set can never reach the release path.if: needs.build.result == 'success'+ # Serialize runs that target the SAME release tag (e.g. two quick pushes, or a re-run+ # racing the original) so they cannot interleave uploads. Keyed on the resolved tag so+ # unrelated beta builds are not serialized behind each other. Job-level concurrency may+ # read `needs.*` outputs (workflow-level cannot). The serialized loser fails loudly at the+ # "already published" guard in create-or-resume-draft.sh — that red ❌ is by design.+ concurrency:+ group: cli-release-${{ needs.prepare.outputs.release_tag }}+ cancel-in-progress: false+ env:+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}+ RELEASE_TAG: ${{ needs.prepare.outputs.release_tag }}+ RELEASE_NAME: ${{ needs.prepare.outputs.release_name }}+ PRERELEASE: ${{ needs.prepare.outputs.prerelease }}+ MAKE_LATEST: ${{ needs.prepare.outputs.make_latest }}+ CHECKOUT_REF: ${{ needs.prepare.outputs.checkout_ref }}+ RELEASE_HELPERS_DIR: ${{ github.workspace }}/.release-workflow/.github/scripts/cli-releasesteps:- name: Checkout@@ -328,13 +214,9 @@ jobs:path: ts/packages/cli/dist/binariesmerge-multiple: true- - name: Generate checksums- working-directory: ts/packages/cli- run: bun run ./scripts/generate-checksums.ts-- - name: Display checksums- run: cat ts/packages/cli/dist/binaries/checksums.txt-+ # Package skills BEFORE generating checksums so composio-skill.zip is included in+ # checksums.txt alongside the platform binaries (generate-checksums hashes every .zip+ # in dist/binaries).- name: Package skill filesworking-directory: ts/packages/clienv:@@ -349,33 +231,40 @@ jobs:pnpm run build:skills -- --channel "$channel" --output-dir ./dist/skillscd dist/skills && zip -r ../binaries/composio-skill.zip composio-cli/- - name: Create GitHub Release- env:- GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}- RELEASE_TAG: ${{ needs.prepare.outputs.release_tag }}- RELEASE_NAME: ${{ needs.prepare.outputs.release_name }}- PRERELEASE: ${{ needs.prepare.outputs.prerelease }}- MAKE_LATEST: ${{ needs.prepare.outputs.make_latest }}- CHECKOUT_REF: ${{ needs.prepare.outputs.checkout_ref }}- run: |- set -euo pipefail-- flags=(- --title "$RELEASE_NAME"- --target "$CHECKOUT_REF"- --generate-notes- )+ - name: Generate checksums+ working-directory: ts/packages/cli+ run: bun run ./scripts/generate-checksums.ts- if [[ "$PRERELEASE" == "true" ]]; then- flags+=(--prerelease)- flags+=(--latest=false)- else- flags+=(--latest)- fi+ - name: Display checksums+ run: cat ts/packages/cli/dist/binaries/checksums.txt- gh release create "$RELEASE_TAG" "${flags[@]}" \- ts/packages/cli/dist/binaries/*.zip \- ts/packages/cli/dist/binaries/checksums.txt+ - name: Checkout workflow release helpers+ uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3+ with:+ ref: ${{ github.workflow_sha }}+ path: .release-workflow+ sparse-checkout: |+ .github/scripts/cli-release+ sparse-checkout-cone-mode: false++ # Build the release as a DRAFT first. Drafts fire no `release: published` event and are+ # excluded from the `/releases/latest` redirect, so no anonymous consumer (install.sh,+ # Homebrew, the redirect) can ever observe a release before its assets are attached and+ # verified. The release is only flipped to published as the final step below.+ - name: Create draft release with all assets+ run: bash "$RELEASE_HELPERS_DIR/create-or-resume-draft.sh"++ # Loud failure gate: assert the full canonical asset set is attached AND fully uploaded.+ # An asset can appear in the list while still processing (`state != "uploaded"`), which is+ # exactly how a release ends up serving 404s, so we require state == "uploaded".+ - name: Verify all release assets are present and uploaded+ run: bash "$RELEASE_HELPERS_DIR/verify-assets.sh"++ # Publishing is the ONLY step that exposes the release. Do not edit the body here: a known+ # GitHub PATCH race drops body changes made in the same call as the draft flip, and the+ # notes were already generated at draft creation. Prerelease status was set on the draft.+ - name: Publish release (flip draft → published)+ run: gh release edit "$RELEASE_TAG" --draft=false --latest="$MAKE_LATEST"test-installation:name: Test Installationdiff --git a/.github/workflows/cli.install-health-check.yml b/.github/workflows/cli.install-health-check.ymlindex 69b14f4ee..c93655cc1 100644--- a/.github/workflows/cli.install-health-check.yml+++ b/.github/workflows/cli.install-health-check.yml@@ -5,24 +5,64 @@ on:- cron: '0 * * * *'workflow_dispatch:+permissions:+ contents: read # gh release list reads the published releases+jobs:health-check:name: Test CLI Installationruns-on: ubuntu-latest+ env:+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}steps:- - name: Run install script+ # Resolve the newest PUBLISHED stable @composio/cli release — exactly what install.sh and+ # the /releases/latest redirect (Homebrew, humans) resolve and download from.+ #+ # Deliberately NOT `npm view @composio/cli version`: npm's latest dist-tag is bumped by+ # changesets minutes before the binary workflow finishes the draft build and publishes the+ # GitHub release. Pinning to the npm version would 404 during that healthy publish gap and+ # false-page hourly. Drafts are excluded here, so this only ever resolves a fully-published+ # release — the in-flight one stays invisible until its assets are verified and attached.+ - name: Resolve newest published release+ id: resolverun: |set -euo pipefail- curl -fsSL https://composio.dev/install | bash+ tag=$(gh release list --repo "${{ github.repository }}" --limit 1000 --exclude-drafts --exclude-pre-releases --json tagName \+ --jq '.[] | select(.tagName | startswith("@composio/cli@")) | .tagName' \+ | sed -n '1p')+ if [[ -z "$tag" ]]; then+ echo "::error::No published @composio/cli release found"+ exit 1+ fi+ echo "tag=${tag}" >> "$GITHUB_OUTPUT"+ echo "Latest published release: ${tag}"++ # Install the PINNED newest tag. This is the path that 404s when a release ships without+ # assets. The no-arg `curl | bash` below is asset-aware and silently falls back to the+ # previous good release, so it would stay green even when the newest release is broken —+ # which is exactly why the previous canary never caught the recurring outage.+ - name: Install newest stable (pinned — fails on a release with missing assets)+ run: |+ set -euo pipefail+ curl -fsSL https://composio.dev/install | bash -s -- "${{ steps.resolve.outputs.tag }}"echo "$HOME/.composio" >> "$GITHUB_PATH"- - name: Verify installation+ - name: Verify pinned installationrun: |set -euo pipefaills -la "$HOME/.composio" || truewhich composiocomposio --version+ # Secondary: the default no-arg flow most users run. Asset-aware and self-healing, so it+ # is a coverage net rather than the primary signal.+ - name: Install via default no-arg flow+ run: |+ set -euo pipefail+ rm -rf "$HOME/.composio"+ curl -fsSL https://composio.dev/install | bash+ "$HOME/.composio/composio" --version+- name: Send Slack Notification (Failure)if: failure()uses: slackapi/slack-github-action@45a88b9581bfab2566dc881e2cd66d334e621e2c # v3.0.3diff --git a/package.json b/package.jsonindex 8b637c1dc..a2ca9b928 100644--- a/package.json+++ b/package.json@@ -20,8 +20,9 @@"build:packages": "turbo build --filter=./ts/packages/**","cli:record": "turbo run record --filter=./ts/packages/cli","record": "turbo run record",- "test": "pnpm run test:install-sh && turbo test --filter=./ts/packages/** --filter=!@e2e-tests/* && pnpm run test:examples",+ "test": "pnpm run test:install-sh && pnpm run test:release-workflow && turbo test --filter=./ts/packages/** --filter=!@e2e-tests/* && pnpm run test:examples","test:install-sh": "bash test/install-sh-release-resolution.test.sh",+ "test:release-workflow": "bun run test/release-workflow.test.ts","test:examples": "tsx ts/scripts/validate-examples.ts","test:e2e": "turbo test:e2e --filter='@e2e-tests/*'","test:e2e:node": "turbo test:e2e:node --filter='@e2e-tests/node-*'",@@ -45,7 +46,7 @@"prepublish": "pnpm run build:packages","changeset": "changeset","changeset:version": "changeset version",- "changeset:release": "pnpm run build:packages && changeset publish",+ "changeset:release": "bash ts/scripts/changeset-release.sh","changeset:pre-enter": "changeset pre enter","changeset:pre-exit": "changeset pre exit","clean": "git clean -xdf .turbo node_modules ts/packages/**/.turbo ts/packages/**/node_modules ts/packages/**/dist",diff --git a/test/release-workflow.test.ts b/test/release-workflow.test.tsnew file mode 100644index 000000000..335e0998f--- /dev/null+++ b/test/release-workflow.test.ts@@ -0,0 +1,421 @@+#!/usr/bin/env node+import { chmodSync, mkdtempSync, rmSync, writeFileSync, readFileSync } from 'node:fs';+import { tmpdir } from 'node:os';+import { join } from 'node:path';+import { spawnSync } from 'node:child_process';++const packageJson = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8'));+const tsReleaseWorkflow = readFileSync(+ new URL('../.github/workflows/ts.release.yml', import.meta.url),+ 'utf8'+);+const releaseScriptUrl = new URL('../ts/scripts/changeset-release.sh', import.meta.url);+const releaseScriptPath = releaseScriptUrl.pathname;+const releaseScript = readFileSync(releaseScriptUrl, 'utf8');+const buildCliWorkflow = readFileSync(+ new URL('../.github/workflows/build-cli-binaries.yml', import.meta.url),+ 'utf8'+);+const installHealthCheck = readFileSync(+ new URL('../.github/workflows/cli.install-health-check.yml', import.meta.url),+ 'utf8'+);+const resolveTargetScriptUrl = new URL(+ '../.github/scripts/cli-release/resolve-release-target.sh',+ import.meta.url+);+const resolveTargetScriptPath = resolveTargetScriptUrl.pathname;+const resolveTargetScript = readFileSync(resolveTargetScriptUrl, 'utf8');+const createDraftScript = readFileSync(+ new URL('../.github/scripts/cli-release/create-or-resume-draft.sh', import.meta.url),+ 'utf8'+);+const verifyAssetsScript = readFileSync(+ new URL('../.github/scripts/cli-release/verify-assets.sh', import.meta.url),+ 'utf8'+);++if (!tsReleaseWorkflow.includes('publish: pnpm changeset:release')) {+ throw new Error('ts.release.yml must use the repository-controlled changeset:release script');+}++if (packageJson.scripts?.['changeset:release'] !== 'bash ts/scripts/changeset-release.sh') {+ throw new Error('changeset:release must use the CLI-release filtering script');+}++if (!releaseScript.includes('pnpm changeset publish')) {+ throw new Error('release script must still publish non-CLI changeset packages');+}++if (!releaseScript.includes('New tag:[[:space:]]*@composio\\/cli@')) {+ throw new Error('release script must filter @composio/cli tag output before changesets/action creates GitHub releases');+}++// --- build-cli-binaries.yml: the CLI binary workflow is the sole, hardened release writer ---++// A single failed platform must never publish a partial set: fail-fast: false makes the build+// job `success` only when every matrix leg passes, gating the release job.+if (!buildCliWorkflow.includes('fail-fast: false')) {+ throw new Error('build-cli-binaries.yml build matrix must set fail-fast: false');+}++// The release must be built as a draft and only flipped to published after verification, so no+// anonymous consumer can observe a release before its assets are attached. The draft and verify+// logic live in standalone scripts checked out from the workflow revision; the workflow must+// invoke them in helper checkout → draft → verify → publish order.+const helperCheckoutIdx = buildCliWorkflow.indexOf('name: Checkout workflow release helpers');+const draftStepIdx = buildCliWorkflow.indexOf(+ 'bash "$RELEASE_HELPERS_DIR/create-or-resume-draft.sh"'+);+const verifyStepIdx = buildCliWorkflow.indexOf('bash "$RELEASE_HELPERS_DIR/verify-assets.sh"');+const publishIdx = buildCliWorkflow.indexOf('gh release edit "$RELEASE_TAG" --draft=false');++if (!buildCliWorkflow.includes("- '.github/scripts/cli-release/**'")) {+ throw new Error('build-cli-binaries.yml must trigger when CLI release helper scripts change');+}+if (helperCheckoutIdx === -1) {+ throw new Error('build-cli-binaries.yml must checkout workflow release helpers before publishing');+}+if (!buildCliWorkflow.includes('ref: ${{ github.workflow_sha }}')) {+ throw new Error('build-cli-binaries.yml must checkout release helpers from the workflow revision');+}+if (draftStepIdx === -1) {+ throw new Error('build-cli-binaries.yml must create the draft via create-or-resume-draft.sh');+}+if (verifyStepIdx === -1) {+ throw new Error('build-cli-binaries.yml must verify assets via verify-assets.sh');+}+if (publishIdx === -1) {+ throw new Error('build-cli-binaries.yml must publish by flipping the draft (gh release edit --draft=false)');+}+if (!(helperCheckoutIdx < draftStepIdx && draftStepIdx < verifyStepIdx && verifyStepIdx < publishIdx)) {+ throw new Error('build-cli-binaries.yml must order steps helper checkout → draft → verify → publish');+}++// The draft script must actually create a draft, and the verify gate must require fully-uploaded+// assets (not merely present) — that distinction is what stops a release serving 404s.+if (!createDraftScript.includes('--draft')) {+ throw new Error('create-or-resume-draft.sh must create the release as a draft (--draft)');+}+if (!verifyAssetsScript.includes('select(.state == "uploaded")')) {+ throw new Error('verify-assets.sh must require assets be fully uploaded (state == "uploaded")');+}++// Beta status must survive the draft→publish flip (regression: the old single create set+// --prerelease at creation; the new flow must set it on the draft).+if (!createDraftScript.includes('flags+=(--prerelease)')) {+ throw new Error('create-or-resume-draft.sh must preserve --prerelease on the draft for beta releases');+}++// Skills must be packaged BEFORE checksums are generated, so composio-skill.zip is hashed into+// checksums.txt rather than shipping unverifiable.+const packageSkillsIdx = buildCliWorkflow.indexOf('name: Package skill files');+const generateChecksumsIdx = buildCliWorkflow.indexOf('name: Generate checksums');+if (packageSkillsIdx === -1 || generateChecksumsIdx === -1) {+ throw new Error('build-cli-binaries.yml must package skills and generate checksums');+}+if (!(packageSkillsIdx < generateChecksumsIdx)) {+ throw new Error('build-cli-binaries.yml must package skills before generating checksums so the skill zip is checksummed');+}++// Per-tag concurrency prevents two runs clobbering the same release without serializing betas.+if (!buildCliWorkflow.includes('group: cli-release-${{ needs.prepare.outputs.release_tag }}')) {+ throw new Error('build-cli-binaries.yml release job must use per-tag concurrency keyed on the release tag');+}++// Release-target resolution lives in a standalone, unit-tested script (see executable tests+// below) rather than inline YAML bash, so the branching logic is reviewable and testable.+if (!buildCliWorkflow.includes('bash .github/scripts/cli-release/resolve-release-target.sh')) {+ throw new Error('build-cli-binaries.yml prepare job must delegate to resolve-release-target.sh');+}++// The "latest stable" lookup must sort by numeric semver, not lexically: a lexical sort ranks+// @composio/[email protected] above 0.2.10 and would regress beta versioning once a patch hits 2 digits.+if (!resolveTargetScript.includes('map(tonumber)')) {+ throw new Error('resolve-release-target.sh must sort releases by numeric semver (map(tonumber)), not lexically');+}+if (!resolveTargetScript.includes('--exclude-drafts')) {+ throw new Error('resolve-release-target.sh must exclude draft stable releases from beta base selection');+}++// --- cli.install-health-check.yml: canary must exercise the failure-prone pinned path ---++// The bare no-arg `curl | bash` is asset-aware and self-heals to the previous good release, so+// the canary must additionally install the newest PUBLISHED release PINNED to actually catch a+// release shipped with missing assets.+//+// It must resolve the newest *published* GitHub release (drafts excluded), NOT `npm view`: npm's+// latest is bumped minutes before the binary workflow publishes the GitHub release, so pinning to+// it would 404 during the healthy publish gap and false-page.+if (installHealthCheck.includes('$(npm view')) {+ throw new Error('cli.install-health-check.yml must not pin to npm (races ahead of the GitHub release)');+}+if (!installHealthCheck.includes('gh release list')) {+ throw new Error('cli.install-health-check.yml must resolve the newest published release (drafts excluded)');+}+if (!installHealthCheck.includes('--repo "${{ github.repository }}"')) {+ throw new Error('cli.install-health-check.yml must pass repository context to gh release list');+}+if (!installHealthCheck.includes('--limit 1000')) {+ throw new Error('cli.install-health-check.yml must look beyond the gh release list default limit');+}+if (+ !installHealthCheck.includes('--exclude-drafts') ||+ !installHealthCheck.includes('--exclude-pre-releases')+) {+ throw new Error('cli.install-health-check.yml must resolve the newest published release (drafts excluded)');+}+if (installHealthCheck.includes('.[0].tagName')) {+ throw new Error('cli.install-health-check.yml must not let jq null bypass the empty tag guard');+}+if (!installHealthCheck.includes("| sed -n '1p'")) {+ throw new Error('cli.install-health-check.yml must convert no matching release into empty output');+}+if (!installHealthCheck.includes('bash -s -- "${{ steps.resolve.outputs.tag }}"')) {+ throw new Error('cli.install-health-check.yml must install the resolved tag via the pinned path');+}++const fakeBin = mkdtempSync(join(tmpdir(), 'composio-release-test-'));+try {+ const fakePnpmPath = join(fakeBin, 'pnpm');+ writeFileSync(+ fakePnpmPath,+ `#!/usr/bin/env bash+set -euo pipefail+case "$*" in+ "run build:packages")+ exit 0+ ;;+ "changeset publish")+ echo 'New tag: @composio/[email protected]'+ echo 'New tag: @composio/[email protected]'+ echo 'release warning preserved' >&2+ exit 0+ ;;+ *)+ echo "unexpected pnpm invocation: $*" >&2+ exit 1+ ;;+esac+`+ );+ chmodSync(fakePnpmPath, 0o755);++ const result = spawnSync('bash', [releaseScriptPath], {+ encoding: 'utf8',+ env: { ...process.env, PATH: `${fakeBin}:${process.env.PATH}` },+ });++ if (result.status !== 0) {+ throw new Error(`release script failed unexpectedly\nstdout:\n${result.stdout}\nstderr:\n${result.stderr}`);+ }++ if (!result.stdout.includes('New tag: @composio/[email protected]')) {+ throw new Error('release script must preserve non-CLI changeset tags');+ }++ if (result.stdout.includes('@composio/[email protected]')) {+ throw new Error('release script must hide @composio/cli tags from changesets/action');+ }++ if (!result.stderr.includes('release warning preserved')) {+ throw new Error('release script must preserve changeset publish stderr');+ }+} finally {+ rmSync(fakeBin, { recursive: true, force: true });+}++// --- resolve-release-target.sh: executable tests for the release-target branching ---+//+// The script shells out to `gh` and `curl`; we stub both on PATH and feed fixtures, so these+// exercise the real branching/version logic (not just substring presence). `jq`/`python3` stay+// real because the script's correctness depends on them.++const FAKE_GH = `#!/usr/bin/env bash+set -euo pipefail+if [[ "\${1:-}" == "release" && "\${2:-}" == "list" ]]; then+ shift 2+ jqexpr=""+ exclude_drafts=false+ limit=""+ while [[ \$# -gt 0 ]]; do+ if [[ "\$1" == "--exclude-drafts" ]]; then exclude_drafts=true; shift; continue; fi+ if [[ "\$1" == "--limit" ]]; then limit="\$2"; shift 2; continue; fi+ if [[ "\$1" == "--jq" ]]; then jqexpr="\$2"; shift 2; continue; fi+ shift+ done+ if [[ "\$exclude_drafts" != "true" ]]; then+ echo "release list must pass --exclude-drafts" >&2+ exit 1+ fi+ if [[ "\$limit" != "1000" ]]; then+ echo "release list must pass --limit 1000" >&2+ exit 1+ fi+ jq -r '[.[] | select(.isDraft != true)] | '"\$jqexpr" "\$GH_RELEASES_FIXTURE"+ exit 0+fi+if [[ "\${1:-}" == "release" && "\${2:-}" == "view" ]]; then+ # An existing release: echo its isDraft flag. Unset fixture ⇒ exit non-zero (release absent).+ if [[ -n "\${GH_VIEW_ISDRAFT:-}" ]]; then+ echo "\$GH_VIEW_ISDRAFT"+ exit 0+ fi+ exit 1+fi+echo "unexpected gh invocation: \$*" >&2+exit 1+`;++const FAKE_CURL = `#!/usr/bin/env bash+set -euo pipefail+cat "\$CURL_FIXTURE"+`;++function parseOutputs(text) {+ const outputs = {};+ for (const line of text.split('\n')) {+ const idx = line.indexOf('=');+ if (idx === -1) continue;+ outputs[line.slice(0, idx)] = line.slice(idx + 1);+ }+ return outputs;+}++function runResolver({ env, releasesFixture, curlFixture, ghViewIsDraft }) {+ const fakeBin = mkdtempSync(join(tmpdir(), 'composio-fakebin-'));+ const workdir = mkdtempSync(join(tmpdir(), 'composio-resolver-'));+ try {+ for (const [name, body] of [['gh', FAKE_GH], ['curl', FAKE_CURL]]) {+ const p = join(fakeBin, name);+ writeFileSync(p, body);+ chmodSync(p, 0o755);+ }++ const outputPath = join(workdir, 'github_output');+ writeFileSync(outputPath, '');++ const fixtures = {};+ if (releasesFixture !== undefined) {+ const fixturePath = join(workdir, 'releases.json');+ writeFileSync(fixturePath, JSON.stringify(releasesFixture));+ fixtures.GH_RELEASES_FIXTURE = fixturePath;+ }+ if (curlFixture !== undefined) {+ const fixturePath = join(workdir, 'curl.json');+ writeFileSync(fixturePath, JSON.stringify(curlFixture));+ fixtures.CURL_FIXTURE = fixturePath;+ }+ if (ghViewIsDraft !== undefined) fixtures.GH_VIEW_ISDRAFT = ghViewIsDraft;++ const result = spawnSync('bash', [resolveTargetScriptPath], {+ encoding: 'utf8',+ env: {+ ...process.env,+ PATH: `${fakeBin}:${process.env.PATH}`,+ GITHUB_OUTPUT: outputPath,+ ...fixtures,+ ...env,+ },+ });++ const output = readFileSync(outputPath, 'utf8');+ return { ...result, output, outputs: parseOutputs(output) };+ } finally {+ rmSync(fakeBin, { recursive: true, force: true });+ rmSync(workdir, { recursive: true, force: true });+ }+}++// build-beta bumps off the NUMERIC-latest stable release. The fixture deliberately interleaves+// 0.2.10 and 0.2.9: a lexical sort would pick 0.2.9 and resolve 0.2.10 here — regression lock.+{+ const r = runResolver({+ env: {+ EVENT_NAME: 'workflow_dispatch',+ ACTION_INPUT: 'build-beta',+ REPOSITORY: 'ComposioHQ/composio',+ RUN_NUMBER: '42',+ COMMIT_SHA: 'deadbeef',+ },+ releasesFixture: [+ { tagName: '@composio/[email protected]', isPrerelease: false },+ { tagName: '@composio/[email protected]', isPrerelease: false },+ { tagName: '@composio/[email protected]', isPrerelease: false },+ // Draft stables must not become the base for rolling betas.+ { tagName: '@composio/[email protected]', isPrerelease: false, isDraft: true },+ { tagName: '@composio/[email protected]', isPrerelease: true },+ ],+ });+ if (r.status !== 0) {+ throw new Error(`resolve-release-target.sh build-beta failed\nstderr:\n${r.stderr}`);+ }+ if (r.outputs.release_version !== '0.2.11') {+ throw new Error(+ `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.`+ );+ }+ if (r.outputs.release_tag !== '@composio/[email protected]') {+ throw new Error(`build-beta release_tag wrong: ${r.outputs.release_tag}`);+ }+ if (r.outputs.prerelease !== 'true' || r.outputs.make_latest !== 'false') {+ throw new Error('build-beta must emit prerelease=true and make_latest=false');+ }+}++// promote-stable must REFUSE a tag that is already published (isDraft=false) and emit nothing.+{+ const r = runResolver({+ env: {+ EVENT_NAME: 'workflow_dispatch',+ ACTION_INPUT: 'promote-stable',+ BETA_TAG_INPUT: '@composio/[email protected]',+ GITHUB_TOKEN: 'fake-token',+ REPOSITORY: 'ComposioHQ/composio',+ RUN_NUMBER: '1',+ COMMIT_SHA: 'unused',+ },+ curlFixture: { prerelease: true, target_commitish: 'abc123' },+ ghViewIsDraft: 'false',+ });+ if (r.status === 0) {+ throw new Error('promote-stable must refuse an already-published stable tag');+ }+ if (!r.stderr.includes('already published')) {+ throw new Error(`promote-stable refusal must explain itself\nstderr:\n${r.stderr}`);+ }+ if (r.output.trim() !== '') {+ throw new Error('a refused promotion must not emit release outputs');+ }+}++// promote-stable happy path: no existing release ⇒ emit a stable target off the beta's commitish.+{+ const r = runResolver({+ env: {+ EVENT_NAME: 'workflow_dispatch',+ ACTION_INPUT: 'promote-stable',+ BETA_TAG_INPUT: '@composio/[email protected]',+ GITHUB_TOKEN: 'fake-token',+ REPOSITORY: 'ComposioHQ/composio',+ RUN_NUMBER: '1',+ COMMIT_SHA: 'unused',+ },+ curlFixture: { prerelease: true, target_commitish: 'abc123' },+ // ghViewIsDraft unset ⇒ `gh release view` exits non-zero ⇒ no existing release to refuse.+ });+ if (r.status !== 0) {+ throw new Error(`resolve-release-target.sh promote-stable failed\nstderr:\n${r.stderr}`);+ }+ if (r.outputs.release_tag !== '@composio/[email protected]' || r.outputs.release_version !== '0.3.0') {+ throw new Error(`promote-stable must strip the -beta suffix, got ${r.outputs.release_tag}`);+ }+ if (r.outputs.prerelease !== 'false' || r.outputs.make_latest !== 'true') {+ throw new Error('promote-stable must emit prerelease=false and make_latest=true');+ }+ if (r.outputs.checkout_ref !== 'abc123') {+ throw new Error(`promote-stable must check out the beta's target_commitish, got ${r.outputs.checkout_ref}`);+ }+}++console.log('release workflow test passed');diff --git a/ts/packages/cli/AGENTS.md b/ts/packages/cli/AGENTS.mdindex 36e547b21..2f9cc0987 100644--- a/ts/packages/cli/AGENTS.md+++ b/ts/packages/cli/AGENTS.md@@ -185,7 +185,7 @@ Also triggerable from any branch via `workflow_dispatch` → `build-beta`. Users2. Merge into `next`3. Changeset bot opens "Release: update version" PR bumping `package.json`4. Merge that PR → push to `next` detects version change → builds **stable** release (`@composio/[email protected]`, marked `latest`)-5. `ts.release.yml` also publishes to npm+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 ReleasesPromote an existing beta to stable via `workflow_dispatch` → `promote-stable` with the beta tag (e.g. `@composio/[email protected]`).diff --git a/ts/scripts/changeset-release.sh b/ts/scripts/changeset-release.shnew file mode 100755index 000000000..2e164f66c--- /dev/null+++ b/ts/scripts/changeset-release.sh@@ -0,0 +1,25 @@+#!/usr/bin/env bash+set -euo pipefail++# changesets/action infers which GitHub tags/releases to push from `New tag:`+# lines printed by `changeset publish`. The CLI binary workflow owns+# @composio/cli GitHub Releases because those releases must include platform+# binary assets. Let changesets publish/tag every other package, but hide the+# private CLI tag from changesets/action so ts.release.yml cannot create an+# empty @composio/cli GitHub Release.++stdout_file=$(mktemp)+stderr_file=$(mktemp)+trap 'rm -f "$stdout_file" "$stderr_file"' EXIT++pnpm run build:packages++set +e+pnpm changeset publish >"$stdout_file" 2>"$stderr_file"+status=$?+set -e++sed '/New tag:[[:space:]]*@composio\/cli@/d' "$stdout_file"+cat "$stderr_file" >&2++exit "$status"