fix(release): pinned tiny transformers version

- Added the Transformers.js version define to release-built binaries.
- Covered the release dry-run command so Homebrew assets keep the tiny runtime pin.

Fixes #3904
This commit is contained in:
roboomp
2026-06-30 14:30:23 +00:00
parent 5bc68f57cd
commit 083d1f5a8e
3 changed files with 64 additions and 25 deletions
+26
View File
@@ -0,0 +1,26 @@
import { $ } from "bun";
import { describe, expect, it } from "bun:test";
import { createRequire } from "node:module";
import * as path from "node:path";
interface PackageManifest {
version: string;
}
const repoRoot = path.join(import.meta.dir, "..");
const transformersManifest: PackageManifest = createRequire(import.meta.url)("@huggingface/transformers/package.json");
const transformersVersion = transformersManifest.version;
describe("ci-release-build-binaries dry run", () => {
it("pins the Transformers.js runtime version in compiled release binaries", async () => {
const result = await $`bun scripts/ci-release-build-binaries.ts --dry-run --targets linux-x64`
.cwd(repoRoot)
.quiet();
const output = result.text();
expect(output).toContain('--define process.env.PI_COMPILED="true"');
expect(output).toContain(
`--define process.env.PI_TINY_TRANSFORMERS_VERSION=${JSON.stringify(transformersVersion)}`,
);
});
});
+34 -25
View File
@@ -1,4 +1,5 @@
#!/usr/bin/env bun
import { createRequire } from "node:module";
import * as fs from "node:fs/promises";
import * as path from "node:path";
@@ -11,9 +12,15 @@ interface BinaryTarget {
outfile: string;
}
interface PackageManifest {
version: string;
}
const repoRoot = path.join(import.meta.dir, "..");
const binariesDir = path.join(repoRoot, "packages", "coding-agent", "binaries");
const entrypoint = "./packages/coding-agent/src/cli.ts";
const transformersManifest: PackageManifest = createRequire(import.meta.url)("@huggingface/transformers/package.json");
const transformersVersion = transformersManifest.version;
// Worker threads spawn `new Worker(Bun.main, { argv })` — they re-enter the
// binary's own entry module — so no separate worker modules are compiled.
// Legacy pi-* extension compat surfaces are served through an in-process
@@ -107,41 +114,43 @@ async function embedNative(target: BinaryTarget): Promise<void> {
});
}
function buildCompileCommand(target: BinaryTarget): string[] {
return [
"bun",
"build",
"--compile",
"--no-compile-autoload-bunfig",
"--no-compile-autoload-dotenv",
"--no-compile-autoload-tsconfig",
"--no-compile-autoload-package-json",
"--minify-identifiers",
"--keep-names",
"--define",
'process.env.PI_COMPILED="true"',
"--define",
`process.env.PI_TINY_TRANSFORMERS_VERSION=${JSON.stringify(transformersVersion)}`,
"--root",
".",
"--target",
target.target,
entrypoint,
"--outfile",
target.outfile,
];
}
async function buildBinary(target: BinaryTarget): Promise<void> {
console.log(`Building ${target.outfile}...`);
await embedNative(target);
if (isDryRun) {
console.log(`DRY RUN bun build --compile --no-compile-autoload-bunfig --no-compile-autoload-dotenv --no-compile-autoload-tsconfig --no-compile-autoload-package-json --minify-identifiers --keep-names --define process.env.PI_COMPILED="true" --root . --target=${target.target} ${entrypoint} --outfile ${target.outfile}`);
console.log(`DRY RUN ${buildCompileCommand(target).join(" ")}`);
return;
}
const buildEnv = shouldAdhocSignDarwinBinary(target)
? { ...Bun.env, BUN_NO_CODESIGN_MACHO_BINARY: "1" }
: Bun.env;
await runCommand(
[
"bun",
"build",
"--compile",
"--no-compile-autoload-bunfig",
"--no-compile-autoload-dotenv",
"--no-compile-autoload-tsconfig",
"--no-compile-autoload-package-json",
"--minify-identifiers",
"--keep-names",
"--define",
'process.env.PI_COMPILED="true"',
"--root",
".",
"--target",
target.target,
entrypoint,
"--outfile",
target.outfile,
],
repoRoot,
buildEnv,
);
await runCommand(buildCompileCommand(target), repoRoot, buildEnv);
// Bun 1.3.12 emits a truncated Mach-O signature on darwin builds.
if (shouldAdhocSignDarwinBinary(target)) {