feat(release): show agent version changes
This commit is contained in:
@@ -14,14 +14,18 @@ function bumpPatchVersion(version) {
|
||||
|
||||
function pathChanged(changedFiles, pathPrefix) {
|
||||
const normalized = pathPrefix.endsWith("/") ? pathPrefix : `${pathPrefix}/`;
|
||||
return changedFiles.some((file) => file === pathPrefix || file.startsWith(normalized));
|
||||
return changedFiles.some((file) => (file === pathPrefix || file.startsWith(normalized)) && isAgentPublishRelevantFile(file));
|
||||
}
|
||||
|
||||
export function isAgentPublishRelevantFile(file) {
|
||||
return !file.endsWith("_test.go") && !file.includes("/src/test/") && !file.includes("/bench/");
|
||||
}
|
||||
|
||||
function isCommonRuntimeChange(file) {
|
||||
return file === "agents/common/build.gradle" || file.startsWith("agents/common/src/main/");
|
||||
}
|
||||
|
||||
function parseLegacyStandaloneProjects(buildGradle) {
|
||||
export function parseLegacyStandaloneProjects(buildGradle) {
|
||||
const match = /legacyStandaloneProjects\s*=\s*\[([^\]]*)\]/m.exec(buildGradle);
|
||||
if (!match) return new Set();
|
||||
|
||||
@@ -128,6 +132,16 @@ export function evaluateAgentVersionBump({
|
||||
return { changed, versions: nextVersions, prevVersions, logs };
|
||||
}
|
||||
|
||||
export function getAgentVersionChanges(previousVersions, nextVersions) {
|
||||
return Object.keys(nextVersions)
|
||||
.filter((moduleName) => nextVersions[moduleName] !== previousVersions[moduleName])
|
||||
.map((moduleName) => ({
|
||||
moduleName,
|
||||
previousVersion: previousVersions[moduleName] ?? null,
|
||||
nextVersion: nextVersions[moduleName],
|
||||
}));
|
||||
}
|
||||
|
||||
function git(args) {
|
||||
return execFileSync("git", args, { encoding: "utf8" }).trim();
|
||||
}
|
||||
|
||||
+29
-1
@@ -3,7 +3,7 @@ import { readFileSync } from "node:fs";
|
||||
import { resolve } from "node:path";
|
||||
import { test } from "vitest";
|
||||
|
||||
const { evaluateAgentVersionBump } = await importScript(".github/scripts/bump-agent-versions.mjs");
|
||||
const { evaluateAgentVersionBump, getAgentVersionChanges } = await importScript(".github/scripts/bump-agent-versions.mjs");
|
||||
|
||||
function importScript(path: string): Promise<Record<string, any>> {
|
||||
const source = readFileSync(resolve(path), "utf8").replace(/^#!.*\r?\n/, "");
|
||||
@@ -101,6 +101,31 @@ test("native agent source changes still bump native module versions", () => {
|
||||
});
|
||||
});
|
||||
|
||||
test("native agent tests and benchmarks do not bump module versions", () => {
|
||||
const fixture = moduleFixture([
|
||||
"agents/drivers/kingbase-go",
|
||||
"agents/drivers/xugu",
|
||||
]);
|
||||
|
||||
const result = evaluateAgentVersionBump({
|
||||
versions: {
|
||||
kingbase: "0.1.34",
|
||||
xugu: "0.1.21",
|
||||
},
|
||||
changedFiles: [
|
||||
"agents/drivers/kingbase-go/main_test.go",
|
||||
"agents/drivers/xugu/bench/compare.go",
|
||||
],
|
||||
...fixture,
|
||||
});
|
||||
|
||||
assert.equal(result.changed, false);
|
||||
assert.deepEqual(result.versions, {
|
||||
kingbase: "0.1.34",
|
||||
xugu: "0.1.21",
|
||||
});
|
||||
});
|
||||
|
||||
test("Kingbase native Go source changes bump the Kingbase module version", () => {
|
||||
const fixture = moduleFixture([
|
||||
"agents/drivers/kingbase",
|
||||
@@ -120,6 +145,9 @@ test("Kingbase native Go source changes bump the Kingbase module version", () =>
|
||||
assert.deepEqual(result.versions, {
|
||||
kingbase: "0.1.35",
|
||||
});
|
||||
assert.deepEqual(getAgentVersionChanges(result.prevVersions, result.versions), [
|
||||
{ moduleName: "kingbase", previousVersion: "0.1.34", nextVersion: "0.1.35" },
|
||||
]);
|
||||
});
|
||||
|
||||
test("manual agent versions are preserved while other changed modules auto bump", () => {
|
||||
|
||||
+30
-1
@@ -2,6 +2,7 @@ import { spawnSync } from "node:child_process";
|
||||
import { readFileSync } from "node:fs";
|
||||
import { createInterface } from "node:readline/promises";
|
||||
import { stdin as input, stdout as output } from "node:process";
|
||||
import { evaluateAgentVersionBump, getAgentVersionChanges, isAgentPublishRelevantFile, parseLegacyStandaloneProjects } from "../.github/scripts/bump-agent-versions.mjs";
|
||||
|
||||
const REPO = "t8y2/dbx";
|
||||
const PACKAGES_WORKFLOW = "mcp-release.yml";
|
||||
@@ -175,6 +176,7 @@ async function releaseAgents(bump) {
|
||||
console.log(kv("Release target", "Agents", bold));
|
||||
console.log(kv("Current agent tag", `${latest.tag}${latest.source ? ` (${latest.source})` : ""}`, yellow));
|
||||
printReleaseStatus(status);
|
||||
printAgentVersionChanges(latest.tag, status.changedFiles);
|
||||
if (!status.needed && !force) {
|
||||
console.log(yellow("No agents release needed; publish-relevant agent runtime files have not changed."));
|
||||
console.log(dim("Use --force to create the tag anyway."));
|
||||
@@ -348,7 +350,7 @@ function getAgentReleaseStatus(latest = getLatestAgentTag()) {
|
||||
};
|
||||
}
|
||||
|
||||
const changedFiles = getChangedFilesSince(latest.tag, AGENT_RELEASE_PATHS);
|
||||
const changedFiles = getChangedFilesSince(latest.tag, AGENT_RELEASE_PATHS).filter(isAgentPublishRelevantFile);
|
||||
return {
|
||||
needed: changedFiles.length > 0,
|
||||
baseline: latest.tag,
|
||||
@@ -387,6 +389,33 @@ function printReleaseStatus(status) {
|
||||
}
|
||||
}
|
||||
|
||||
function printAgentVersionChanges(baselineTag, changedFiles) {
|
||||
if (changedFiles.length === 0 || !refExists(`refs/tags/${baselineTag}`)) return;
|
||||
|
||||
const currentVersions = JSON.parse(readFileSync("agents/versions.json", "utf8"));
|
||||
const previousVersions = JSON.parse(run("git", ["show", `${baselineTag}:agents/versions.json`]).stdout);
|
||||
const legacyStandaloneModules = parseLegacyStandaloneProjects(readFileSync("agents/build.gradle", "utf8"));
|
||||
const result = evaluateAgentVersionBump({
|
||||
versions: currentVersions,
|
||||
prevVersions: previousVersions,
|
||||
changedFiles,
|
||||
legacyStandaloneModules,
|
||||
manualVersionsChanged: changedFiles.includes("agents/versions.json"),
|
||||
});
|
||||
const changes = getAgentVersionChanges(previousVersions, result.versions)
|
||||
.map(({ moduleName, previousVersion, nextVersion }) => `${moduleName}: ${previousVersion ?? "new"} -> ${nextVersion}`);
|
||||
|
||||
if (changes.length === 0) {
|
||||
console.log(dim("No automatic driver version changes detected."));
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(dim("Expected driver version changes:"));
|
||||
for (const change of changes) {
|
||||
console.log(` ${dim("-")} ${change}`);
|
||||
}
|
||||
}
|
||||
|
||||
function formatStatusSummary(status) {
|
||||
if (status.needed) {
|
||||
const detail = status.changedFiles.length > 0 ? `${status.changedFiles.length} changed file${status.changedFiles.length === 1 ? "" : "s"}` : "release baseline missing";
|
||||
|
||||
Reference in New Issue
Block a user