Files
oh-my-pi/scripts/ci-release-publish.ts
T
can1357 52719d1a7c refactor: restructured monorepo TypeScript config and build tasks for unified setup
- Migrated all package tsconfig files to extend tsconfig.workspace.json for unified TypeScript configuration across monorepo.
- Consolidated build and check scripts across 10+ packages to use biome for linting/formatting with separate type checking via tsgo.
- Renamed build scripts from build:native and build:binary to build for simplified command naming across packages/natives and packages/coding-agent.
- Refactored CI workflow to invoke bun tasks instead of inline shell scripts, reducing workflow complexity by 40+ lines.
- Removed sync-exports.ts and repro-stuck.ts scripts; deleted path aliases from tsconfig.base.json in favor of workspace-based configuration.
- Updated turbo.json with new task definitions (check:types, lint, fmt, fix) and removed build:native/embed:native tasks.
2026-04-08 17:05:20 +02:00

74 lines
1.9 KiB
TypeScript

#!/usr/bin/env bun
import * as path from "node:path";
import { $ } from "bun";
interface PublishPackage {
dir: string;
}
interface PackageJson {
private?: boolean;
}
const repoRoot = path.join(import.meta.dir, "..");
const isDryRun = process.argv.includes("--dry-run");
const packageDirs: PublishPackage[] = [
{ dir: "packages/utils" },
{ dir: "packages/ai" },
{ dir: "packages/natives" },
{ dir: "packages/tui" },
{ dir: "packages/stats" },
{ dir: "packages/agent" },
{ dir: "packages/coding-agent" },
];
const alreadyPublishedPatterns = [
"previously published",
"cannot publish over",
"You cannot publish over",
];
function isAlreadyPublished(output: string): boolean {
return alreadyPublishedPatterns.some((pattern) => output.includes(pattern));
}
async function readPackageJson(packageDir: string): Promise<PackageJson> {
return (await Bun.file(path.join(repoRoot, packageDir, "package.json")).json()) as PackageJson;
}
async function publishPackage(pkg: PublishPackage): Promise<void> {
const packageJson = await readPackageJson(pkg.dir);
const packageName = path.basename(pkg.dir);
if (packageJson.private) {
console.log(`Skipping ${packageName} (private)`);
return;
}
if (isDryRun) {
console.log(`DRY RUN bun publish --access public (${pkg.dir})`);
return;
}
console.log(`Publishing ${packageName}...`);
const result = await $`bun publish --access public`.cwd(path.join(repoRoot, pkg.dir)).quiet().nothrow();
const output = `${result.stdout.toString()}${result.stderr.toString()}`.trim();
if (result.exitCode === 0) {
if (output) console.log(output);
return;
}
if (output) console.log(output);
if (isAlreadyPublished(output)) {
console.log("Already published, skipping");
return;
}
process.exit(result.exitCode ?? 1);
}
async function main(): Promise<void> {
for (const pkg of packageDirs) {
await publishPackage(pkg);
}
}
await main();