2024-09-16 19:50:53 -04:00
|
|
|
const V8_TRACKING_BRANCH = "13.0-lkgr-denoland";
|
2022-09-18 17:50:11 -04:00
|
|
|
const AUTOROLL_BRANCH = "autoroll";
|
2021-04-26 07:05:18 -04:00
|
|
|
|
|
|
|
function extractVersion() {
|
|
|
|
const MAJOR_PREFIX = "#define V8_MAJOR_VERSION ";
|
|
|
|
const MINOR_PREFIX = "#define V8_MINOR_VERSION ";
|
|
|
|
const BUILD_PREFIX = "#define V8_BUILD_NUMBER ";
|
|
|
|
const PATCH_PREFIX = "#define V8_PATCH_LEVEL ";
|
|
|
|
|
|
|
|
const versionDotH = Deno.readTextFileSync("./v8/include/v8-version.h");
|
|
|
|
const lines = versionDotH.split("\n");
|
|
|
|
const major = parseInt(lines.find((s) => s.startsWith(MAJOR_PREFIX))!
|
|
|
|
.substring(MAJOR_PREFIX.length));
|
|
|
|
const minor = parseInt(lines.find((s) => s.startsWith(MINOR_PREFIX))!
|
|
|
|
.substring(MINOR_PREFIX.length));
|
|
|
|
const build = parseInt(lines.find((s) => s.startsWith(BUILD_PREFIX))!
|
|
|
|
.substring(BUILD_PREFIX.length));
|
|
|
|
const patch = parseInt(lines.find((s) => s.startsWith(PATCH_PREFIX))!
|
|
|
|
.substring(PATCH_PREFIX.length));
|
|
|
|
|
|
|
|
return `${major}.${minor}.${build}.${patch}`;
|
|
|
|
}
|
|
|
|
|
2023-05-03 17:05:07 -04:00
|
|
|
await run("git", ["checkout", "origin/main"]);
|
|
|
|
await run("git", ["submodule", "update", "--init", "--recursive", "v8"]);
|
2021-04-26 07:05:18 -04:00
|
|
|
|
|
|
|
const currentVersion = extractVersion();
|
|
|
|
console.log(`Starting auto update. Currently on ${currentVersion}`);
|
|
|
|
|
2023-05-03 17:05:07 -04:00
|
|
|
async function run(cmd: string, args: string[], cwd?: string) {
|
|
|
|
console.log("$", cmd, ...args);
|
|
|
|
const proc = new Deno.Command(cmd, { args, cwd });
|
|
|
|
const status = await proc.output();
|
2021-04-26 07:05:18 -04:00
|
|
|
if (!status.success) {
|
2023-05-03 17:05:07 -04:00
|
|
|
console.error(`Failed to run ${cmd} ${args.join(" ")}`);
|
2021-04-26 07:05:18 -04:00
|
|
|
Deno.exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Update v8 submodule
|
2023-05-03 17:05:07 -04:00
|
|
|
await run("git", ["fetch", `origin`, V8_TRACKING_BRANCH], "./v8");
|
|
|
|
await run("git", ["checkout", `origin/${V8_TRACKING_BRANCH}`], "./v8");
|
2021-04-26 07:05:18 -04:00
|
|
|
|
|
|
|
const newVersion = extractVersion();
|
|
|
|
if (currentVersion == newVersion) {
|
|
|
|
console.log(`No new version available. Staying on ${newVersion}`);
|
|
|
|
Deno.exit(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
console.log(`Updated to version ${newVersion}`);
|
|
|
|
|
|
|
|
// Update version in readme
|
|
|
|
let readme = Deno.readTextFileSync("README.md");
|
|
|
|
readme = readme.replace(
|
2022-08-27 12:44:12 -04:00
|
|
|
/V8 Version: \S+/,
|
2021-04-26 07:05:18 -04:00
|
|
|
`V8 Version: ${newVersion}`,
|
|
|
|
);
|
|
|
|
Deno.writeTextFileSync("README.md", readme);
|
|
|
|
|
|
|
|
// Stage the changes
|
2023-05-03 17:05:07 -04:00
|
|
|
await run("git", ["add", "v8", "README.md"]);
|
2021-04-26 07:05:18 -04:00
|
|
|
|
|
|
|
// Commit the changes
|
2023-05-03 17:05:07 -04:00
|
|
|
await run("git", ["commit", "-m", `Rolling to V8 ${newVersion}`]);
|
2021-04-26 07:05:18 -04:00
|
|
|
|
|
|
|
// Push to the `denoland/rusty_v8#autoroll`
|
2023-05-03 17:05:07 -04:00
|
|
|
await run("git", ["push", "origin", `+HEAD:refs/heads/${AUTOROLL_BRANCH}`]);
|
2021-04-27 05:02:47 -04:00
|
|
|
|
|
|
|
// Fetch the remote branch so `gh` cli can find it
|
2023-05-03 17:05:07 -04:00
|
|
|
await run("git", ["fetch", "origin", AUTOROLL_BRANCH]);
|
2021-04-26 07:05:18 -04:00
|
|
|
|
2023-05-03 17:05:07 -04:00
|
|
|
const proc = new Deno.Command("gh", {
|
|
|
|
args: ["pr", "view", AUTOROLL_BRANCH, "--json", "state"],
|
2021-04-27 05:02:47 -04:00
|
|
|
stdout: "piped",
|
2021-04-26 07:05:18 -04:00
|
|
|
});
|
2023-05-03 17:05:07 -04:00
|
|
|
const output = await proc.output();
|
|
|
|
const isPrOpen = output.success
|
|
|
|
? JSON.parse(new TextDecoder().decode(output.stdout)).state === "OPEN"
|
2021-04-27 05:02:47 -04:00
|
|
|
: false;
|
|
|
|
|
|
|
|
if (isPrOpen) {
|
|
|
|
console.log("Already open PR. Editing existing PR.");
|
2023-05-03 17:05:07 -04:00
|
|
|
await run("gh", [
|
2021-04-26 07:05:18 -04:00
|
|
|
"pr",
|
2021-04-27 05:02:47 -04:00
|
|
|
"edit",
|
2021-05-04 13:17:53 -04:00
|
|
|
AUTOROLL_BRANCH,
|
2021-04-27 05:02:47 -04:00
|
|
|
"--title",
|
|
|
|
`Rolling to V8 ${newVersion}`,
|
2021-04-26 07:05:18 -04:00
|
|
|
]);
|
|
|
|
} else {
|
2021-04-27 05:02:47 -04:00
|
|
|
console.log("No PR open. Creating a new PR.");
|
2023-05-03 17:05:07 -04:00
|
|
|
await run("gh", [
|
2021-04-26 07:05:18 -04:00
|
|
|
"pr",
|
2021-04-27 05:02:47 -04:00
|
|
|
"create",
|
2021-04-26 07:05:18 -04:00
|
|
|
"--title",
|
|
|
|
`Rolling to V8 ${newVersion}`,
|
2021-04-27 05:02:47 -04:00
|
|
|
"--body",
|
|
|
|
"",
|
|
|
|
"--head",
|
|
|
|
`denoland:${AUTOROLL_BRANCH}`,
|
2021-04-26 07:05:18 -04:00
|
|
|
]);
|
|
|
|
}
|