Skip to content

Commit bc0b99c

Browse files
authored
0.4.1 (#17)
* sync version * 0.4.1 * add release script
1 parent a0802b1 commit bc0b99c

4 files changed

Lines changed: 54 additions & 8 deletions

File tree

cli/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cli/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "agent-browser"
3-
version = "0.4.0"
3+
version = "0.4.1"
44
edition = "2021"
55
description = "Fast browser automation CLI for AI agents"
66
license = "Apache-2.0"

package.json

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "agent-browser",
3-
"version": "0.4.0",
3+
"version": "0.4.1",
44
"description": "Headless browser automation CLI for AI agents",
55
"type": "module",
66
"main": "dist/daemon.js",
@@ -15,13 +15,16 @@
1515
},
1616
"scripts": {
1717
"prepare": "husky",
18+
"version:sync": "node scripts/sync-version.js",
19+
"version": "npm run version:sync && git add cli/Cargo.toml",
1820
"build": "tsc",
19-
"build:native": "cargo build --release --manifest-path cli/Cargo.toml && node scripts/copy-native.js",
20-
"build:linux": "docker compose -f docker/docker-compose.yml run --rm build-linux",
21-
"build:macos": "(cargo build --release --manifest-path cli/Cargo.toml --target aarch64-apple-darwin & cargo build --release --manifest-path cli/Cargo.toml --target x86_64-apple-darwin & wait) && cp cli/target/aarch64-apple-darwin/release/agent-browser bin/agent-browser-darwin-arm64 && cp cli/target/x86_64-apple-darwin/release/agent-browser bin/agent-browser-darwin-x64",
22-
"build:windows": "docker compose -f docker/docker-compose.yml run --rm build-windows",
23-
"build:all-platforms": "(npm run build:linux & npm run build:windows & wait) && npm run build:macos",
21+
"build:native": "npm run version:sync && cargo build --release --manifest-path cli/Cargo.toml && node scripts/copy-native.js",
22+
"build:linux": "npm run version:sync && docker compose -f docker/docker-compose.yml run --rm build-linux",
23+
"build:macos": "npm run version:sync && (cargo build --release --manifest-path cli/Cargo.toml --target aarch64-apple-darwin & cargo build --release --manifest-path cli/Cargo.toml --target x86_64-apple-darwin & wait) && cp cli/target/aarch64-apple-darwin/release/agent-browser bin/agent-browser-darwin-arm64 && cp cli/target/x86_64-apple-darwin/release/agent-browser bin/agent-browser-darwin-x64",
24+
"build:windows": "npm run version:sync && docker compose -f docker/docker-compose.yml run --rm build-windows",
25+
"build:all-platforms": "npm run version:sync && (npm run build:linux & npm run build:windows & wait) && npm run build:macos",
2426
"build:docker": "docker build -t agent-browser-builder -f docker/Dockerfile.build .",
27+
"release": "npm run version:sync && npm run build && npm run build:all-platforms && npm publish",
2528
"start": "node dist/daemon.js",
2629
"dev": "tsx src/daemon.ts",
2730
"typecheck": "tsc --noEmit",

scripts/sync-version.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/usr/bin/env node
2+
3+
/**
4+
* Syncs the version from package.json to all other config files.
5+
* Run this script before building or releasing.
6+
*/
7+
8+
import { readFileSync, writeFileSync } from "fs";
9+
import { dirname, join } from "path";
10+
import { fileURLToPath } from "url";
11+
12+
const __dirname = dirname(fileURLToPath(import.meta.url));
13+
const rootDir = join(__dirname, "..");
14+
15+
// Read version from package.json (single source of truth)
16+
const packageJson = JSON.parse(
17+
readFileSync(join(rootDir, "package.json"), "utf-8")
18+
);
19+
const version = packageJson.version;
20+
21+
console.log(`Syncing version ${version} to all config files...`);
22+
23+
// Update Cargo.toml
24+
const cargoTomlPath = join(rootDir, "cli/Cargo.toml");
25+
let cargoToml = readFileSync(cargoTomlPath, "utf-8");
26+
const cargoVersionRegex = /^version\s*=\s*"[^"]*"/m;
27+
const newCargoVersion = `version = "${version}"`;
28+
29+
if (cargoVersionRegex.test(cargoToml)) {
30+
const oldMatch = cargoToml.match(cargoVersionRegex)?.[0];
31+
if (oldMatch !== newCargoVersion) {
32+
cargoToml = cargoToml.replace(cargoVersionRegex, newCargoVersion);
33+
writeFileSync(cargoTomlPath, cargoToml);
34+
console.log(` Updated cli/Cargo.toml: ${oldMatch} -> ${newCargoVersion}`);
35+
} else {
36+
console.log(` cli/Cargo.toml already up to date`);
37+
}
38+
} else {
39+
console.error(" Could not find version field in cli/Cargo.toml");
40+
process.exit(1);
41+
}
42+
43+
console.log("Version sync complete.");

0 commit comments

Comments
 (0)