Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:construction_worker: Trim the changelog during packaging (#17987)

Jeffrey Chend1bcef2d12dc
diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml
index 0b22b396d9..a28becec0c 100644
--- a/.github/workflows/cd.yml
+++ b/.github/workflows/cd.yml
@@ -331,7 +331,8 @@ jobs:
cp ${{ github.workspace }}/go/src/github.com/${{ github.repository }}/kernel/kernel.aar \
${{ github.workspace }}/siyuan-android/app/libs/kernel.aar
cd ${{ github.workspace }}/go/src/github.com/${{ github.repository }}/app
- zip -r app.zip appearance guide stage changelogs
+ node scripts/trimChangelogs.js
+ zip -r app.zip appearance guide stage $([ -d changelogs ] && echo changelogs)
mkdir -p ${{ github.workspace }}/siyuan-android/app/src/main/assets
cp app.zip ${{ github.workspace }}/siyuan-android/app/src/main/assets/app.zip
diff --git a/Dockerfile b/Dockerfile
index 817f556943..55d4407d61 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -19,7 +19,8 @@ RUN <<EORUN
pnpm run build
node scripts/trimChangelogs.js
mkdir /artifacts
-mv appearance stage guide changelogs /artifacts/
+mv appearance stage guide /artifacts/
+if [ -d changelogs ]; then mv changelogs /artifacts/; fi
EORUN
FROM golang:1.25-alpine AS go-build
diff --git a/app/scripts/afterPack.js b/app/scripts/afterPack.js
index 80c379328f..b6bd723f1b 100644
--- a/app/scripts/afterPack.js
+++ b/app/scripts/afterPack.js
@@ -24,7 +24,9 @@ async function trimPackagedChangelogs(appOutDir, packager, platform) {
console.error(`trimChangelogs: ${result.reason}`);
return;
}
- console.log(`trimChangelogs: ${result.path}`);
+ if (result.path) {
+ console.log(`trimChangelogs: ${result.path}`);
+ }
} catch (error) {
console.error("Failed to trim changelogs:", error.message);
}
diff --git a/app/scripts/trimChangelogs.js b/app/scripts/trimChangelogs.js
index a95d82c954..4cd4d27306 100644
--- a/app/scripts/trimChangelogs.js
+++ b/app/scripts/trimChangelogs.js
@@ -1,12 +1,25 @@
const fsPromises = require("fs").promises;
const path = require("path");
-// 裁剪 changelog,只保留顶层 changelogs/v{version}/。
+// 裁剪 changelog,只保留顶层 changelogs/v{version}/;预发布版删除整个 changelogs 目录。
// 版本号须与 package.json、kernel/util/working.go 的 Ver 一致(内核按此路径读取)。
async function trimChangelogs(changelogsDir, version) {
+ let exists = true;
try {
await fsPromises.access(changelogsDir);
} catch {
+ exists = false;
+ }
+
+ if (version.includes("-")) {
+ // 预发布版
+ if (exists) {
+ await fsPromises.rm(changelogsDir, {recursive: true, force: true});
+ }
+ return {ok: true};
+ }
+
+ if (!exists) {
return {ok: false, reason: "directory not found"};
}
@@ -48,7 +61,9 @@ if (require.main === module) {
console.error(`trimChangelogs: ${result.reason}`);
return;
}
- console.log(`trimChangelogs: ${result.path}`);
+ if (result.path) {
+ console.log(`trimChangelogs: ${result.path}`);
+ }
}).catch((error) => {
console.error("trimChangelogs failed:", error.message);
});