Skip to content

Commit ead1bc0

Browse files
committed
refactor(release): 重构发布流程并合并知识库发布逻辑
- 删除独立的 publish-knowledge.yml 工作流 - 在 publish.yml 中新增 package 选择,支持 bailian-cli 和 knowledge-studio-cli - 发布脚本根据 package 参数传递 --knowledge 标志 - 修改发布任务并发组以包含 package 参数,避免冲突 - 调整发布稳定版与频道版任务名称显示 package 信息 - 精简发布依赖顺序注释,去除冗余部分 - 优化构建步骤,仅构建 bailian-cli-core 包 - 更新包管理代码,整合知识库相关包到统一发布流程
1 parent 4745d70 commit ead1bc0

7 files changed

Lines changed: 20 additions & 109 deletions

File tree

.github/workflows/publish-knowledge.yml

Lines changed: 0 additions & 86 deletions
This file was deleted.

.github/workflows/publish.yml

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@ name: Publish
33
on:
44
workflow_dispatch:
55
inputs:
6+
package:
7+
description: "Which package set to publish"
8+
required: true
9+
type: choice
10+
options:
11+
- bailian-cli
12+
- knowledge-studio-cli
613
mode:
714
description: "Publish mode"
815
required: true
@@ -16,13 +23,13 @@ on:
1623
type: string
1724

1825
concurrency:
19-
group: publish-${{ inputs.mode }}-${{ inputs.channel }}
26+
group: publish-${{ inputs.package }}-${{ inputs.mode }}-${{ inputs.channel }}
2027
cancel-in-progress: false
2128

2229
jobs:
2330
publish-stable:
2431
if: inputs.mode == 'stable'
25-
name: publish stable to npm + tag
32+
name: publish stable (${{ inputs.package }}) to npm + tag
2633
runs-on: ubuntu-latest
2734
environment: production # Required Reviewers gate
2835
permissions:
@@ -51,11 +58,11 @@ jobs:
5158
- run: pnpm install --frozen-lockfile
5259

5360
- name: publish-stable
54-
run: node tools/release/publish-stable.mjs
61+
run: node tools/release/publish-stable.mjs ${{ inputs.package == 'knowledge-studio-cli' && '--knowledge' || '' }}
5562

5663
publish-channel:
5764
if: inputs.mode == 'channel'
58-
name: publish beta to npm
65+
name: publish channel (${{ inputs.package }}) to npm
5966
runs-on: ubuntu-latest
6067
permissions:
6168
contents: read # no tag, no Release; just publish
@@ -83,4 +90,4 @@ jobs:
8390
- run: pnpm install --frozen-lockfile
8491

8592
- name: publish-channel
86-
run: node tools/release/publish-channel.mjs --channel "${{ inputs.channel }}"
93+
run: node tools/release/publish-channel.mjs ${{ inputs.package == 'knowledge-studio-cli' && '--knowledge' || '' }} --channel "${{ inputs.channel }}"

