mirror of
https://github.com/modelstudioai/cli.git
synced 2026-09-14 19:49:23 +08:00
build: multi channel install test
This commit is contained in:
@@ -57,6 +57,8 @@ jobs:
|
||||
|
||||
- run: pnpm install --frozen-lockfile
|
||||
|
||||
# Binary compile uses `bun build --compile` CLI (not Bun.build API).
|
||||
# Keep this pin in sync with any local smoke tests of binary-compile.mjs.
|
||||
- uses: oven-sh/setup-bun@v2
|
||||
with:
|
||||
bun-version: "1.2.19"
|
||||
@@ -97,6 +99,8 @@ jobs:
|
||||
|
||||
- run: pnpm install --frozen-lockfile
|
||||
|
||||
# Binary compile uses `bun build --compile` CLI (not Bun.build API).
|
||||
# Keep this pin in sync with any local smoke tests of binary-compile.mjs.
|
||||
- uses: oven-sh/setup-bun@v2
|
||||
with:
|
||||
bun-version: "1.2.19"
|
||||
|
||||
@@ -61,3 +61,9 @@ vp check
|
||||
| FC 未跑完用户就 curl | OSS 404 / 半包 |
|
||||
| 矩阵变更未通知脚本方 | 装错 arch / 永久失败 |
|
||||
| webhook 配错当发版失败 | 不应;webhook 失败只 warn |
|
||||
| 用 `Bun.build({ compile })` 代替 CLI | Bun ≤1.2.19 可能 exit 0 但不写 outfile → `sha256` ENOENT |
|
||||
|
||||
## 编译实现注意
|
||||
|
||||
- `binary-compile.mjs` 必须走 **`bun build --compile --outfile …`**,不要用 `Bun.build({ compile })`(CI 钉 `1.2.19` 时 API 会假成功)。
|
||||
- 编译后校验 outfile 存在再算 SHA256。
|
||||
|
||||
@@ -150,8 +150,10 @@ function compileOne({ bunTarget, os, arch, exe }, version, outdir, entry) {
|
||||
);
|
||||
if (result.status !== 0) {
|
||||
process.stderr.write(result.stderr || result.stdout || "");
|
||||
throw new Error(`Bun.build compile failed for ${bunTarget}`);
|
||||
throw new Error(`Bun compile failed for ${bunTarget}`);
|
||||
}
|
||||
if (result.stdout) process.stdout.write(result.stdout);
|
||||
if (result.stderr) process.stderr.write(result.stderr);
|
||||
return { fileName, outfile, os, arch, sha256: sha256File(outfile) };
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,16 @@
|
||||
/**
|
||||
* Single-target `Bun.build({ compile })` helper. Must be run with Bun:
|
||||
* Single-target Bun compile helper. Must be run with Bun on PATH:
|
||||
* bun tools/release/lib/binary-compile.mjs --entry <path> --outfile <path> --target <bun-target>
|
||||
*
|
||||
* Uses `bun build --compile` (CLI), not `Bun.build({ compile })`.
|
||||
* Bun ≤1.2.19's Build API can report success without writing `compile.outfile`
|
||||
* (API support landed properly around 1.2.21). CLI works on the pinned CI version.
|
||||
*
|
||||
* Called by binary-build.mjs (Node orchestration stays on Node).
|
||||
*/
|
||||
import { existsSync } from "node:fs";
|
||||
import { spawnSync } from "node:child_process";
|
||||
|
||||
function parseArgs(argv) {
|
||||
let entry = null;
|
||||
let outfile = null;
|
||||
@@ -30,22 +37,33 @@ function parseArgs(argv) {
|
||||
|
||||
const { entry, outfile, target } = parseArgs(process.argv.slice(2));
|
||||
|
||||
const result = await Bun.build({
|
||||
entrypoints: [entry],
|
||||
// Bundler defaults to "browser"; CLI needs Node/Bun builtins.
|
||||
target: "bun",
|
||||
define: {
|
||||
"process.env.BAILIAN_COMPILED": JSON.stringify("1"),
|
||||
},
|
||||
compile: {
|
||||
target,
|
||||
const result = spawnSync(
|
||||
"bun",
|
||||
[
|
||||
"build",
|
||||
entry,
|
||||
"--compile",
|
||||
"--outfile",
|
||||
outfile,
|
||||
},
|
||||
});
|
||||
"--target",
|
||||
target,
|
||||
"--define",
|
||||
'process.env.BAILIAN_COMPILED="1"',
|
||||
],
|
||||
{ encoding: "utf-8", stdio: ["ignore", "pipe", "pipe"] },
|
||||
);
|
||||
|
||||
if (!result.success) {
|
||||
for (const log of result.logs) {
|
||||
console.error(log);
|
||||
}
|
||||
if (result.stdout) process.stdout.write(result.stdout);
|
||||
if (result.stderr) process.stderr.write(result.stderr);
|
||||
|
||||
if (result.status !== 0) {
|
||||
process.exit(result.status ?? 1);
|
||||
}
|
||||
|
||||
if (!existsSync(outfile)) {
|
||||
console.error(
|
||||
`bun build --compile exited 0 but outfile missing: ${outfile}\n` +
|
||||
`(Bun Build API compile.outfile is unreliable on some versions; this helper uses the CLI.)`,
|
||||
);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user