docs(ci): 优化发布流程,自动提取版本更新日志作为release body

修改了release.yml工作流,新增步骤从CHANGELOG.md提取当前tag对应版本的更新内容,替代固定的release提示文本,同时给两个版本条目添加了新版本发布提示
This commit is contained in:
Yuhang Wu 2026-08-24 17:42:02 +08:00
parent f4ad3a5195
commit 0242f14aaa
2 changed files with 39 additions and 2 deletions

View File

@ -61,7 +61,42 @@ jobs:
- name: Install frontend dependencies - name: Install frontend dependencies
run: pnpm install --frozen-lockfile run: pnpm install --frozen-lockfile
# 7. 构建并发布(核心步骤) # 7. 从 docs/CHANGELOG.md 提取当前 tag 对应版本的更新日志
- name: Extract changelog for release
id: changelog
shell: bash
env:
RELEASE_TAG: ${{ github.ref_name }}
run: |
node -e '
const fs = require("fs");
const content = fs.readFileSync("docs/CHANGELOG.md", "utf8");
const lines = content.split(/\r?\n/);
const marker = "## " + process.env.RELEASE_TAG;
const startIdx = lines.findIndex((l) => l.trim().startsWith(marker));
if (startIdx === -1) {
fs.writeFileSync("release_body.md", "");
process.exit(0);
}
let endIdx = lines.length;
for (let i = startIdx + 1; i < lines.length; i++) {
if (/^##\s/.test(lines[i])) {
endIdx = i;
break;
}
}
fs.writeFileSync(
"release_body.md",
lines.slice(startIdx + 1, endIdx).join("\n").trim()
);
'
{
echo "body<<CHANGELOG_BODY_EOF"
cat release_body.md
echo "CHANGELOG_BODY_EOF"
} >> "$GITHUB_OUTPUT"
# 8. 构建并发布(核心步骤)
- name: Build app & publish release - name: Build app & publish release
uses: tauri-apps/tauri-action@v0 uses: tauri-apps/tauri-action@v0
env: env:
@ -71,7 +106,7 @@ jobs:
with: with:
tagName: v__VERSION__ # 自动替换为 tauri.conf.json 里的版本号 tagName: v__VERSION__ # 自动替换为 tauri.conf.json 里的版本号
releaseName: "StealthReader v__VERSION__" releaseName: "StealthReader v__VERSION__"
releaseBody: "See the assets to download and install." releaseBody: ${{ steps.changelog.outputs.body }}
releaseDraft: true # 先创建草稿,手动确认后再发布 releaseDraft: true # 先创建草稿,手动确认后再发布
prerelease: false prerelease: false
args: ${{ matrix.args }} args: ${{ matrix.args }}

View File

@ -5,6 +5,7 @@
--- ---
## v0.3.02026-08-24 16:52 ## v0.3.02026-08-24 16:52
### 🎉 新版本发布!
### ✨ 新增功能 ### ✨ 新增功能
@ -28,6 +29,7 @@
--- ---
## v0.2.02026-08-24 14:00 ## v0.2.02026-08-24 14:00
### 🎉 新版本发布!
### ✨ 新增功能 ### ✨ 新增功能