fix(updater): sync release notes across update sources

This commit is contained in:
t8y2
2026-07-22 11:17:29 +08:00
parent 68e7169f1d
commit 1b399a58d0
11 changed files with 190 additions and 17 deletions
+15
View File
@@ -11,6 +11,7 @@ const DEEPSEEK_API_KEY = process.env.DEEPSEEK_API_KEY || "";
const OUT_CN = "releases-cn.json";
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 SECTION_MAP = {
@@ -156,6 +157,14 @@ function buildLatestEnNotes(enReleasesJson) {
};
}
export function buildLatestReleaseNotes(releases) {
const latest = releases
.filter((release) => !release.draft && !release.prerelease && !release.tag_name.startsWith("agents-"))
.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 || "" };
}
export async function fetchCachedEnglish({ cacheUrl = EN_CACHE_URL, fetchImpl = fetch } = {}) {
try {
const res = await fetchImpl(cacheUrl, { headers: { Accept: "application/json" } });
@@ -262,6 +271,12 @@ async function main() {
writeFileSync(OUT_CN, JSON.stringify(cnJson, null, 2));
console.log(`Wrote ${OUT_CN}`);
const latestNotes = buildLatestReleaseNotes(releases);
if (latestNotes) {
writeFileSync(LATEST_NOTES_OUT, JSON.stringify(latestNotes, null, 2));
console.log(`Wrote ${LATEST_NOTES_OUT}`);
}
console.log("Fetching cached English changelog...");
const cachedEnJson = await fetchCachedEnglish();
+28
View File
@@ -0,0 +1,28 @@
import assert from "node:assert/strict";
import test from "node:test";
import { buildLatestReleaseNotes } from "./sync-changelog.mjs";
test("buildLatestReleaseNotes returns the curated latest release body", () => {
const result = buildLatestReleaseNotes([
{
tag_name: "v0.5.62",
draft: false,
prerelease: false,
published_at: "2026-07-20T00:00:00Z",
body: "### 新功能\n- old\n\n### 下载安装\n- assets",
},
{
tag_name: "v0.5.63",
draft: false,
prerelease: false,
published_at: "2026-07-21T00:00:00Z",
body: "### 新功能\n- new\n\n### 下载安装\n- assets",
},
]);
assert.deepEqual(result, {
version: "v0.5.63",
notes: "### 新功能\n- new\n\n### 下载安装\n- assets",
});
});