mirror of
https://github.com/harivansh-afk/sandbox-agent.git
synced 2026-04-16 16:01:05 +00:00
fix: add cli-shared publishing to release workflow
This commit is contained in:
parent
7404e86975
commit
e0573ebaf5
3 changed files with 51 additions and 2 deletions
|
|
@ -13,7 +13,7 @@ import {
|
||||||
createGitHubRelease,
|
createGitHubRelease,
|
||||||
validateGit,
|
validateGit,
|
||||||
} from "./git";
|
} from "./git";
|
||||||
import { publishCrates, publishNpmCli, publishNpmSdk } from "./sdk";
|
import { publishCrates, publishNpmCli, publishNpmCliShared, publishNpmSdk } from "./sdk";
|
||||||
import { updateVersion } from "./update_version";
|
import { updateVersion } from "./update_version";
|
||||||
import { assert, assertEquals, fetchGitRef, versionOrCommitToRef } from "./utils";
|
import { assert, assertEquals, fetchGitRef, versionOrCommitToRef } from "./utils";
|
||||||
|
|
||||||
|
|
@ -281,6 +281,7 @@ const STEPS = [
|
||||||
"run-ci-checks",
|
"run-ci-checks",
|
||||||
"build-js-artifacts",
|
"build-js-artifacts",
|
||||||
"publish-crates",
|
"publish-crates",
|
||||||
|
"publish-npm-cli-shared",
|
||||||
"publish-npm-sdk",
|
"publish-npm-sdk",
|
||||||
"publish-npm-cli",
|
"publish-npm-cli",
|
||||||
"tag-docker",
|
"tag-docker",
|
||||||
|
|
@ -322,6 +323,7 @@ const PHASE_MAP: Record<Phase, Step[]> = {
|
||||||
"complete-ci": [
|
"complete-ci": [
|
||||||
"update-version",
|
"update-version",
|
||||||
"publish-crates",
|
"publish-crates",
|
||||||
|
"publish-npm-cli-shared",
|
||||||
"publish-npm-sdk",
|
"publish-npm-sdk",
|
||||||
"publish-npm-cli",
|
"publish-npm-cli",
|
||||||
"tag-docker",
|
"tag-docker",
|
||||||
|
|
@ -595,6 +597,11 @@ async function main() {
|
||||||
await publishCrates(releaseOpts);
|
await publishCrates(releaseOpts);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (shouldRunStep("publish-npm-cli-shared")) {
|
||||||
|
console.log("==> Publishing NPM CLI Shared");
|
||||||
|
await publishNpmCliShared(releaseOpts);
|
||||||
|
}
|
||||||
|
|
||||||
if (shouldRunStep("publish-npm-sdk")) {
|
if (shouldRunStep("publish-npm-sdk")) {
|
||||||
console.log("==> Publishing NPM SDK");
|
console.log("==> Publishing NPM SDK");
|
||||||
await publishNpmSdk(releaseOpts);
|
await publishNpmSdk(releaseOpts);
|
||||||
|
|
|
||||||
|
|
@ -133,6 +133,43 @@ export async function publishCrates(opts: ReleaseOpts) {
|
||||||
console.log("✅ All crates published");
|
console.log("✅ All crates published");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function publishNpmCliShared(opts: ReleaseOpts) {
|
||||||
|
const cliSharedPath = join(opts.root, "sdks/cli-shared");
|
||||||
|
const packageJsonPath = join(cliSharedPath, "package.json");
|
||||||
|
const packageJson = JSON.parse(await fs.readFile(packageJsonPath, "utf-8"));
|
||||||
|
const name = packageJson.name;
|
||||||
|
|
||||||
|
// Check if version already exists
|
||||||
|
const versionExists = await npmVersionExists(name, opts.version);
|
||||||
|
if (versionExists) {
|
||||||
|
console.log(
|
||||||
|
`Version ${opts.version} of ${name} already exists. Skipping...`,
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Build cli-shared
|
||||||
|
console.log(`==> Building @sandbox-agent/cli-shared`);
|
||||||
|
await $({
|
||||||
|
stdio: "inherit",
|
||||||
|
cwd: opts.root,
|
||||||
|
})`pnpm --filter @sandbox-agent/cli-shared build`;
|
||||||
|
|
||||||
|
// Publish
|
||||||
|
console.log(`==> Publishing to NPM: ${name}@${opts.version}`);
|
||||||
|
|
||||||
|
// Add --tag flag for release candidates
|
||||||
|
const isReleaseCandidate = opts.version.includes("-rc.");
|
||||||
|
const tag = isReleaseCandidate ? "rc" : "latest";
|
||||||
|
|
||||||
|
await $({
|
||||||
|
stdio: "inherit",
|
||||||
|
cwd: cliSharedPath,
|
||||||
|
})`pnpm publish --access public --tag ${tag} --no-git-checks`;
|
||||||
|
|
||||||
|
console.log(`✅ Published ${name}@${opts.version}`);
|
||||||
|
}
|
||||||
|
|
||||||
export async function publishNpmSdk(opts: ReleaseOpts) {
|
export async function publishNpmSdk(opts: ReleaseOpts) {
|
||||||
const sdkPath = join(opts.root, "sdks/typescript");
|
const sdkPath = join(opts.root, "sdks/typescript");
|
||||||
const packageJsonPath = join(sdkPath, "package.json");
|
const packageJsonPath = join(sdkPath, "package.json");
|
||||||
|
|
@ -148,7 +185,7 @@ export async function publishNpmSdk(opts: ReleaseOpts) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build the SDK
|
// Build the SDK (cli-shared should already be built by publishNpmCliShared)
|
||||||
console.log(`==> Building TypeScript SDK`);
|
console.log(`==> Building TypeScript SDK`);
|
||||||
await $({
|
await $({
|
||||||
stdio: "inherit",
|
stdio: "inherit",
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,11 @@ export async function updateVersion(opts: ReleaseOpts) {
|
||||||
find: /\[workspace\.package\]\nversion = ".*"/,
|
find: /\[workspace\.package\]\nversion = ".*"/,
|
||||||
replace: `[workspace.package]\nversion = "${opts.version}"`,
|
replace: `[workspace.package]\nversion = "${opts.version}"`,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: "sdks/cli-shared/package.json",
|
||||||
|
find: /"version": ".*"/,
|
||||||
|
replace: `"version": "${opts.version}"`,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: "sdks/typescript/package.json",
|
path: "sdks/typescript/package.json",
|
||||||
find: /"version": ".*"/,
|
find: /"version": ".*"/,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue