@devries-cameron20 / composio Mirror · read-only / commits / 395cd866a
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 21, 06:00 UTC

feat(release): publish beta releases to npm and PyPI

A release request now picks a channel. A beta goes through the same request, release PR, approval, tag and reviewed candidates as a stable release; only its versions and npm dist-tag differ, and CHANNELS in scripts/sdk-release/channel.ts lists every difference. A beta's versions are Changesets snapshots of the next stable release, suffixed with the planning run (0.29.0-beta.<run>; PyPI 0.29.0b<run>). Its release PR commits only the plan, so next keeps its stable versions and every changeset stays pending. The credential-free candidate build and smoke jobs apply the frozen plan before building. npm publishes it under next, because beta belongs to the 1.0 train on main, and never reads or moves latest. Betas skip the docs check and the docs pin PR.

jkomyno committed Nov 5, 2026 at 18:57 UTC 395cd866ad5f0327fec9895d1d47eec18dbc18d8
24 files changed +480 -99
.github/ISSUE_TEMPLATE/sdk-release.yml
+9
@@ -7,6 +7,15 @@ body:
7 value: |
8 Any active ComposioHQ member can use this form, including members with repository Read access.
9 The bot prepares one release PR. A repository writer who did not request the release approves its final head, then a person merges it.
10 + - type: dropdown
11 + id: channel
12 + attributes:
13 + label: Channel
14 + description: stable publishes to npm `latest` and consumes the changesets. beta publishes a preview such as 0.29.0-beta.<run> (PyPI 0.29.0b<run>) to npm `next` and leaves every changeset for the stable release.
15 + options: [stable, beta]
16 + default: 0
17 + validations:
18 + required: true
19 - type: dropdown
20 id: typescript
21 attributes:
.github/workflows/sdk.release.yml
+5
@@ -17,6 +17,11 @@ on:
17 types: [opened]
18 workflow_dispatch:
19 inputs:
20 + channel:
21 + description: stable consumes the changesets; beta publishes a preview to npm next
22 + type: choice
23 + options: [stable, beta]
24 + default: stable
25 typescript:
26 description: TypeScript bump (auto follows the changesets)
27 type: choice
GLOSSARY.md new
+33
@@ -0,0 +1,33 @@
1 +# SDK release
2 +
3 +How the TypeScript and Python SDKs go from merged changes to published packages on npm and PyPI.
4 +
5 +## Language
6 +
7 +**Language**:
8 +One of the two SDK ecosystems a release covers: TypeScript (published to npm) or Python (published to PyPI).
9 +_Avoid_: Lane, ecosystem, SDK
10 +
11 +**Channel**:
12 +The audience a release is for: stable, installed by default, or beta, installed only when asked for.
13 +_Avoid_: Track, lane, prerelease mode
14 +
15 +**Release request**:
16 +A ComposioHQ member's ask to release, made through the release issue form or a workflow dispatch.
17 +_Avoid_: Release issue, trigger
18 +
19 +**Release batch**:
20 +The versions planned for one release request, across both languages.
21 +_Avoid_: Release plan, train
22 +
23 +**Release PR**:
24 +The bot-authored pull request that carries a release batch's version and changelog changes for review.
25 +_Avoid_: Version PR, changeset PR
26 +
27 +**Candidate**:
28 +A package file built and smoke-tested on the release PR, which is exactly what gets published if the PR is approved.
29 +_Avoid_: Artifact, build
30 +
31 +**Publication**:
32 +One package version on one registry.
33 +_Avoid_: Upload, deploy
scripts/sdk-release/approval.ts
+4 -3
@@ -10,7 +10,7 @@ import {
10 } from './github';
11 import { Pull, isReleasePull, releaseBranch } from './release-pr';
12 import { ensure, fail } from './runtime';
13 -import { BATCH_PATH, ReleaseBatch, batchLanguages } from './source';
13 +import { BATCH_PATH, ReleaseBatch, batchLanguages, channelOf } from './source';
14
15 const WRITE_PERMISSIONS = new Set(['write', 'maintain', 'admin']);
16 const REVIEW_STATES = new Set(['APPROVED', 'CHANGES_REQUESTED', 'DISMISSED']);
@@ -148,7 +148,7 @@ export const trustedIssue = (pull: Pull, batch: ReleaseBatch, appSlug: string) =
148 * - the head is the release App's own commit on the frozen source, so nobody added changes the
149 * release-only diff check did not see;
150 * - a writer other than the author and the requester approved that head;
151 - * - the candidate build, smoke and docs checks passed on it.
151 + * - the candidate build and smoke checks passed on it, and the docs check for a stable release.
152 */
153 export const verifyReleaseGate = (pull: Pull, batch: ReleaseBatch, appSlug: string) =>
154 Effect.gen(function* () {
@@ -184,5 +184,6 @@ export const verifyReleaseGate = (pull: Pull, batch: ReleaseBatch, appSlug: stri
184 for (const language of batchLanguages(batch))
185 for (const check of [`SDK candidate (${language})`, `SDK candidate smoke (${language})`])
186 yield* ensure(passed(check), `Missing green final-head check: ${check}`);
187 - yield* ensure(passed('typescript-check'), 'Missing green final-head docs check');
187 + for (const check of channelOf(batch).extraChecks)
188 + yield* ensure(passed(check), `Missing green final-head check: ${check}`);
189 });
scripts/sdk-release/batch.ts
+11 -5
@@ -20,7 +20,13 @@ import {
20 runUrl,
21 } from './github';
22 import { createSdkReleasePlan, type SdkReleasePlan } from './plan';
23 -import { Pull, isReleasePull, releaseBranch, releasePullBody } from './release-pr';
23 +import {
24 + Pull,
25 + isReleasePull,
26 + releaseBranch,
27 + releasePullBody,
28 + releasePullTitle,
29 +} from './release-pr';
30 import { ReleaseRequest, parseReleaseRequest } from './request';
31 import {
32 appendFile,
@@ -37,7 +43,7 @@ import {
43 ReleasePatch,
44 releaseOutputs,
45 releaseTag,
40 - validateReleaseDiff,
46 + validateBatchDiff,
47 } from './source';
48 import { ReleaseState } from './state';
49
@@ -266,10 +272,10 @@ export const openReleasePull = (cwd: string, planned: ReleaseBatch, value: unkno
272 'Prepared release plan differs from the planned batch'
273 );
274 const outputs = yield* releaseOutputs(cwd, batch);
269 - yield* validateReleaseDiff(patch.files, batch.plan, outputs);
275 + yield* validateBatchDiff(patch.files, batch, outputs);
276 const branch = yield* commitReleaseBranch(batch, patch);
277 const pull = yield* request('POST', `${REPOSITORY_PATH}/pulls`, Pull, {
272 - title: 'chore(release): publish SDK packages',
278 + title: releasePullTitle(batch),
279 head: branch,
280 base: 'next',
281 body: releasePullBody(batch, branch, outputs),
@@ -382,7 +388,7 @@ const MODES: Record<'plan' | 'release-pr' | 'tag', Mode> = {
388 appSlug,
389 ...(envelope.issue ? { issueNumber: envelope.issue.number } : {}),
390 },
385 - choices => createSdkReleasePlan(cwd, choices)
391 + choices => createSdkReleasePlan(cwd, { ...choices, run: env.runId })
392 );
393 yield* outcome._tag === 'Planned'
394 ? appendFile(env.outputPath, `batch=${JSON.stringify(outcome.batch)}\n`)
scripts/sdk-release/candidates.ts
+13 -4
@@ -26,8 +26,8 @@ import {
26 jobs,
27 request,
28 } from './github';
29 -import { Language } from './lanes';
30 -import type { SdkRelease } from './plan';
29 +import { Language, REGISTRY_VERSION } from './lanes';
30 +import { applySdkReleasePlan, type SdkRelease } from './plan';
31 import { discoverPythonPackages } from './python-metadata';
32 import {
33 appendFile,
@@ -41,7 +41,7 @@ import {
41 sha256Hex,
42 type ReleaseServices,
43 } from './runtime';
44 -import { BATCH_PATH, ReleaseBatch, batchLanguages, releaseTag } from './source';
44 +import { BATCH_PATH, ReleaseBatch, batchLanguages, channelOf, releaseTag } from './source';
45
46 const PackedManifest = Schema.StructWithRest(
47 Schema.Struct({ name: Schema.String, version: Schema.String }),
@@ -142,7 +142,7 @@ const LANE_BUILDS: Record<
142 const [release] = selected;
143 const python = yield* discoverPythonPackages(cwd);
144 yield* ensure(
145 - python.every(pkg => pkg.version === release.newVersion),
145 + python.every(pkg => pkg.version === REGISTRY_VERSION.python(release.newVersion)),
146 'Python candidate train differs from the approved target'
147 );
148 }),
@@ -265,6 +265,14 @@ export const adoptApprovedCandidate = (sha: string, language: Language, director
265 } satisfies ApprovedCandidate;
266 });
267
268 +/**
269 + * Makes the checkout carry the versions the candidate publishes. A stable release PR already
270 + * commits them; a beta PR commits only its plan, so its frozen plan is applied here, in the
271 + * credential-free build and smoke jobs, and never reaches `next`.
272 + */
273 +export const prepareCandidateSource = (cwd: string, batch: ReleaseBatch) =>
274 + channelOf(batch).commitsVersions ? Effect.void : applySdkReleasePlan(cwd, batch.plan);
275 +
276 /** Builds a release-PR candidate. */
277 const buildCandidate = (
278 env: BuildEnvironment,
@@ -317,6 +325,7 @@ const buildMode = (language: Language) =>
325 const batch = yield* readJson(ReleaseBatch, BATCH_PATH);
326 const selected = batch.plan.releases.filter(release => release.language === language);
327 yield* ensure(selected.length > 0, `This release plans no ${language} packages`);
328 + yield* prepareCandidateSource((yield* Path.Path).resolve('.'), batch);
329 yield* buildCandidate(env, language, selected);
330 });
331
scripts/sdk-release/channel.ts new
+59
@@ -0,0 +1,59 @@
1 +import { Effect, Schema } from 'effect';
2 +
3 +/** Who a release is for: stable installs by default, beta only when asked for. */
4 +export const Channel = Schema.Literals(['stable', 'beta']);
5 +export type Channel = typeof Channel.Type;
6 +export const stableByDefault = Channel.pipe(
7 + Schema.withDecodingDefaultKey(Effect.succeed('stable' as const))
8 +);
9 +
10 +/**
11 + * Everything that differs between channels. The request, the release PR, the gate, the tag and
12 + * the reviewed files are the same for both.
13 + */
14 +export const CHANNELS = {
15 + stable: {
16 + /** The npm dist-tag a published version moves forward. */
17 + npmTag: 'latest',
18 + /**
19 + * Whether the release PR commits versions, changelogs and references to `next`. A beta PR
20 + * commits only its plan, so `next` stays stable and every changeset stays pending.
21 + */
22 + commitsVersions: true,
23 + /** Checks the release PR head needs besides the candidate checks. */
24 + extraChecks: ['typescript-check'],
25 + /** Whether publishing opens a docs PR that pins the released npm versions. */
26 + pinsDocs: true,
27 + },
28 + beta: {
29 + // `beta` belongs to the 1.0 prerelease train on `main`; previews of `next` use `next`.
30 + npmTag: 'next',
31 + commitsVersions: false,
32 + // A beta PR does not touch the docs, so the docs check never runs on it.
33 + extraChecks: [],
34 + pinsDocs: false,
35 + },
36 +} as const satisfies Record<
37 + Channel,
38 + {
39 + readonly npmTag: string;
40 + readonly commitsVersions: boolean;
41 + readonly extraChecks: ReadonlyArray<string>;
42 + readonly pinsDocs: boolean;
43 + }
44 +>;
45 +
46 +/**
47 + * Changesets snapshot settings for a beta: the version the changesets would release, suffixed
48 + * with the planning run, such as `0.29.0-beta.19087654321`. The run ID is unique and grows over
49 + * time, so betas sort in request order without reading the registry or the clock.
50 + */
51 +export const betaSnapshot = (run: string) => ({
52 + config: { useCalculatedVersion: true, prereleaseTemplate: `{tag}.${run}` },
53 + parameters: { tag: 'beta' },
54 +});
55 +
56 +const BETA = /^(\d+\.\d+\.\d+)-beta\.(\d+)$/;
57 +
58 +/** The PEP 440 spelling of a planned version: `1.2.3-beta.45` is published as `1.2.3b45`. */
59 +export const pythonVersion = (version: string) => version.replace(BETA, '$1b$2');
scripts/sdk-release/consumers.ts
+12 -5
@@ -8,8 +8,8 @@ import {
8 readCandidateFiles,
9 verifyCandidateFiles,
10 } from './artifacts';
11 -import { tarballName } from './candidates';
12 -import { NPM_REGISTRY, type Language } from './lanes';
11 +import { prepareCandidateSource, tarballName } from './candidates';
12 +import { NPM_REGISTRY, REGISTRY_VERSION, type Language } from './lanes';
13 import { discoverPythonPackages } from './python-metadata';
14 import {
15 ensure,
@@ -218,8 +218,9 @@ const verifyPythonConsumer = (
218 Effect.gen(function* () {
219 const path = yield* Path.Path;
220 const command = inDirectory(directory);
221 - const version =
222 - batch.plan.releases.find(release => release.language === 'python')?.newVersion ?? '';
221 + const version = REGISTRY_VERSION.python(
222 + batch.plan.releases.find(release => release.language === 'python')?.newVersion ?? ''
223 + );
224 const packages = yield* discoverPythonPackages(cwd);
225 const python = yield* pythonVersion(cwd);
226 const wheels = yield* candidateWheels(candidates);
@@ -323,7 +324,12 @@ export const verifyCandidateConsumers = (cwd: string, batch: ReleaseBatch, candi
324 yield* CONSUMERS[manifest.language](cwd, batch, directory, candidates);
325 const python = batch.plan.releases.find(release => release.language === 'python');
326 if (manifest.language === 'python' && python)
326 - yield* verifyPublishedProviders(cwd, candidates, python.newVersion, directory);
327 + yield* verifyPublishedProviders(
328 + cwd,
329 + candidates,
330 + REGISTRY_VERSION.python(python.newVersion),
331 + directory
332 + );
333 })
334 );
335
@@ -334,6 +340,7 @@ const main = Effect.gen(function* () {
340 yield* (yield* Stdio.Stdio).args
341 );
342 const batch = yield* readJson(ReleaseBatch, BATCH_PATH);
343 + yield* prepareCandidateSource(path.resolve('.'), batch);
344 yield* verifyCandidateConsumers(path.resolve('.'), batch, path.resolve(candidates));
345 });
346
scripts/sdk-release/lanes.ts
+7
@@ -1,4 +1,5 @@
1 import { Schema } from 'effect';
2 +import { pythonVersion } from './channel';
3
4 export const Language = Schema.Literals(['typescript', 'python']);
5 export type Language = typeof Language.Type;
@@ -17,6 +18,12 @@ export const PRIMARY_TARGETS: Record<Language, ReadonlyArray<string>> = {
18 python: [PYTHON_RELEASE_MARKER],
19 };
20
21 +/** How each language's registry spells a planned version. */
22 +export const REGISTRY_VERSION: Record<Language, (version: string) => string> = {
23 + typescript: version => version,
24 + python: pythonVersion,
25 +};
26 +
27 /** Where each language's registry serves metadata and files. */
28 export const REGISTRY_LANES: Record<
29 Language,
scripts/sdk-release/plan.ts
+43 -8
@@ -6,6 +6,7 @@ import { assembleReleasePlan } from '@changesets/assemble-release-plan';
6 import { applyReleasePlan } from '@changesets/apply-release-plan';
7 import type { Config, NewChangeset, Packages, ReleasePlan } from '@changesets/types';
8 import semver from 'semver';
9 +import { betaSnapshot, pythonVersion, stableByDefault } from './channel';
10 import { LANGUAGES, Language, PRIMARY_TARGETS, PYTHON_RELEASE_MARKER, languageOf } from './lanes';
11 import {
12 discoverPythonPackages,
@@ -26,9 +27,14 @@ export const autoByDefault = ReleaseChoice.pipe(
27 Schema.withDecodingDefaultKey(Effect.succeed('auto' as const))
28 );
29
30 +const PlanningRun = Schema.String.check(Schema.isPattern(/^[1-9][0-9]*$/));
31 +
32 export const ReleaseOptions = Schema.Struct({
33 typescript: autoByDefault,
34 python: autoByDefault,
35 + channel: stableByDefault,
36 + /** The run that plans the release; a beta's versions end with it. */
37 + run: Schema.optionalKey(PlanningRun),
38 });
39 export type SdkReleaseOptions = typeof ReleaseOptions.Encoded;
40 type Choices = Record<Language, ReleaseChoice>;
@@ -54,7 +60,12 @@ const Release = Schema.Struct({
60 export const SdkReleasePlan = Schema.Struct({
61 schemaVersion: Schema.Literal(1),
62 inputFingerprint: Schema.String,
57 - choices: Schema.Struct({ typescript: ReleaseChoice, python: ReleaseChoice }),
63 + choices: Schema.Struct({
64 + typescript: ReleaseChoice,
65 + python: ReleaseChoice,
66 + channel: stableByDefault,
67 + run: Schema.optionalKey(PlanningRun),
68 + }),
69 recommended: Schema.Array(Release),
70 releases: Schema.Array(Release),
71 changesets: Schema.Array(Changeset),
@@ -197,10 +208,23 @@ const maintenanceNotes = (
208 })
209 );
210
211 +/**
212 + * How Changesets computes versions for a channel: the normal bump for stable, a snapshot of it
213 + * for beta. A beta needs its planning run, which makes its versions unique.
214 + */
215 +const versioning = (choices: typeof ReleaseOptions.Type, config: Config) =>
216 + Effect.gen(function* () {
217 + if (choices.channel === 'stable') return { config, snapshot: undefined };
218 + if (choices.run === undefined) return yield* fail('A beta plan needs its planning run');
219 + const { config: snapshot, parameters } = betaSnapshot(choices.run);
220 + return { config: { ...config, snapshot }, snapshot: parameters };
221 + });
222 +
223 export const createSdkReleasePlan = (cwd: string, options: SdkReleaseOptions = {}) =>
224 Effect.gen(function* () {
225 const choices = yield* Schema.decodeUnknownEffect(ReleaseOptions)(options);
226 const inputs = yield* loadInputs(cwd);
227 + const { config, snapshot } = yield* versioning(choices, inputs.config);
228 for (const pkg of inputs.packages.packages)
229 if (inputs.allowed.has(pkg.packageJson.name))
230 yield* ensure(
@@ -208,10 +232,10 @@ export const createSdkReleasePlan = (cwd: string, options: SdkReleaseOptions = {
232 `SDK version must be stable for ${pkg.packageJson.name}`
233 );
234 const notes = inputs.changesets;
211 - const recommendation = assembleReleasePlan(notes, inputs.packages, inputs.config, undefined);
235 + const recommendation = assembleReleasePlan(notes, inputs.packages, config, undefined, snapshot);
236 const { selected, retained } = splitNotes(notes, choices);
237 selected.push(...(yield* maintenanceNotes(selected, choices, inputs.allowed)));
214 - const native = assembleReleasePlan(selected, inputs.packages, inputs.config, undefined);
238 + const native = assembleReleasePlan(selected, inputs.packages, config, undefined, snapshot);
239 const releases = yield* selectedReleases(native);
240 for (const release of releases)
241 yield* ensure(
@@ -221,7 +245,12 @@ export const createSdkReleasePlan = (cwd: string, options: SdkReleaseOptions = {
245 return yield* decodePlan({
246 schemaVersion: 1,
247 inputFingerprint: inputs.fingerprint,
224 - choices: { typescript: choices.typescript, python: choices.python },
248 + choices: {
249 + typescript: choices.typescript,
250 + python: choices.python,
251 + channel: choices.channel,
252 + ...(choices.run === undefined ? {} : { run: choices.run }),
253 + },
254 recommended: yield* selectedReleases(recommendation),
255 releases,
256 changesets: native.changesets,
@@ -259,18 +288,24 @@ export const applySdkReleasePlan = (
288 inputs.allowed.has(release.name) && versionOf(release.name) === release.oldVersion,
289 `Invalid release target ${release.name}`
290 );
291 + const { config, snapshot } = yield* versioning(
292 + yield* Schema.decodeUnknownEffect(ReleaseOptions)(plan.choices),
293 + inputs.config
294 + );
295 const native = assembleReleasePlan(
296 plan.changesets.map(toNewChangeset),
297 inputs.packages,
265 - inputs.config,
266 - undefined
298 + config,
299 + undefined,
300 + snapshot
301 );
302 yield* ensure(
303 sameJson(yield* selectedReleases(native), plan.releases),
304 'Release targets changed from the selected Changesets plan'
305 );
306 + // A snapshot pins internal dependencies to the exact beta versions.
307 yield* fromPromise(() =>
273 - applyReleasePlan(native, inputs.packages, inputs.config, undefined, cwd)
308 + applyReleasePlan(native, inputs.packages, config, snapshot !== undefined, cwd)
309 );
310 for (const note of plan.retainedChangesets)
311 yield* writeFile(
@@ -281,5 +316,5 @@ export const applySdkReleasePlan = (
316 for (const note of plan.changesets.filter(note => !retainedIds.has(note.id)))
317 yield* fs.remove(path.resolve(cwd, '.changeset', `${note.id}.md`), { force: true });
318 const python = plan.releases.find(release => release.name === PYTHON_RELEASE_MARKER);
284 - if (python) yield* synchronizePythonMetadata(cwd, python.newVersion, options);
319 + if (python) yield* synchronizePythonMetadata(cwd, pythonVersion(python.newVersion), options);
320 });
scripts/sdk-release/prepare.ts
+21 -13
@@ -19,9 +19,10 @@ import {
19 BATCH_PATH,
20 ReleaseBatch,
21 ReleasePatch,
22 + channelOf,
23 issueUrl,
24 releaseOutputs,
24 - validateReleaseDiff,
25 + validateBatchDiff,
26 } from './source';
27
28 const git = (cwd: string, ...args: ReadonlyArray<string>) =>
@@ -44,18 +45,9 @@ const releaseFile = (cwd: string, inputBase: string, file: string) =>
45 };
46 });
47
47 -/** Applies a planned batch to a clean checkout of its source and returns the changed files. */
48 -export const prepareRelease = (cwd: string, batch: ReleaseBatch) =>
48 +/** Writes the versions, lockfile, references and changelogs a stable release PR commits. */
49 +const applyStableRelease = (cwd: string, batch: ReleaseBatch) =>
50 Effect.gen(function* () {
50 - const path = yield* Path.Path;
51 - yield* ensure(
52 - (yield* git(cwd, 'rev-parse', 'HEAD')).trim() === batch.inputBase,
53 - 'Preparation checkout does not match the planned source'
54 - );
55 - yield* ensure(
56 - (yield* git(cwd, 'status', '--porcelain')).trim() === '',
57 - 'Preparation requires a clean source checkout'
58 - );
51 yield* applySdkReleasePlan(cwd, batch.plan);
52 yield* run('pnpm', ['install', '--lockfile-only', '--ignore-scripts'], {
53 cwd,
@@ -67,6 +59,22 @@ export const prepareRelease = (cwd: string, batch: ReleaseBatch) =>
59 date: batch.date,
60 requestUrl: issueUrl(batch),
61 });
62 + });
63 +
64 +/** Applies a planned batch to a clean checkout of its source and returns the changed files. */
65 +export const prepareRelease = (cwd: string, batch: ReleaseBatch) =>
66 + Effect.gen(function* () {
67 + const path = yield* Path.Path;
68 + yield* ensure(
69 + (yield* git(cwd, 'rev-parse', 'HEAD')).trim() === batch.inputBase,
70 + 'Preparation checkout does not match the planned source'
71 + );
72 + yield* ensure(
73 + (yield* git(cwd, 'status', '--porcelain')).trim() === '',
74 + 'Preparation requires a clean source checkout'
75 + );
76 + // A beta commits only its plan; its candidate build applies the versions.
77 + if (channelOf(batch).commitsVersions) yield* applyStableRelease(cwd, batch);
78 yield* writeFile(path.resolve(cwd, BATCH_PATH), formatJson(batch));
79 const changed = new Set([
80 ...nulSeparated(yield* git(cwd, 'diff', '--name-only', '-z', batch.inputBase)),
@@ -77,7 +85,7 @@ export const prepareRelease = (cwd: string, batch: ReleaseBatch) =>
85 file => releaseFile(cwd, batch.inputBase, file),
86 { concurrency: 8 }
87 );
80 - yield* validateReleaseDiff(files, batch.plan, yield* releaseOutputs(cwd, batch));
88 + yield* validateBatchDiff(files, batch, yield* releaseOutputs(cwd, batch));
89 return yield* Schema.decodeUnknownEffect(ReleasePatch)({ files });
90 });
91
scripts/sdk-release/python-metadata.ts
+2 -3
@@ -1,6 +1,5 @@
1 import { Effect, FileSystem, Path, Schema } from 'effect';
2 import { Toml } from 'effect/encoding';
3 -import semver from 'semver';
3 import { ensure, fail, readFile, spawn, withoutReleaseTokens, writeFile } from './runtime';
4
5 const PyProject = Schema.Struct({
@@ -143,8 +142,8 @@ export const synchronizePythonMetadata = (
142 ) =>
143 Effect.gen(function* () {
144 yield* ensure(
146 - semver.valid(version) !== null && semver.prerelease(version) === null,
147 - `Python stable release requires a stable semantic version, received ${version}`
145 + /^\d+\.\d+\.\d+(b\d+)?$/.test(version),
146 + `Python release requires a final or beta PEP 440 version, received ${version}`
147 );
148 const path = yield* Path.Path;
149 const packages = yield* discoverPythonPackages(cwd);
scripts/sdk-release/registry.ts
+55 -31
@@ -15,7 +15,14 @@ import {
15 type CandidateFile,
16 } from './artifacts';
17 import { GitHub, REPOSITORY_PATH, Sha, request } from './github';
18 -import { NPM_REGISTRY, REGISTRY_LANES, Language, type Language as Lang } from './lanes';
18 +import { CHANNELS, type Channel } from './channel';
19 +import {
20 + NPM_REGISTRY,
21 + REGISTRY_LANES,
22 + REGISTRY_VERSION,
23 + Language,
24 + type Language as Lang,
25 +} from './lanes';
26 import { discoverPythonPackages } from './python-metadata';
27 import {
28 appendFile,
@@ -40,16 +47,18 @@ export interface Distribution {
47 readonly sha256: string;
48 }
49
43 -export interface StableTag {
50 +/** An npm dist-tag of the release's channel that should point at `version`. */
51 +export interface ChannelTag {
52 readonly name: string;
53 readonly version: string;
54 + readonly tag: string;
55 }
56
48 -/** What the registries already serve, what they are missing, and which `latest` tags lag. */
57 +/** What the registries already serve, what they are missing, and which channel tags lag. */
58 export interface RegistryState {
59 readonly existing: ReadonlyArray<Distribution>;
60 readonly missing: ReadonlyArray<Distribution>;
52 - readonly tagsToRepair: ReadonlyArray<StableTag>;
61 + readonly tagsToRepair: ReadonlyArray<ChannelTag>;
62 }
63
64 const REGISTRY_TIMEOUT = '30 seconds';
@@ -125,7 +134,7 @@ const NpmVersion = Schema.Struct({
134 version: Schema.String,
135 dist: Schema.Struct({ tarball: Url }),
136 });
128 -const NpmLatest = Schema.Struct({ version: Schema.String });
137 +const NpmTagged = Schema.Struct({ version: Schema.String });
138 const PackageIdentity = Schema.Struct({ name: Schema.String, version: Schema.String });
139
140 const pythonDistributionNames = (name: string, version: string) => {
@@ -155,9 +164,12 @@ const distributionOf = (
164 sha256: entry.sha256,
165 });
166
158 -/** npm: one tarball per package version and a stable `latest` tag. */
167 +/**
168 + * npm: one tarball per package version, and the channel's dist-tag moved forward to it. A beta
169 + * only ever reads and moves its own tag, never `latest`.
170 + */
171 const npmAdapter = {
160 - reconcileGroup: (group: ReadonlyArray<Distribution>) =>
172 + reconcileGroup: (group: ReadonlyArray<Distribution>, channel: Channel) =>
173 Effect.gen(function* () {
174 yield* ensure(group.length === 1, 'Expected exactly one npm tarball per package');
175 const [file] = group;
@@ -173,21 +185,22 @@ const npmAdapter = {
185 );
186 yield* verifyOriginalBytes(dist.tarball, file);
187 }
176 - const latest = yield* registryJson(
177 - `${NPM_REGISTRY}/${encodeURIComponent(file.name)}/latest`,
178 - NpmLatest
188 + const { npmTag } = CHANNELS[channel];
189 + const current = yield* registryJson(
190 + `${NPM_REGISTRY}/${encodeURIComponent(file.name)}/${npmTag}`,
191 + NpmTagged
192 );
180 - const tagged = Option.getOrUndefined(Option.map(latest, value => value.version));
193 + const tagged = Option.getOrUndefined(Option.map(current, value => value.version));
194 yield* ensure(
195 tagged === undefined || semver.valid(tagged) !== null,
183 - `Invalid stable npm tag: ${file.name}`
196 + `Invalid npm ${npmTag} tag: ${file.name}`
197 );
198 return {
199 existing: Option.isSome(metadata) ? [file] : [],
200 missing: Option.isSome(metadata) ? [] : [file],
201 tagsToRepair:
202 tagged === undefined || semver.lt(tagged, file.version)
190 - ? [{ name: file.name, version: file.version }]
203 + ? [{ name: file.name, version: file.version, tag: npmTag }]
204 : [],
205 } satisfies RegistryState;
206 }),
@@ -225,7 +238,7 @@ const npmAdapter = {
238
239 /** PyPI: a wheel and sdist for every package of the synchronized Python train. */
240 const pythonAdapter = {
228 - reconcileGroup: (group: ReadonlyArray<Distribution>) =>
241 + reconcileGroup: (group: ReadonlyArray<Distribution>, _channel: Channel) =>
242 Effect.gen(function* () {
243 const [first] = group;
244 const metadata = yield* registryJson(
@@ -258,7 +271,7 @@ const pythonAdapter = {
271 candidateDistributions: (candidate: LoadedCandidate) =>
272 Effect.gen(function* () {
273 const release = candidate.batch.plan.releases.find(entry => entry.language === 'python');
261 - const version = release?.newVersion ?? '';
274 + const version = REGISTRY_VERSION.python(release?.newVersion ?? '');
275 const files: Distribution[] = [];
276 for (const pkg of yield* discoverPythonPackages(candidate.cwd))
277 for (const name of pythonDistributionNames(pkg.name, version)) {
@@ -277,11 +290,14 @@ const pythonAdapter = {
290 const REGISTRY_ADAPTERS = { typescript: npmAdapter, python: pythonAdapter } as const;
291
292 /** Splits reviewed files into those the registry already serves and those still missing. */
280 -export const reconcileRegistry = (files: ReadonlyArray<Distribution>) =>
293 +export const reconcileRegistry = (
294 + files: ReadonlyArray<Distribution>,
295 + channel: Channel = 'stable'
296 +) =>
297 Effect.gen(function* () {
298 const groups = Map.groupBy(files, file => `${file.language}:${file.name}@${file.version}`);
299 const states: ReadonlyArray<RegistryState> = yield* Effect.forEach(groups.values(), group =>
284 - REGISTRY_ADAPTERS[group[0].language].reconcileGroup(group)
300 + REGISTRY_ADAPTERS[group[0].language].reconcileGroup(group, channel)
301 );
302 return {
303 existing: states.flatMap(state => state.existing),
@@ -290,28 +306,31 @@ export const reconcileRegistry = (files: ReadonlyArray<Distribution>) =>
306 } satisfies RegistryState;
307 });
308
293 -const incompleteInventory = (state: RegistryState, stableTags: boolean) =>
309 +const incompleteInventory = (state: RegistryState, channelTags: boolean) =>
310 [
311 ...state.missing.map(file => `${file.name}@${file.version}/${file.file}`),
296 - ...(stableTags ? state.tagsToRepair : []).map(tag => `${tag.name}@${tag.version} stable tag`),
312 + ...(channelTags ? state.tagsToRepair : []).map(
313 + tag => `${tag.name}@${tag.version} ${tag.tag} tag`
314 + ),
315 ].join(', ');
316
317 /**
300 - * Polls the registries until every file is visible, and every stable tag too unless
301 - * `stableTags` is false (right after an upload, before `latest` moves).
318 + * Polls the registries until every file is visible, and every channel tag too unless
319 + * `channelTags` is false (right after an upload, before the channel tag moves).
320 */
321 export const waitForRegistry = (
322 files: ReadonlyArray<Distribution>,
323 options: {
324 readonly attempts?: number;
325 readonly spacing?: Duration.Input;
308 - readonly stableTags?: boolean;
326 + readonly channelTags?: boolean;
327 + readonly channel?: Channel;
328 } = {}
329 ) => {
330 const attempts = options.attempts ?? 6;
312 - return reconcileRegistry(files).pipe(
331 + return reconcileRegistry(files, options.channel).pipe(
332 Effect.flatMap(state => {
314 - const missing = incompleteInventory(state, options.stableTags ?? true);
333 + const missing = incompleteInventory(state, options.channelTags ?? true);
334 return missing
335 ? Effect.fail(new RegistryIncomplete({ message: missing }))
336 : Effect.succeed(state);
@@ -384,13 +403,17 @@ export const loadOriginalDistributions = (
403 });
404 });
405
387 -/** Publishes under a release-only dist-tag, then moves `latest` once the upload is visible. */
388 -const publishNpm = (cwd: string, batch: ReleaseBatch, files: ReadonlyArray<Distribution>) =>
406 +/**
407 + * Publishes under a release-only dist-tag, moves the channel's tag once the upload is visible,
408 + * then drops the release-only tag.
409 + */
410 +export const publishNpm = (cwd: string, batch: ReleaseBatch, files: ReadonlyArray<Distribution>) =>
411 Effect.gen(function* () {
412 const path = yield* Path.Path;
413 + const channel = batch.plan.choices.channel;
414 const npm = (args: ReadonlyArray<string>) =>
415 run('npm', args, { cwd, env: withoutReleaseTokens });
393 - for (const file of (yield* reconcileRegistry(files)).missing)
416 + for (const file of (yield* reconcileRegistry(files, channel)).missing)
417 yield* npm([
418 'publish',
419 path.resolve(cwd, 'sdk-publication/typescript', file.file),
@@ -399,10 +422,10 @@ const publishNpm = (cwd: string, batch: ReleaseBatch, files: ReadonlyArray<Distr
422 '--access=public',
423 `--tag=sdk-release-${batch.id}`,
424 ]);
402 - const visible = yield* waitForRegistry(files, { stableTags: false });
425 + const visible = yield* waitForRegistry(files, { channelTags: false, channel });
426 for (const tag of visible.tagsToRepair)
404 - yield* npm(['dist-tag', 'add', `${tag.name}@${tag.version}`, 'latest']);
405 - yield* waitForRegistry(files);
427 + yield* npm(['dist-tag', 'add', `${tag.name}@${tag.version}`, tag.tag]);
428 + yield* waitForRegistry(files, { channel });
429 // The release-only tag only served the upload; a re-run finds it already gone.
430 const releaseOnly = `sdk-release-${batch.id}`;
431 for (const file of files) {
@@ -458,7 +481,8 @@ const main = Effect.gen(function* () {
481 const files = yield* loadOriginalDistributions(cwd, batch, env.sha, env.approved, language).pipe(
482 Effect.provide(GitHub.layer(env.token))
483 );
461 - if (mode === 'verify') return yield* waitForRegistry(files);
484 + if (mode === 'verify')
485 + return yield* waitForRegistry(files, { channel: batch.plan.choices.channel });
486 if (language === 'typescript') return yield* publishNpm(cwd, batch, files);
487 yield* stageMissingPython(cwd, files, env.output);
488 });
scripts/sdk-release/release-pr.ts
+27 -3
@@ -1,6 +1,7 @@
1 import { Schema } from 'effect';
2 import { PositiveInt, SDK_RELEASE_REPOSITORY, Sha, runUrl } from './github';
3 -import { PYTHON_RELEASE_MARKER } from './lanes';
3 +import type { Channel } from './channel';
4 +import { PYTHON_RELEASE_MARKER, REGISTRY_VERSION } from './lanes';
5 import { issueUrl, type ReleaseBatch } from './source';
6
7 const RELEASE_BRANCH = /^sdk-release\/batch-\d+$/;
@@ -71,6 +72,27 @@ const changesetLine = (note: Changeset) => {
72 return `- \`.changeset/${note.id}.md\` (${bumps || 'no version bump'}): ${headline(note.summary)}`;
73 };
74
75 +/** How a release PR explains its channel to the reviewer. */
76 +const CHANNEL_COPY: Record<
77 + Channel,
78 + { readonly title: string; readonly summary: string; readonly notes: string }
79 +> = {
80 + stable: {
81 + title: 'chore(release): publish SDK packages',
82 + summary: 'A stable release: npm moves `latest` to these versions.',
83 + notes: '## Changesets consumed',
84 + },
85 + beta: {
86 + title: 'chore(release): publish SDK beta packages',
87 + summary:
88 + 'A beta release: npm moves `next` to these versions and never touches `latest`, and pip installs them only with `--pre` or an exact pin. This PR commits only the release plan. The candidate checks apply its versions, so `next` keeps its stable versions and every changeset below stays pending for the stable release.',
89 + notes: '## Changesets previewed',
90 + },
91 +};
92 +
93 +export const releasePullTitle = (batch: ReleaseBatch) =>
94 + CHANNEL_COPY[batch.plan.choices.channel].title;
95 +
96 const packageRows = (plan: Plan) =>
97 plan.releases.map(release => {
98 const recommended = plan.recommended.find(candidate => candidate.name === release.name);
@@ -79,7 +101,7 @@ const packageRows = (plan: Plan) =>
101 ? ''
102 : ` (recommended ${recommended?.newVersion ?? 'none'})`;
103 const notes = release.changesets.map(id => `\`${id}\``).join(', ') || 'maintenance release';
82 - return `| ${packageLabel(release.name)} | ${release.oldVersion} → **${release.newVersion}**${override} | ${release.type} | ${notes} |`;
104 + return `| ${packageLabel(release.name)} | ${release.oldVersion} → **${REGISTRY_VERSION[release.language](release.newVersion)}**${override} | ${release.type} | ${notes} |`;
105 });
106
107 /** Lists what ships, which changesets it consumes, and which changelogs and docs it edits. */
@@ -89,6 +111,7 @@ export const releasePullBody = (
111 outputs: ReadonlyArray<string>
112 ) => {
113 const { plan } = batch;
114 + const copy = CHANNEL_COPY[plan.choices.channel];
115 const changelogs = outputs.filter(path => path.endsWith('/CHANGELOG.md'));
116 const docsChangelog = outputs.filter(path => path.startsWith('docs/content/changelog/'));
117 const references = outputs.filter(path =>
@@ -97,13 +120,14 @@ export const releasePullBody = (
120 const link = (path: string) => `[\`${path}\`](${fileUrl(branch, path)})`;
121 const sections = [
122 NOTE_EXEMPT,
123 + copy.summary,
124 '## What gets released',
125 [
126 '| Package | Version | Bump | Changesets |',
127 '| --- | --- | --- | --- |',
128 ...packageRows(plan),
129 ].join('\n'),
106 - '## Changesets consumed',
130 + copy.notes,
131 plan.changesets.map(changesetLine).join('\n') || 'None: this is a maintenance release.',
132 ...(plan.retainedChangesets.length
133 ? [
scripts/sdk-release/report.ts
+8 -4
@@ -9,9 +9,10 @@ import {
9 request,
10 runUrl,
11 } from './github';
12 +import { REGISTRY_VERSION } from './lanes';
13 import { packageLabel } from './release-pr';
14 import { appendFile, ensure, readJson, runMain } from './runtime';
14 -import { BATCH_PATH, ReleaseBatch } from './source';
15 +import { BATCH_PATH, ReleaseBatch, channelOf } from './source';
16 import { DISPLAY, ReleaseState, STATUS_LABELS, Stage, describe, endsStage } from './state';
17
18 /** Status comments come from the workflow token, so nobody else's comment is ever edited. */
@@ -104,7 +105,7 @@ const publishedState = (batch: ReleaseBatch) =>
105 _tag: 'Published',
106 versions: batch.plan.releases.map(release => ({
107 name: packageLabel(release.name),
107 - version: release.newVersion,
108 + version: REGISTRY_VERSION[release.language](release.newVersion),
109 })),
110 });
111
@@ -172,13 +173,16 @@ const DocsManifest = Schema.Struct({
173 devDependencies: Schema.Record(Schema.String, Schema.String),
174 });
175
175 -/** `report.ts docs-pins <docs package.json>` prints the `bun add` specs for this tag's npm release. */
176 +/**
177 + * `report.ts docs-pins <docs package.json>` prints the `bun add` specs for this tag's npm
178 + * release. A beta prints nothing: the docs follow stable releases only.
179 + */
180 const docsPinsMode = (manifestPath: string) =>
181 Effect.gen(function* () {
182 const batch = yield* readJson(ReleaseBatch, BATCH_PATH);
183 const released = Object.fromEntries(
184 batch.plan.releases
181 - .filter(release => release.language === 'typescript')
185 + .filter(release => channelOf(batch).pinsDocs && release.language === 'typescript')
186 .map(release => [release.name, release.newVersion])
187 );
188 const { devDependencies } = yield* readJson(DocsManifest, manifestPath);
scripts/sdk-release/request.ts
+10 -4
@@ -1,8 +1,13 @@
1 import { Schema } from 'effect';
2 +import { stableByDefault } from './channel';
3 import { autoByDefault } from './plan';
4
4 -/** Per-language bump choices; `auto` follows the changesets. */
5 -export const ReleaseRequest = Schema.Struct({ typescript: autoByDefault, python: autoByDefault });
5 +/** The channel and per-language bump choices; `auto` follows the changesets. */
6 +export const ReleaseRequest = Schema.Struct({
7 + channel: stableByDefault,
8 + typescript: autoByDefault,
9 + python: autoByDefault,
10 +});
11 export type ReleaseRequest = typeof ReleaseRequest.Type;
12
13 const Dispatch = Schema.Struct({
@@ -11,8 +16,9 @@ const Dispatch = Schema.Struct({
16 const Issue = Schema.Struct({ issue: Schema.Struct({ body: Schema.String }) });
17
18 /** Issue-form headings and the request fields they fill. */
14 -const ISSUE_FIELDS = { TypeScript: 'typescript', Python: 'python' } as const;
15 -const ISSUE_FIELD_PATTERN = /^### (TypeScript|Python)\r?\n\r?\n([\s\S]*?)(?=^### |$(?![\s\S]))/gm;
19 +const ISSUE_FIELDS = { Channel: 'channel', TypeScript: 'typescript', Python: 'python' } as const;
20 +const ISSUE_FIELD_PATTERN =
21 + /^### (Channel|TypeScript|Python)\r?\n\r?\n([\s\S]*?)(?=^### |$(?![\s\S]))/gm;
22
23 const parseIssueBody = (body: string) => {
24 const fields = new Map<keyof typeof ISSUE_FIELDS, string>();
scripts/sdk-release/source.ts
+26
@@ -2,6 +2,7 @@ import { Effect, Schema } from 'effect';
2 import { getPackages } from '@manypkg/get-packages';
3 import semver from 'semver';
4 import { PositiveInt, RunId, SDK_RELEASE_REPOSITORY, Sha } from './github';
5 +import { CHANNELS } from './channel';
6 import { PYTHON_RELEASE_MARKER, type Language } from './lanes';
7 import { SdkReleasePlan } from './plan';
8 import { PROJECT_VERSION, RUNTIME_VERSION, SETUP_VERSION } from './python-metadata';
@@ -25,6 +26,10 @@ export const BATCH_PATH = '.github/sdk-release-plan.json';
26 /** The tag a release batch publishes from. */
27 export const releaseTag = (id: string) => `sdk-release/${id}`;
28
29 +/** What the batch's channel changes about its release. */
30 +export const channelOf = (batch: Pick<ReleaseBatch, 'plan'>) =>
31 + CHANNELS[batch.plan.choices.channel];
32 +
33 export const issueUrl = (batch: ReleaseBatch) =>
34 `https://github.com/${SDK_RELEASE_REPOSITORY}/issues/${batch.issue}`;
35
@@ -269,6 +274,26 @@ const validateReleaseFile = (
274 return yield* fail(`Not a planned release output: ${path}`);
275 });
276
277 +/**
278 + * A beta release PR commits only its plan: its versions are applied where the candidates are
279 + * built, so `next` keeps its stable versions and every changeset.
280 + */
281 +const validatePlanOnlyDiff = (files: ReadonlyArray<ReleaseFile>) =>
282 + ensure(
283 + files.length === 1 && files[0].path === BATCH_PATH,
284 + `A beta release PR changes only ${BATCH_PATH}`
285 + );
286 +
287 +/** Checks the release PR's diff against what its channel lets it commit. */
288 +export const validateBatchDiff = (
289 + files: ReadonlyArray<ReleaseFile>,
290 + batch: ReleaseBatch,
291 + outputs: ReadonlyArray<string>
292 +) =>
293 + channelOf(batch).commitsVersions
294 + ? validateReleaseDiff(files, batch.plan, outputs)
295 + : validatePlanOnlyDiff(files);
296 +
297 /** Every changed file must be a planned version, note, lockfile, or generated release output. */
298 export const validateReleaseDiff = (
299 files: ReadonlyArray<ReleaseFile>,
@@ -295,6 +320,7 @@ export const validateReleaseDiff = (
320 /** The changelog and reference paths a release may write besides version metadata. */
321 export const releaseOutputs = (cwd: string, batch: ReleaseBatch) =>
322 Effect.gen(function* () {
323 + if (!channelOf(batch).commitsVersions) return [];
324 const { packages } = yield* fromPromise(() => getPackages(cwd));
325 const names = new Set(batch.plan.releases.map(release => release.name));
326 const [year, month, day] = batch.date.split('-');
test/sdk-release-approval.test.ts
+9 -3
@@ -105,6 +105,12 @@ describe('source tag', () => {
105 expect(await issueOf({ headCommitter: 'writer' })).toEqual(Option.none());
106 });
107
108 + test('a beta is tagged without the docs check, which never runs on a plan-only PR', async () => {
109 + const { fetcher, writes } = fakeController({ beta: true, docs: 'missing' });
110 + expect(await tag(fetcher)).toEqual(tagged);
111 + expect(writes).toEqual([tagWrite]);
112 + });
113 +
114 test('a release PR closed without merging is abandoned and creates no tag', async () => {
115 const { fetcher, writes } = fakeController({ closedUnmerged: true });
116 expect(await tag(fetcher)).toEqual({ _tag: 'Abandoned', pull });
@@ -124,9 +130,9 @@ describe('source tag', () => {
130 ['the head is not on the planned source', { headParent: merge }, 'release App commit'],
131 ['the candidate build failed', { failedCandidate: true }, 'SDK candidate (typescript)'],
132 ['the smoke test failed', { failedSmoke: true }, 'SDK candidate smoke (typescript)'],
127 - ['the docs check failed', { docs: 'failure' }, 'docs check'],
128 - ['the docs check is pending', { docs: 'pending' }, 'docs check'],
129 - ['the docs check is missing', { docs: 'missing' }, 'docs check'],
133 + ['the docs check failed', { docs: 'failure' }, 'typescript-check'],
134 + ['the docs check is pending', { docs: 'pending' }, 'typescript-check'],
135 + ['the docs check is missing', { docs: 'missing' }, 'typescript-check'],
136 ])(
137 'when %s, the release is refused, no tag is created and the PR is told to revert',
138 async (_name, options, reason) => {
test/sdk-release-batch.test.ts
+37
@@ -5,6 +5,8 @@ import { BATCH_PATH, validateReleaseDiff, type ReleaseFile } from '../scripts/sd
5 import {
6 base,
7 batch,
8 + betaBatch,
9 + betaFiles,
10 fakeController,
11 newManifest,
12 oldManifest,
@@ -134,6 +136,41 @@ describe('release PR', () => {
136 expect(writes).toEqual([]);
137 });
138
139 + test('a beta release PR commits only its plan, so next keeps its versions and changesets', async () => {
140 + const { fetcher, writes } = fakeController({ beta: true });
141 + const state = await runRelease(
142 + openReleasePull(await resolvePath('.'), betaBatch, { files: betaFiles }),
143 + fetcher
144 + );
145 + expect(state).toEqual({
146 + _tag: 'InReview',
147 + pull: 'https://github.com/ComposioHQ/composio/pull/9',
148 + });
149 + expect(writePaths(writes)).toEqual([
150 + 'POST /git/blobs',
151 + 'POST /git/trees',
152 + 'POST /git/commits',
153 + 'POST /git/refs',
154 + 'POST /pulls',
155 + ]);
156 + expect(writes.find(write => write.path === '/pulls')?.body).toMatchObject({
157 + title: 'chore(release): publish SDK beta packages',
158 + body: expect.stringContaining('never touches `latest`'),
159 + });
160 + });
161 +
162 + test('a beta release PR that also writes a changelog is refused before any write', async () => {
163 + const { fetcher, writes } = fakeController({ beta: true });
164 + const changelog = { path: 'ts/packages/core/CHANGELOG.md', before: null, after: '## beta' };
165 + await expect(
166 + runRelease(
167 + openReleasePull(await resolvePath('.'), betaBatch, { files: [...betaFiles, changelog] }),
168 + fetcher
169 + )
170 + ).rejects.toThrow('A beta release PR changes only .github/sdk-release-plan.json');
171 + expect(writes).toEqual([]);
172 + });
173 +
174 test('major targets allow normal Changesets peer-range updates without changing unrelated fields', async () => {
175 const plan = {
176 ...batch.plan,
test/sdk-release-controller-fixture.ts
+18 -2
@@ -16,7 +16,7 @@ export const batch: ReleaseBatch = {
16 plan: {
17 schemaVersion: 1,
18 inputFingerprint: 'frozen',
19 - choices: { typescript: 'auto', python: 'skip' },
19 + choices: { typescript: 'auto', python: 'skip', channel: 'stable' },
20 recommended: [],
21 releases: [
22 {
@@ -32,6 +32,20 @@ export const batch: ReleaseBatch = {
32 retainedChangesets: [],
33 },
34 };
35 +/** Batch 8 as a beta: same request and source, snapshot versions, and nothing consumed. */
36 +export const betaBatch: ReleaseBatch = {
37 + ...batch,
38 + plan: {
39 + ...batch.plan,
40 + choices: { ...batch.plan.choices, channel: 'beta', run: '8' },
41 + releases: batch.plan.releases.map(release => ({
42 + ...release,
43 + newVersion: `${release.newVersion}-beta.8`,
44 + })),
45 + },
46 +};
47 +/** The only file a beta release PR commits. */
48 +export const betaFiles = [{ path: BATCH_PATH, before: null, after: JSON.stringify(betaBatch) }];
49 export const oldManifest = JSON.stringify({
50 name: '@composio/core',
51 version: '1.0.0',
@@ -52,6 +66,8 @@ export const releaseFiles = [
66 export interface ControllerOptions {
67 /** `next` carries batch 8's plan without its tag: a release merged and failed its gate. */
68 readonly untaggedNext?: boolean;
69 + /** Serve batch 8 as a beta release PR. */
70 + readonly beta?: boolean;
71 readonly deletedReviewer?: boolean;
72 readonly oldReview?: boolean;
73 readonly reviewer?: string;
@@ -171,7 +187,7 @@ export function fakeController(options: ControllerOptions = {}) {
187 });
188 if (path.startsWith('/contents/')) {
189 const filename = url.pathname.split('/contents/')[1];
174 - const file = releaseFiles.find(file => file.path === filename);
190 + const file = (options.beta ? betaFiles : releaseFiles).find(file => file.path === filename);
191 const data = url.searchParams.get('ref') === base ? file?.before : file?.after;
192 if (data == null) return response({}, 404);
193 return new Response(data);
test/sdk-release-plan.test.ts
+36
@@ -1,4 +1,5 @@
1 import { afterEach, describe, expect, test } from 'bun:test';
2 +import { pythonVersion } from '../scripts/sdk-release/channel';
3 import {
4 applySdkReleasePlan as applyPlanEffect,
5 createSdkReleasePlan as createPlanEffect,
@@ -131,6 +132,36 @@ describe('SDK release planning', () => {
132 );
133 });
134
135 + test('a beta plans snapshot versions of the next stable release, suffixed with its run', async () => {
136 + const { cwd, note } = await fixture();
137 + await note('core-feature', { '@composio/core': 'minor' }, 'Add trigger polling.');
138 + await note('python-fix', { '@composio/python-sdk': 'patch' }, 'Fix connected accounts.');
139 + const plan = await createSdkReleasePlan(cwd, { channel: 'beta', run: '19087654321' });
140 + expect(versions(plan)).toMatchObject({
141 + '@composio/core': '0.29.0-beta.19087654321',
142 + '@composio/slim': '0.29.0-beta.19087654321',
143 + '@composio/python-sdk': '0.31.1-beta.19087654321',
144 + });
145 + expect(plan.choices).toMatchObject({ channel: 'beta', run: '19087654321' });
146 + await applySdkReleasePlan(cwd, plan, { updateLockfile: false });
147 + expect(JSON.parse(await readText(`${cwd}/packages/core/package.json`)).version).toBe(
148 + '0.29.0-beta.19087654321'
149 + );
150 + // Python spells the same beta the PEP 440 way, in every mirror.
151 + expect(await readText(`${cwd}/python/composio/__version__.py`)).toContain('0.31.1b19087654321');
152 + expect(
153 + (await discoverPythonPackages(cwd)).every(pkg => pkg.version === '0.31.1b19087654321')
154 + ).toBe(true);
155 + });
156 +
157 + test('a beta needs its planning run, so its versions are unique', async () => {
158 + const { cwd, note } = await fixture();
159 + await note('core-feature', { '@composio/core': 'minor' });
160 + await expect(createSdkReleasePlan(cwd, { channel: 'beta' })).rejects.toThrow(
161 + 'A beta plan needs its planning run'
162 + );
163 + });
164 +
165 test('mixed recommendations retain TS independent provider versions and per-language overrides', async () => {
166 const { cwd, note } = await fixture();
167 await note('mixed', {
@@ -278,3 +309,8 @@ describe('SDK release planning', () => {
309 expect(JSON.parse(await readText(`${cwd}/packages/core/package.json`)).version).toBe('0.28.0');
310 });
311 });
312 +
313 +test('a beta takes the PEP 440 spelling on PyPI and stable versions keep theirs', () => {
314 + expect(pythonVersion('0.31.1-beta.19087654321')).toBe('0.31.1b19087654321');
315 + expect(pythonVersion('0.31.1')).toBe('0.31.1');
316 +});
test/sdk-release-publication.test.ts
+23 -5
@@ -1,4 +1,5 @@
1 import { describe, expect, test } from 'bun:test';
2 +import type { Channel } from '../scripts/sdk-release/channel';
3 import type { Language } from '../scripts/sdk-release/lanes';
4 import {
5 loadOriginalDistributions,
@@ -25,8 +26,8 @@ const distribution = async (file: string, language: Language = 'python'): Promis
26 const wheel = await distribution('composio-1.0.1-py3-none-any.whl');
27 const sdist = await distribution('composio-1.0.1.tar.gz');
28 const tarball = await distribution('composio-core-1.0.1.tgz', 'typescript');
28 -const reconcileRegistry = (files: Distribution[], fetch: Fetch) =>
29 - runRelease(reconcileRegistryEffect(files), fetch);
29 +const reconcileRegistry = (files: Distribution[], fetch: Fetch, channel?: Channel) =>
30 + runRelease(reconcileRegistryEffect(files, channel), fetch);
31
32 function registry(
33 files: Distribution[],
@@ -134,7 +135,7 @@ describe('registry reconciliation', () => {
135 ).rejects.toThrow(`after 3 attempts: composio@1.0.1/${sdist.file}`);
136 expect(fake.reads.filter(url => url.startsWith('https://pypi.org/'))).toHaveLength(3);
137 });
137 - test('a fresh npm upload is polled until visible, then its stable tag is left to move', async () => {
138 + test('a fresh npm upload is polled until visible, then its channel tag is left to move', async () => {
139 const fake = registry([tarball]);
140 let lookups = 0;
141 const lagging: Fetch = async input => {
@@ -145,11 +146,28 @@ describe('registry reconciliation', () => {
146 return fake.fetcher(input);
147 };
148 const state = await runRelease(
148 - waitForRegistry([tarball], { attempts: 3, spacing: '0 millis', stableTags: false }),
149 + waitForRegistry([tarball], { attempts: 3, spacing: '0 millis', channelTags: false }),
150 lagging
151 );
152 expect(state.missing).toEqual([]);
152 - expect(state.tagsToRepair).toEqual([{ name: tarball.name, version: tarball.version }]);
153 + expect(state.tagsToRepair).toEqual([
154 + { name: tarball.name, version: tarball.version, tag: 'latest' },
155 + ]);
156 + });
157 + test('a beta moves only npm next forward and never reads or moves latest', async () => {
158 + const beta = { ...tarball, version: '1.0.1-beta.8', file: 'composio-core-1.0.1-beta.8.tgz' };
159 + const requested: string[] = [];
160 + const fetch: Fetch = async input => {
161 + const url = String(input);
162 + requested.push(url);
163 + if (url.endsWith('/next')) return new Response(JSON.stringify({ version: '0.1.36-next.13' }));
164 + if (url.endsWith('/1.0.1-beta.8')) return new Response('{}', { status: 404 });
165 + throw new Error(`Unexpected registry request: ${url}`);
166 + };
167 + const state = await reconcileRegistry([beta], fetch, 'beta');
168 + expect(state.missing).toEqual([beta]);
169 + expect(state.tagsToRepair).toEqual([{ name: beta.name, version: beta.version, tag: 'next' }]);
170 + expect(requested.some(url => url.endsWith('/latest'))).toBe(false);
171 });
172 test('a content conflict fails at once instead of waiting for propagation', async () => {
173 const fake = registry([wheel], { conflict: true });
test/sdk-release-release-pr.test.ts
+1 -1
@@ -32,7 +32,7 @@ const batch: ReleaseBatch = {
32 plan: {
33 schemaVersion: 1,
34 inputFingerprint: 'frozen',
35 - choices: { typescript: 'auto', python: 'minor' },
35 + choices: { typescript: 'auto', python: 'minor', channel: 'stable' },
36 recommended: [
37 release('@composio/core', 'typescript', '1.1.0', ['brave-cats']),
38 release('@composio/python-sdk', 'python', '1.0.1', []),
test/sdk-release-request.test.ts
+11 -5
@@ -16,7 +16,7 @@ const context = {
16 const plan: SdkReleasePlan = {
17 schemaVersion: 1,
18 inputFingerprint: 'frozen',
19 - choices: { typescript: 'auto', python: 'auto' },
19 + choices: { typescript: 'auto', python: 'auto', channel: 'stable' },
20 recommended: [],
21 changesets: [],
22 retainedChangesets: [],
@@ -31,7 +31,7 @@ const plan: SdkReleasePlan = {
31 },
32 ],
33 };
34 -const request: ReleaseRequest = { typescript: 'auto', python: 'auto' };
34 +const request: ReleaseRequest = { channel: 'stable', typescript: 'auto', python: 'auto' };
35 const planned = (value: SdkReleasePlan) => () => Effect.succeed(value);
36 const failing = (message: string) => () =>
37 Effect.sync((): SdkReleasePlan => {
@@ -103,11 +103,17 @@ function client(
103
104 describe('release request parsing', () => {
105 test('the issue form and a dispatch read into the same request', () => {
106 - const issue = { issue: { body: '### TypeScript\n\nskip\n\n### Python\n\npatch\n' } };
107 - expect(parseReleaseRequest('issues', issue)).toEqual({ typescript: 'skip', python: 'patch' });
106 + const issue = {
107 + issue: { body: '### Channel\n\nbeta\n\n### TypeScript\n\nskip\n\n### Python\n\npatch\n' },
108 + };
109 + expect(parseReleaseRequest('issues', issue)).toEqual({
110 + channel: 'beta',
111 + typescript: 'skip',
112 + python: 'patch',
113 + });
114 expect(
115 parseReleaseRequest('workflow_dispatch', { inputs: { typescript: 'skip', python: 'patch' } })
110 - ).toEqual({ typescript: 'skip', python: 'patch' });
116 + ).toEqual({ channel: 'stable', typescript: 'skip', python: 'patch' });
117 expect(parseReleaseRequest('workflow_dispatch', { inputs: {} })).toEqual(request);
118 });
119 test('a hand-written issue body and an unknown bump are refused', () => {