@devries-cameron20 / composio Mirror · read-only / commits / 59844b580
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.

Mirrored from https://github.com/Camo67/composio.git

Synced Nov 22, 00:45 UTC

Add beta-channel CLI release promotion flow (#3089)

## Summary - Add support for beta CLI releases in the binary publish workflow, including beta tag validation and promotion to stable from an existing prerelease tag. - Update `composio upgrade` to support a `--beta` flag that stays on the prerelease channel. - Refresh release documentation and CLI README to describe the new beta/stable release model. - Expand upgrade binary tests to cover prerelease resolution and channel-specific behavior. ## Testing - Not run (PR content generation only). - Checked the workflow and CLI changes for beta/stable tag handling paths. - Reviewed updated release documentation for the new promotion flow.

Rahul Tarak committed Mar 31, 2026 at 16:23 UTC 59844b58091cab65172d04b944a61e9d08aa6120
7 files changed +461 -62
.agents/skills/cli-release-promotion/SKILL.md new
+67
@@ -0,0 +1,67 @@
1 +---
2 +description: Validate a Composio CLI beta release and promote it to a stable release by dispatching the CLI binary workflow with an existing beta tag.
3 +---
4 +
5 +# CLI Release Promotion
6 +
7 +Use this skill when working on the Composio CLI release pipeline or when an agent needs to test a beta CLI binary and trigger the final stable promotion.
8 +
9 +## What This Covers
10 +
11 +- Finding the beta release tag produced from the Changesets release PR
12 +- Smoke-testing that beta release through the existing installation path
13 +- Promoting only an existing beta release to a stable CLI release
14 +
15 +## Beta Release Model
16 +
17 +- Beta releases are created by `.github/workflows/build-cli-binaries.yml`
18 +- They are triggered from the Changesets release PR titled `Release: update version`
19 +- Beta tags use the form `@composio/cli@<version>-beta.<pr-number>`
20 +- Stable releases are promoted manually from an existing beta tag through the same workflow
21 +
22 +## Validate The Beta
23 +
24 +Pick the beta tag you intend to promote, then test it before promotion.
25 +
26 +Use the existing installation health check workflow if you only need repo-side validation:
27 +
28 +```bash
29 +gh workflow run cli.test-installation.yml -f version='@composio/cli@0.2.18-beta.123'
30 +```
31 +
32 +For a local smoke test, install that exact beta binary and verify the upgrade path:
33 +
34 +```bash
35 +curl -fsSL https://raw.githubusercontent.com/ComposioHQ/composio/main/install.sh | bash -s -- '@composio/cli@0.2.18-beta.123'
36 +composio --version
37 +composio upgrade --beta
38 +```
39 +
40 +`composio upgrade --beta` should stay on the beta channel and resolve the newest prerelease, not the latest stable release.
41 +
42 +## Promote To Stable
43 +
44 +Only promote by referencing an existing beta tag.
45 +
46 +Run the CLI binary workflow manually with that beta tag:
47 +
48 +```bash
49 +gh workflow run build-cli-binaries.yml -f beta_tag='@composio/cli@0.2.18-beta.123'
50 +```
51 +
52 +The workflow will:
53 +
54 +- verify the beta release exists
55 +- reject non-prerelease tags
56 +- derive the stable tag `@composio/cli@0.2.18`
57 +- rebuild from the beta release's recorded commit
58 +- publish the stable GitHub release
59 +
60 +## Reference Files
61 +
62 +Read these when you need implementation details:
63 +
64 +- `.github/workflows/build-cli-binaries.yml`
65 +- `ts/packages/cli/src/commands/upgrade.cmd.ts`
66 +- `ts/packages/cli/src/services/upgrade-binary.ts`
67 +- `ts/docs/internal/release.md`
.github/workflows/build-cli-binaries.yml
+133 -25
@@ -1,21 +1,133 @@
1 name: Build CLI Binaries
2
3 on:
4 - release:
5 - types: [published]
4 + pull_request:
5 + branches: [next]
6 + types: [opened, synchronize, reopened]
7 workflow_dispatch:
8 inputs:
8 - version:
9 - description: 'Semver version to release (e.g., 1.0.0)'
9 + beta_tag:
10 + description: 'Existing beta release tag to promote (e.g., @composio/cli@1.0.0-beta.123)'
11 required: true
12
13 permissions:
14 contents: write
15
16 jobs:
17 + prepare:
18 + name: Resolve Release Metadata
19 + if: "${{ github.event_name == 'workflow_dispatch' || github.event.pull_request.title == 'Release: update version' }}"
20 + runs-on: ubuntu-latest
21 + outputs:
22 + checkout_ref: ${{ steps.resolve.outputs.checkout_ref }}
23 + release_name: ${{ steps.resolve.outputs.release_name }}
24 + release_tag: ${{ steps.resolve.outputs.release_tag }}
25 + release_version: ${{ steps.resolve.outputs.release_version }}
26 + prerelease: ${{ steps.resolve.outputs.prerelease }}
27 + make_latest: ${{ steps.resolve.outputs.make_latest }}
28 +
29 + steps:
30 + - name: Checkout release PR head
31 + if: github.event_name == 'pull_request'
32 + uses: actions/checkout@v6
33 + with:
34 + ref: ${{ github.event.pull_request.head.sha }}
35 +
36 + - name: Resolve beta or stable release target
37 + id: resolve
38 + env:
39 + EVENT_NAME: ${{ github.event_name }}
40 + PR_NUMBER: ${{ github.event.pull_request.number }}
41 + PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
42 + BETA_TAG_INPUT: ${{ inputs.beta_tag }}
43 + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
44 + REPOSITORY: ${{ github.repository }}
45 + run: |
46 + set -euo pipefail
47 +
48 + if [[ "$EVENT_NAME" == "pull_request" ]]; then
49 + version=$(node -p "require('./ts/packages/cli/package.json').version")
50 + if [[ ! "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
51 + echo "Expected ts/packages/cli/package.json version to be a stable semver on the release PR, got: $version"
52 + exit 1
53 + fi
54 +
55 + release_tag="@composio/cli@${version}-beta.${PR_NUMBER}"
56 + release_name="CLI Beta ${release_tag}"
57 + {
58 + echo "checkout_ref=${PR_HEAD_SHA}"
59 + echo "release_name=${release_name}"
60 + echo "release_tag=${release_tag}"
61 + echo "release_version=${version}"
62 + echo "prerelease=true"
63 + echo "make_latest=false"
64 + } >> "$GITHUB_OUTPUT"
65 + exit 0
66 + fi
67 +
68 + encoded_beta_tag=$(python3 - <<'PY'
69 + import os, urllib.parse
70 + print(urllib.parse.quote(os.environ["BETA_TAG_INPUT"], safe=""))
71 + PY
72 + )
73 +
74 + release_json=$(curl -fsSL \
75 + -H "Authorization: Bearer ${GITHUB_TOKEN}" \
76 + -H "Accept: application/vnd.github+json" \
77 + "https://api.github.com/repos/${REPOSITORY}/releases/tags/${encoded_beta_tag}")
78 +
79 + is_prerelease=$(jq -r '.prerelease' <<<"$release_json")
80 + if [[ "$is_prerelease" != "true" ]]; then
81 + echo "Release ${BETA_TAG_INPUT} is not a beta prerelease"
82 + exit 1
83 + fi
84 +
85 + if [[ ! "$BETA_TAG_INPUT" =~ ^@composio/cli@([0-9]+\.[0-9]+\.[0-9]+)-beta\.[0-9]+$ ]]; then
86 + echo "Beta tag must match @composio/cli@<version>-beta.<pr-number>"
87 + exit 1
88 + fi
89 +
90 + stable_version="${BASH_REMATCH[1]}"
91 + stable_tag="@composio/cli@${stable_version}"
92 + export stable_tag
93 +
94 + stable_status=$(curl -sS -o /tmp/stable-release.json -w "%{http_code}" \
95 + -H "Authorization: Bearer ${GITHUB_TOKEN}" \
96 + -H "Accept: application/vnd.github+json" \
97 + "https://api.github.com/repos/${REPOSITORY}/releases/tags/$(python3 - <<'PY'
98 + import os, urllib.parse
99 + print(urllib.parse.quote(os.environ["stable_tag"], safe=""))
100 + PY
101 + )")
102 + if [[ "$stable_status" == "200" ]]; then
103 + echo "Stable release ${stable_tag} already exists"
104 + exit 1
105 + fi
106 + if [[ "$stable_status" != "404" ]]; then
107 + echo "Unexpected response while checking stable release ${stable_tag}: HTTP ${stable_status}"
108 + cat /tmp/stable-release.json
109 + exit 1
110 + fi
111 +
112 + target_commitish=$(jq -r '.target_commitish' <<<"$release_json")
113 + if [[ -z "$target_commitish" || "$target_commitish" == "null" ]]; then
114 + echo "Beta release ${BETA_TAG_INPUT} does not expose target_commitish"
115 + exit 1
116 + fi
117 +
118 + {
119 + echo "checkout_ref=${target_commitish}"
120 + echo "release_name=CLI ${stable_tag}"
121 + echo "release_tag=${stable_tag}"
122 + echo "release_version=${stable_version}"
123 + echo "prerelease=false"
124 + echo "make_latest=true"
125 + } >> "$GITHUB_OUTPUT"
126 +
127 build:
128 name: Build ${{ matrix.artifact }}
18 - if: github.event_name == 'workflow_dispatch' || startsWith(github.event.release.tag_name, '@composio/cli@') || startsWith(github.event.release.tag_name, 'v')
129 + needs: prepare
130 + if: needs.prepare.result == 'success'
131 runs-on: ubuntu-latest
132 strategy:
133 matrix:
@@ -32,16 +144,8 @@ jobs:
144 steps:
145 - name: Checkout
146 uses: actions/checkout@v6
35 -
36 - - name: Validate manual version input
37 - if: github.event_name == 'workflow_dispatch'
38 - run: |
39 - version="${{ inputs.version }}"
40 - if [[ ! "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+([-.][0-9A-Za-z.-]+)?(\+[0-9A-Za-z.-]+)?$ ]]; then
41 - echo "Invalid semver version: '$version'"
42 - echo "Expected format like: 1.2.3, 1.2.3-beta.1, 1.2.3+build.7"
43 - exit 1
44 - fi
147 + with:
148 + ref: ${{ needs.prepare.outputs.checkout_ref }}
149
150 - name: Setup Node.js, pnpm, Bun
151 uses: ./.github/actions/setup-node-pnpm-bun
@@ -84,13 +188,15 @@ jobs:
188
189 release:
190 name: Create Release
87 - needs: build
191 + needs: [prepare, build]
192 runs-on: ubuntu-latest
89 - if: github.event_name == 'release' || github.event_name == 'workflow_dispatch'
193 + if: needs.build.result == 'success'
194
195 steps:
196 - name: Checkout
197 uses: actions/checkout@v6
198 + with:
199 + ref: ${{ needs.prepare.outputs.checkout_ref }}
200
201 - name: Setup Node.js, pnpm, Bun
202 uses: ./.github/actions/setup-node-pnpm-bun
@@ -119,29 +225,31 @@ jobs:
225 - name: Create GitHub Release
226 uses: softprops/action-gh-release@v2
227 with:
122 - tag_name: ${{ github.event_name == 'workflow_dispatch' && format('@composio/cli@{0}', inputs.version) || github.event.release.tag_name }}
123 - name: ${{ github.event_name == 'workflow_dispatch' && format('CLI @composio/cli@{0} (Manual Build)', inputs.version) || github.event.release.tag_name }}
228 + tag_name: ${{ needs.prepare.outputs.release_tag }}
229 + name: ${{ needs.prepare.outputs.release_name }}
230 files: |
231 ts/packages/cli/dist/binaries/*.zip
232 ts/packages/cli/dist/binaries/checksums.txt
233 draft: false
128 - prerelease: ${{ github.event_name == 'workflow_dispatch' || github.event.release.prerelease || contains(github.event.release.tag_name, 'alpha') || contains(github.event.release.tag_name, 'beta') || contains(github.event.release.tag_name, 'rc') }}
234 + prerelease: ${{ needs.prepare.outputs.prerelease == 'true' }}
235 generate_release_notes: true
130 - make_latest: ${{ github.event_name != 'workflow_dispatch' }}
236 + make_latest: ${{ needs.prepare.outputs.make_latest }}
237 + target_commitish: ${{ needs.prepare.outputs.checkout_ref }}
238 + overwrite_files: true
239 env:
240 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
241
242 test-installation:
243 name: Test Installation
136 - needs: release
244 + needs: [prepare, release]
245 if: always() && !cancelled() && needs.release.result == 'success'
246 uses: ./.github/workflows/cli.test-installation.yml
247 with:
140 - version: ${{ github.event_name == 'workflow_dispatch' && format('@composio/cli@{0}', inputs.version) || github.event.release.tag_name }}
248 + version: ${{ needs.prepare.outputs.release_tag }}
249
250 create-install-instructions:
251 name: Create Install Instructions
144 - needs: release
252 + needs: [prepare, release]
253 runs-on: ubuntu-latest
254 if: always() && !cancelled() && needs.release.result == 'success'
255
@@ -151,7 +259,7 @@ jobs:
259
260 - name: Create installation README
261 run: |
154 - RELEASE_TAG="${{ github.event_name == 'workflow_dispatch' && format('@composio/cli@{0}', inputs.version) || github.event.release.tag_name }}"
262 + RELEASE_TAG="${{ needs.prepare.outputs.release_tag }}"
263 cat > INSTALL.md << 'EOF'
264 # Composio CLI Installation
265
ts/docs/internal/release.md
+18 -11
@@ -9,35 +9,42 @@ The CLI binary release process is separate from npm publishing.
9 - `@composio/cli` is marked private and is not published to npm via Changesets.
10 - CLI binaries are built and published as GitHub Release assets by `.github/workflows/build-cli-binaries.yml`.
11 - Install and upgrade flows (`install.sh` and `composio upgrade`) download binaries from GitHub Releases.
12 +- `composio upgrade --beta` resolves the newest CLI prerelease from GitHub Releases.
13
14 ### Triggers
15
15 -The CLI binary workflow supports two tag formats during the migration window:
16 +The CLI binary workflow supports two entry points:
17
17 -- Legacy: `v*`
18 -- New package-scoped tags: `@composio/cli@*`
18 +- Beta release: the auto-generated Changesets release PR titled `Release: update version`
19 +- Stable release: manual `workflow_dispatch`, but only from an existing beta release tag
20
20 -It also supports manual runs (`workflow_dispatch`).
21 +### Beta CLI Release
22
22 -### Manual CLI Binary Release
23 +When the Changesets release PR is opened or updated, the workflow:
24 +
25 +1. Reads the bumped CLI version from `ts/packages/cli/package.json`
26 +2. Publishes a prerelease tag in the form `@composio/cli@<version>-beta.<pr-number>`
27 +3. Attaches the built binaries to that prerelease
28 +
29 +### Stable CLI Release
30
31 When running **Build CLI Binaries** manually:
32
26 -1. Enter a plain semver version (for example `1.2.3`).
27 -2. The workflow validates semver format.
28 -3. The workflow creates/publishes the release under tag `@composio/cli@<version>`.
33 +1. Enter an existing beta tag (for example `@composio/cli@1.2.3-beta.456`)
34 +2. The workflow verifies that the beta release already exists and is marked as a prerelease
35 +3. The workflow checks out the exact commit associated with that beta release
36 +4. The workflow rebuilds the binaries and publishes the stable release under `@composio/cli@<version>`
37
38 ### What the workflow does
39
40 1. Builds CLI binaries for Linux/macOS (x64 + arm64)
41 2. Creates platform zip archives (`composio-<platform>.zip`)
34 -3. Publishes assets to the GitHub Release
42 +3. Publishes assets to the beta or stable GitHub Release
43 4. Runs `.github/workflows/cli.test-installation.yml` to validate installation paths and shell integration
44
45 ### Notes
46
39 -- The temporary dual-tag support (`v*` + `@composio/cli@*`) is intended to keep older installed CLIs upgradeable during migration.
40 -- After migration, legacy `v*` support can be removed.
47 +- Stable promotion is intentionally gated on an existing beta release so the shipped stable binaries always correspond to a tested beta artifact.
48
49 ## Automated Release Process
50
ts/packages/cli/README.md
+7 -1
@@ -41,7 +41,7 @@ composio [--log-level all|trace|debug|info|warning|error|fatal|none]
41 - `composio generate [-o, --output-dir <directory>] [--toolkits <toolkit>] [--type-tools]`: Auto-detect the project language (Python or TypeScript) and generate type stubs for toolkits, tools, and triggers.
42 - `composio generate py [-o, --output-dir <directory>] [--toolkits <toolkit>]`: Generate Python type stubs for toolkits, tools, and triggers from the Composio API.
43 - `composio generate ts [-o, --output-dir <directory>] [--compact] [--transpiled] [--type-tools] [--toolkits <toolkit>]`: Generate TypeScript types for toolkits, tools, and triggers from the Composio API.
44 -- `composio upgrade`: Self-update the Composio CLI if a new release is out.
44 +- `composio upgrade [--beta]`: Self-update the Composio CLI from the stable channel, or from the beta channel with `--beta`.
45
46 ## Configuration
47
@@ -85,6 +85,12 @@ If you pin upgrades with `COMPOSIO_GITHUB_TAG`, prefer the package-scoped tag fo
85 COMPOSIO_GITHUB_TAG='@composio/cli@0.1.24' composio upgrade
86 ```
87
88 +To pull from the beta channel instead of the stable channel:
89 +
90 +```bash
91 +composio upgrade --beta
92 +```
93 +
94 ## Caching
95
96 The CLI implements a file-based caching system for improved performance and offline capabilities.
ts/packages/cli/src/commands/upgrade.cmd.ts
+9 -3
@@ -1,9 +1,15 @@
1 -import { Command } from '@effect/cli';
1 +import { Command, Options } from '@effect/cli';
2 import { Effect } from 'effect';
3 import { APP_VERSION } from 'src/constants';
4 import { UpgradeBinary } from 'src/services/upgrade-binary';
5 import { installSkillSafe } from 'src/effects/install-skill';
6
7 +const betaOpt = Options.boolean('beta').pipe(
8 + Options.withAlias('b'),
9 + Options.withDefault(false),
10 + Options.withDescription('Upgrade to the latest beta CLI release instead of the stable channel')
11 +);
12 +
13 /**
14 * CLI command to upgrade the CLI to the latest available version.
15 *
@@ -12,10 +18,10 @@ import { installSkillSafe } from 'src/effects/install-skill';
18 * composio upgrade
19 * ```
20 */
15 -export const upgradeCmd = Command.make('upgrade', {}, () =>
21 +export const upgradeCmd = Command.make('upgrade', { beta: betaOpt }, ({ beta }) =>
22 Effect.gen(function* () {
23 const upgradeBinary = yield* UpgradeBinary;
18 - const newReleaseTag = yield* upgradeBinary.upgrade();
24 + const newReleaseTag = yield* upgradeBinary.upgrade({ prerelease: beta });
25 yield* installSkillSafe({ releaseTag: newReleaseTag ?? `@composio/cli@${APP_VERSION}` });
26 })
27 ).pipe(Command.withDescription('Upgrade your Composio CLI to the latest available version.'));
ts/packages/cli/src/services/upgrade-binary.ts
+34 -16
@@ -14,6 +14,7 @@ import { renderPrettyError } from './utils/pretty-error';
14 import { TerminalUI } from './terminal-ui';
15 import {
16 collectExpectedRunCompanionAssetRelativePaths,
17 + readInstalledReleaseTag,
18 writeInstalledReleaseTag,
19 } from './run-companion-modules';
20
@@ -108,14 +109,18 @@ export class UpgradeBinary extends Effect.Service<UpgradeBinary>()('services/Upg
109 });
110
111 const fetchLatestRelease = (
111 - platformArch: PlatformArch
112 + platformArch: PlatformArch,
113 + options: {
114 + prerelease?: boolean;
115 + } = {}
116 ): Effect.Effect<GitHubRelease, UpgradeBinaryError, never> =>
117 Effect.gen(function* () {
118 + const prerelease = options.prerelease ?? false;
119 const release = yield* githubConfig.TAG.pipe(
120 Option.match({
121 onNone: Effect.fn(function* () {
122 yield* Effect.logDebug(
118 - 'No tag specified, resolving latest package-scoped CLI release'
123 + `No tag specified, resolving latest package-scoped CLI ${prerelease ? 'beta' : 'stable'} release`
124 );
125 const url = `${githubConfig.API_BASE_URL}/repos/${githubConfig.OWNER}/${githubConfig.REPO}/releases?per_page=100`;
126 const releases = yield* fetchGitHubJson<unknown>({
@@ -139,7 +144,9 @@ export class UpgradeBinary extends Effect.Service<UpgradeBinary>()('services/Upg
144 release !== null &&
145 'tag_name' in release &&
146 typeof release.tag_name === 'string' &&
142 - ('prerelease' in release ? release.prerelease === false : true) &&
147 + ('prerelease' in release
148 + ? release.prerelease === prerelease
149 + : prerelease === false) &&
150 ('draft' in release ? release.draft === false : true) &&
151 CLI_RELEASE_TAG_PATTERN.test(release.tag_name)
152 );
@@ -147,9 +154,10 @@ export class UpgradeBinary extends Effect.Service<UpgradeBinary>()('services/Upg
154 if (cliReleases.length === 0) {
155 return yield* Effect.fail(
156 new UpgradeBinaryError({
150 - cause: new Error('No package-scoped CLI releases found'),
151 - message:
152 - 'Failed to determine latest CLI release from @composio/cli tags on GitHub',
157 + cause: new Error(
158 + `No package-scoped CLI ${prerelease ? 'beta' : 'stable'} releases found`
159 + ),
160 + message: `Failed to determine latest CLI ${prerelease ? 'beta' : 'stable'} release from @composio/cli tags on GitHub`,
161 })
162 );
163 }
@@ -162,10 +170,9 @@ export class UpgradeBinary extends Effect.Service<UpgradeBinary>()('services/Upg
170 return yield* Effect.fail(
171 new UpgradeBinaryError({
172 cause: new Error(
165 - `No package-scoped CLI releases found with ${getBinaryAssetName(platformArch)}`
173 + `No package-scoped CLI ${prerelease ? 'beta' : 'stable'} releases found with ${getBinaryAssetName(platformArch)}`
174 ),
167 - message:
168 - 'Failed to determine latest CLI release from @composio/cli tags on GitHub',
175 + message: `Failed to determine latest CLI ${prerelease ? 'beta' : 'stable'} release from @composio/cli tags on GitHub`,
176 })
177 );
178 }
@@ -210,13 +217,17 @@ export class UpgradeBinary extends Effect.Service<UpgradeBinary>()('services/Upg
217 /**
218 * Check if update is available
219 */
220 + const resolveCurrentReleaseIdentifier = (currentPath: string) =>
221 + readInstalledReleaseTag(currentPath) || `@composio/cli@${APP_VERSION}`;
222 +
223 const isUpdateAvailable = (
214 - release: GitHubRelease
224 + release: GitHubRelease,
225 + currentReleaseIdentifier: string
226 ): Effect.Effect<boolean, CompareSemverError | UpgradeBinaryError, never> =>
227 Effect.gen(function* () {
228 // Current version is older than latest
229 const isVersionOutdated: Predicate<number> = comparison => comparison < 0;
219 - const comparison = yield* semverComparator(APP_VERSION, release.tag_name);
230 + const comparison = yield* semverComparator(currentReleaseIdentifier, release.tag_name);
231 return isVersionOutdated(comparison);
232 });
233
@@ -561,18 +572,25 @@ export class UpgradeBinary extends Effect.Service<UpgradeBinary>()('services/Upg
572 /**
573 * Main upgrade function
574 */
564 - const upgrade = () =>
575 + const upgrade = (
576 + options: {
577 + prerelease?: boolean;
578 + } = {}
579 + ) =>
580 Effect.gen(function* () {
581 const ui = yield* TerminalUI;
582 const upgradeTargetOpt = yield* DEBUG_OVERRIDE_CONFIG['UPGRADE_TARGET'];
583 const currentPath = yield* getCurrentExecutablePath();
584 + const prerelease = options.prerelease ?? false;
585 + const currentReleaseIdentifier = resolveCurrentReleaseIdentifier(currentPath);
586 yield* Effect.logDebug(`Current executable path: ${currentPath}`);
587 + yield* Effect.logDebug(`Current release identifier: ${currentReleaseIdentifier}`);
588
589 yield* ui.intro('composio upgrade');
590
591 // If local binary path is provided (for testing), use it directly
592 if (Option.isSome(upgradeTargetOpt)) {
575 - yield* ui.log.info(`New local version available (current: ${APP_VERSION})`);
593 + yield* ui.log.info(`New local version available (current: ${currentReleaseIdentifier})`);
594 yield* replaceBinary(upgradeTargetOpt.value, currentPath);
595 yield* ui.outro('Upgrade completed');
596 return undefined;
@@ -581,15 +599,15 @@ export class UpgradeBinary extends Effect.Service<UpgradeBinary>()('services/Upg
599 const didUpgrade = yield* ui.useMakeSpinner('Checking for updates...', spinner =>
600 Effect.gen(function* () {
601 const platformArch = yield* detectPlatform;
584 - const release = yield* fetchLatestRelease(platformArch);
585 - const updateAvailable = yield* isUpdateAvailable(release);
602 + const release = yield* fetchLatestRelease(platformArch, { prerelease });
603 + const updateAvailable = yield* isUpdateAvailable(release, currentReleaseIdentifier);
604 if (!updateAvailable) {
605 yield* spinner.stop('You are already running the latest version!');
606 return false;
607 }
608
609 yield* spinner.message(
592 - `New version available: ${release.tag_name} (current: ${APP_VERSION}). Downloading...`
610 + `New version available: ${release.tag_name} (current: ${currentReleaseIdentifier}). Downloading...`
611 );
612
613 const { name, data } = yield* downloadBinary(release, platformArch);
ts/packages/cli/test/src/services/upgrade-binary.test.ts
+193 -6
@@ -2,6 +2,9 @@ import { describe, expect, it, vi } from '@effect/vitest';
2 import { ConfigProvider, Effect, Layer } from 'effect';
3 import { FetchHttpClient } from '@effect/platform';
4 import { BunFileSystem } from '@effect/platform-bun';
5 +import { mkdtempSync, writeFileSync } from 'node:fs';
6 +import { tmpdir } from 'node:os';
7 +import path from 'node:path';
8 import { withHttpServer } from 'test/__utils__/http-server';
9 import { TerminalUI } from 'src/services/terminal-ui';
10 import { UpgradeBinary, UpgradeBinaryError } from 'src/services/upgrade-binary';
@@ -43,10 +46,15 @@ const NodeOsTest = Layer.succeed(
46 })
47 );
48
46 -const makeUpgradeEffect = (configEntries: ReadonlyArray<[string, string]>) =>
49 +const makeUpgradeEffect = (
50 + configEntries: ReadonlyArray<[string, string]>,
51 + options?: {
52 + prerelease?: boolean;
53 + }
54 +) =>
55 Effect.gen(function* () {
56 const service = yield* UpgradeBinary;
49 - return yield* service.upgrade();
57 + return yield* service.upgrade(options);
58 }).pipe(
59 Effect.provide(UpgradeBinary.Default),
60 Effect.provide(FetchHttpClient.layer),
@@ -57,11 +65,19 @@ const makeUpgradeEffect = (configEntries: ReadonlyArray<[string, string]>) =>
65 Effect.scoped
66 );
67
60 -const runUpgrade = (configEntries: ReadonlyArray<[string, string]>) =>
61 - makeUpgradeEffect(configEntries).pipe(Effect.flip, Effect.runPromise);
68 +const runUpgrade = (
69 + configEntries: ReadonlyArray<[string, string]>,
70 + options?: {
71 + prerelease?: boolean;
72 + }
73 +) => makeUpgradeEffect(configEntries, options).pipe(Effect.flip, Effect.runPromise);
74
63 -const runUpgradeSuccess = (configEntries: ReadonlyArray<[string, string]>) =>
64 - makeUpgradeEffect(configEntries).pipe(Effect.runPromise);
75 +const runUpgradeSuccess = (
76 + configEntries: ReadonlyArray<[string, string]>,
77 + options?: {
78 + prerelease?: boolean;
79 + }
80 +) => makeUpgradeEffect(configEntries, options).pipe(Effect.runPromise);
81
82 describe('UpgradeBinary', () => {
83 it('wraps non-2xx releases fetch failures with fetch context (no tag branch)', async () => {
@@ -208,4 +224,175 @@ describe('UpgradeBinary', () => {
224 vi.restoreAllMocks();
225 }
226 });
227 +
228 + it('ignores prereleases when checking the stable channel', async () => {
229 + vi.stubGlobal('Bun', { which: vi.fn(() => null) });
230 +
231 + try {
232 + await withHttpServer(
233 + (_req, res) => {
234 + res.writeHead(200, { 'content-type': 'application/json' });
235 + res.end(
236 + JSON.stringify([
237 + {
238 + tag_name: '@composio/cli@0.2.18-beta.9',
239 + draft: false,
240 + prerelease: true,
241 + assets: [
242 + {
243 + name: 'composio-darwin-aarch64.zip',
244 + browser_download_url: 'http://127.0.0.1/beta.zip',
245 + },
246 + ],
247 + },
248 + {
249 + tag_name: '@composio/cli@0.2.17',
250 + draft: false,
251 + prerelease: false,
252 + assets: [
253 + {
254 + name: 'composio-darwin-aarch64.zip',
255 + browser_download_url: 'http://127.0.0.1/stable.zip',
256 + },
257 + ],
258 + },
259 + ])
260 + );
261 + },
262 + async apiBaseUrl => {
263 + const result = await runUpgradeSuccess([
264 + ['GITHUB_API_BASE_URL', apiBaseUrl],
265 + ['GITHUB_OWNER', 'test-owner'],
266 + ['GITHUB_REPO', 'test-repo'],
267 + ]);
268 +
269 + expect(result).toBeUndefined();
270 + }
271 + );
272 + } finally {
273 + vi.unstubAllGlobals();
274 + vi.restoreAllMocks();
275 + }
276 + });
277 +
278 + it('selects the latest prerelease when beta upgrades are requested', async () => {
279 + vi.stubGlobal('Bun', { which: vi.fn(() => null) });
280 +
281 + try {
282 + await withHttpServer(
283 + (_req, res) => {
284 + res.writeHead(200, { 'content-type': 'application/json' });
285 + res.end(
286 + JSON.stringify([
287 + {
288 + tag_name: '@composio/cli@0.2.18-beta.1',
289 + draft: false,
290 + prerelease: true,
291 + assets: [
292 + {
293 + name: 'composio-darwin-aarch64.zip',
294 + browser_download_url: 'http://127.0.0.1/beta-1.zip',
295 + },
296 + ],
297 + },
298 + {
299 + tag_name: '@composio/cli@0.2.18-beta.3',
300 + draft: false,
301 + prerelease: true,
302 + assets: [
303 + {
304 + name: 'composio-darwin-aarch64.zip',
305 + browser_download_url: 'http://127.0.0.1/beta-3.zip',
306 + },
307 + ],
308 + },
309 + {
310 + tag_name: '@composio/cli@0.2.17',
311 + draft: false,
312 + prerelease: false,
313 + assets: [
314 + {
315 + name: 'composio-darwin-aarch64.zip',
316 + browser_download_url: 'http://127.0.0.1/stable.zip',
317 + },
318 + ],
319 + },
320 + ])
321 + );
322 + },
323 + async apiBaseUrl => {
324 + const error = await runUpgrade(
325 + [
326 + ['GITHUB_API_BASE_URL', apiBaseUrl],
327 + ['GITHUB_OWNER', 'test-owner'],
328 + ['GITHUB_REPO', 'test-repo'],
329 + ],
330 + { prerelease: true }
331 + );
332 +
333 + expect(error).toBeInstanceOf(UpgradeBinaryError);
334 + if (!(error instanceof UpgradeBinaryError)) {
335 + throw error;
336 + }
337 + expect(error.message).toBe('Failed to download binary: composio-darwin-aarch64.zip');
338 + expect(String(error.cause)).toContain('beta-3.zip');
339 + }
340 + );
341 + } finally {
342 + vi.unstubAllGlobals();
343 + vi.restoreAllMocks();
344 + }
345 + });
346 +
347 + it('uses the installed beta release tag when comparing beta updates', async () => {
348 + const installDir = mkdtempSync(path.join(tmpdir(), 'composio-beta-upgrade-'));
349 + const fakeExecPath = path.join(installDir, 'composio');
350 + writeFileSync(path.join(installDir, 'release-tag.txt'), '@composio/cli@0.2.17-beta.1\n');
351 + vi.stubGlobal('Bun', { which: vi.fn(() => null) });
352 + const execPathSpy = vi.spyOn(process, 'execPath', 'get').mockReturnValue(fakeExecPath);
353 +
354 + try {
355 + await withHttpServer(
356 + (_req, res) => {
357 + res.writeHead(200, { 'content-type': 'application/json' });
358 + res.end(
359 + JSON.stringify([
360 + {
361 + tag_name: '@composio/cli@0.2.17-beta.3',
362 + draft: false,
363 + prerelease: true,
364 + assets: [
365 + {
366 + name: 'composio-darwin-aarch64.zip',
367 + browser_download_url: 'http://127.0.0.1/beta-3.zip',
368 + },
369 + ],
370 + },
371 + ])
372 + );
373 + },
374 + async apiBaseUrl => {
375 + const error = await runUpgrade(
376 + [
377 + ['GITHUB_API_BASE_URL', apiBaseUrl],
378 + ['GITHUB_OWNER', 'test-owner'],
379 + ['GITHUB_REPO', 'test-repo'],
380 + ],
381 + { prerelease: true }
382 + );
383 +
384 + expect(error).toBeInstanceOf(UpgradeBinaryError);
385 + if (!(error instanceof UpgradeBinaryError)) {
386 + throw error;
387 + }
388 + expect(error.message).toBe('Failed to download binary: composio-darwin-aarch64.zip');
389 + expect(String(error.cause)).toContain('beta-3.zip');
390 + }
391 + );
392 + } finally {
393 + execPathSpy.mockRestore();
394 + vi.unstubAllGlobals();
395 + vi.restoreAllMocks();
396 + }
397 + });
398 });