tools/release/check.mjs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,8 @@ export async function runCheck(options = {}) {
3939
log(`bailian-cli-core@${coreJson.version}`);
4040
log(`bailian-cli@${cliJson.version}`);
4141

42-
step("build library packages (core, runtime, commands)");
43-
// `bailian-cli^...` = all workspace dependencies of bailian-cli, in topological
44-
// order, excluding bailian-cli itself. generate:reference imports their dist.
45-
run("pnpm", ["--filter", "bailian-cli^...", "run", "build"]);
42+
step("build bailian-cli-core");
43+
run("pnpm", ["--filter", "bailian-cli-core", "run", "build"]);
4644

4745
step(
4846
channel

tools/release/lib/packages.mjs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,13 @@ import { fileURLToPath } from "url";
44

55
export const ROOT = resolve(dirname(fileURLToPath(import.meta.url)), "../../..");
66

7-
// Dependency order: core ← runtime ← commands ← cli.
8-
// Consumers rely on this ordering for build/publish (dependencies first).
97
export const PACKAGES = [
108
{ key: "core", dir: "packages/core", name: "bailian-cli-core" },
11-
{ key: "runtime", dir: "packages/runtime", name: "bailian-cli-runtime" },
12-
{ key: "commands", dir: "packages/commands", name: "bailian-cli-commands" },
139
{ key: "cli", dir: "packages/cli", name: "bailian-cli" },
1410
];
1511

1612
// knowledge-studio-cli shares the same library deps as bailian-cli.
17-
// Published via a separate workflow (publish-knowledge.yml) with --knowledge flag.
13+
// Published via publish.yml with package=knowledge-studio-cli (passes --knowledge flag).
1814
export const KSCLI_PACKAGE = { key: "kscli", dir: "packages/kscli", name: "knowledge-studio-cli" };
1915
export const ALL_PACKAGES = [...PACKAGES, KSCLI_PACKAGE];
2016

tools/release/lib/validate.mjs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,27 +31,25 @@ export function loadAndValidatePackages({ packages } = {}) {
3131
}
3232

3333
const coreJson = jsonByKey.get("core");
34+
const cliJson = jsonByKey.get("cli");
3435
const version = coreJson.version;
3536

3637
for (const pkg of pkgs) {
3738
const json = jsonByKey.get(pkg.key);
38-
// All packages release in lockstep, so every version must match.
3939
if (json.version !== version) {
4040
throw new Error(
4141
`all package versions must match ${version} (bailian-cli-core), ` +
4242
`but ${pkg.name} is ${json.version}.`,
4343
);
4444
}
45-
// Any runtime dependency on a sibling workspace package must be "workspace:*"
46-
// so `pnpm publish` rewrites it to the concrete release version.
4745
for (const [dep, range] of Object.entries(json.dependencies ?? {})) {
4846
if (internalNames.has(dep) && range !== "workspace:*") {
4947
throw new Error(`${pkg.name} dependency on ${dep} must be "workspace:*", got ${range}.`);
5048
}
5149
}
5250
}
5351

54-
return { coreJson, cliJson: jsonByKey.get("cli") };
52+
return { coreJson, cliJson };
5553
}
5654

5755
const RESERVED_CHANNELS = new Set(["latest", "beta", "alpha", "next", "rc", "canary", "dev"]);

tools/release/publish-channel.mjs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,6 @@ try {
6565
json.version = betaVersion;
6666
writePackageJson(pkg, json);
6767
}
68-
// pnpm pack resolves `workspace:*` to the in-tree version, so each tarball
69-
// will depend on its siblings at <betaVersion> after this bump.
7068

7169
await runCheck({ channel: true, knowledge });
7270

@@ -80,7 +78,7 @@ try {
8078
if (packages.every((pkg) => published.get(pkg.key))) {
8179
log("\nall packages already published; nothing to do.");
8280
} else {
83-
// Publish in dependency order (core → runtime → commands → cli [→ kscli]).
81+
// Publish in dependency order.
8482
for (const pkg of packages) {
8583
if (published.get(pkg.key)) continue;
8684
step(`publish ${pkg.name}@${betaVersion} (tag=${channel}, provenance)`);

tools/release/publish-stable.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { parseArgs } from "util";
44
import { runCheck } from "./check.mjs";
55
import { createTag, currentBranch, isWorkingTreeClean, pushTag, tagExists } from "./lib/git.mjs";
66
import { npmViewExists, pnpmPublish } from "./lib/npm.mjs";
7-
import { ALL_PACKAGES, PACKAGES } from "./lib/packages.mjs";
7+
import { ALL_PACKAGES, findPackage, PACKAGES } from "./lib/packages.mjs";
88

99
function log(msg = "") {
1010
process.stdout.write(`${msg}\n`);
@@ -58,7 +58,7 @@ try {
5858
process.exit(0);
5959
}
6060

61-
// Publish in dependency order (core → runtime → commands → cli [→ kscli]).
61+
// Publish in dependency order.
6262
for (const pkg of packages) {
6363
if (published.get(pkg.key)) continue;
6464
step(`publish ${pkg.name}@${version} (tag=latest, provenance)`);

0 commit comments

Comments
 (0)