fix(changelog): filter non-app releases

This commit is contained in:
t8y2
2026-07-24 09:55:48 +08:00
parent 1870be4a81
commit 562edef4dc
6 changed files with 110 additions and 6 deletions
+8 -2
View File
@@ -13,6 +13,7 @@ const OUT_EN = "releases-en.json";
const LATEST_EN_OUT = "latest-en.json";
const LATEST_NOTES_OUT = "latest-notes.json";
const EN_CACHE_URL = process.env.CHANGELOG_EN_CACHE_URL || "https://dl.dbxio.com/changelog/releases-en.json";
const APP_RELEASE_TAG_PATTERN = /^v[0-9]+[.][0-9]+[.][0-9]+(?:[.-][0-9A-Za-z.-]+)?$/;
const SECTION_MAP = {
新功能: "added",
@@ -121,11 +122,16 @@ export function buildReleaseSourceHash(release) {
.digest("hex");
}
export function isAppRelease(release) {
return !release.draft && !release.prerelease && APP_RELEASE_TAG_PATTERN.test(release.tag_name || "");
}
export function buildReleasesJson(releases, now = new Date()) {
return {
updatedAt: now.toISOString(),
releases: releases
.filter((r) => !r.draft && !r.prerelease && !r.tag_name.startsWith("agents-"))
// This repository has independent app, agent, and package release streams.
.filter(isAppRelease)
.sort((a, b) => new Date(b.published_at) - new Date(a.published_at))
.map((r) => ({
tag: r.tag_name,
@@ -159,7 +165,7 @@ function buildLatestEnNotes(enReleasesJson) {
export function buildLatestReleaseNotes(releases) {
const latest = releases
.filter((release) => !release.draft && !release.prerelease && !release.tag_name.startsWith("agents-"))
.filter(isAppRelease)
.sort((a, b) => new Date(b.published_at) - new Date(a.published_at))[0];
if (!latest) return null;
return { version: latest.tag_name, notes: latest.body || "" };
+36 -1
View File
@@ -1,7 +1,7 @@
import assert from "node:assert/strict";
import test from "node:test";
import { buildLatestReleaseNotes } from "./sync-changelog.mjs";
import { buildLatestReleaseNotes, buildReleasesJson } from "./sync-changelog.mjs";
test("buildLatestReleaseNotes returns the curated latest release body", () => {
const result = buildLatestReleaseNotes([
@@ -26,3 +26,38 @@ test("buildLatestReleaseNotes returns the curated latest release body", () => {
notes: "### 新功能\n- new\n\n### 下载安装\n- assets",
});
});
test("changelog excludes agent and package release streams", () => {
const releases = [
{
tag_name: "packages-v0.4.42",
draft: false,
prerelease: false,
published_at: "2026-07-23T02:00:00Z",
body: "### Changed\n- packages",
},
{
tag_name: "agents-v0.2.64",
draft: false,
prerelease: false,
published_at: "2026-07-23T01:00:00Z",
body: "### Changed\n- agents",
},
{
tag_name: "v0.5.66",
draft: false,
prerelease: false,
published_at: "2026-07-23T00:00:00Z",
body: "### Changed\n- app",
},
];
assert.deepEqual(
buildReleasesJson(releases, new Date("2026-07-24T00:00:00Z")).releases.map((release) => release.tag),
["v0.5.66"],
);
assert.deepEqual(buildLatestReleaseNotes(releases), {
version: "v0.5.66",
notes: "### Changed\n- app",
});
});