📝 (release): 加更新日志,Release 说明取自 CHANGELOG.md,去掉 RELEASE_TOKEN 要求
Co-authored-by: Copilot <[email protected]>
This commit is contained in:
1 parent
cc00c43b4c
commit
2004114672
3 files changed
+27
-4
No files matched your search
@@ -1,7 +1,8 @@
|
||||
name: Release
|
||||
|
||||
# 推送 vX.Y.Z(或 vX.Y.Z-rc.1 等预发布)标签:打包本仓库的插件为 zip → 建 Release 并上传。
|
||||
# 需要在仓库「设置 → Actions → 密钥」里加 RELEASE_TOKEN:Codeberg 个人访问令牌,勾 write:repository。
|
||||
# 更新日志取自 CHANGELOG.md 里 "## <版本号>" 这一节,作为 Release 说明(月读的更新弹窗也会显示)。
|
||||
# 令牌默认用内置 GITHUB_TOKEN;需要时可在仓库密钥里配 RELEASE_TOKEN 覆盖。
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
@@ -46,9 +47,10 @@ jobs:
|
||||
TOKEN: ${{ secrets.RELEASE_TOKEN || secrets.GITHUB_TOKEN }}
|
||||
TAG: ${{ steps.ver.outputs.tag }}
|
||||
PRERELEASE: ${{ steps.ver.outputs.prerelease }}
|
||||
VERSION: ${{ steps.ver.outputs.version }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
: "${TOKEN:?没有可用令牌:请配置仓库密钥 RELEASE_TOKEN}"
|
||||
: "${TOKEN:?没有可用令牌:没有内置令牌,也没有配置 RELEASE_TOKEN}"
|
||||
API="${GITHUB_SERVER_URL}/api/v1/repos/${GITHUB_REPOSITORY}"
|
||||
AUTH="Authorization: token ${TOKEN}"
|
||||
|
||||
@@ -56,7 +58,21 @@ jobs:
|
||||
OLD=$(curl -fsS -H "$AUTH" "${API}/releases/tags/${TAG}" 2>/dev/null | node -e 'let s="";process.stdin.on("data",d=>s+=d).on("end",()=>{try{console.log(JSON.parse(s).id||"")}catch(e){}})' || true)
|
||||
[ -n "$OLD" ] && curl -fsS -X DELETE -H "$AUTH" "${API}/releases/${OLD}"
|
||||
|
||||
BODY=$(node -e 'console.log(JSON.stringify({tag_name:process.env.TAG,name:process.env.TAG,prerelease:process.env.PRERELEASE==="true",body:"给月读增加在线平台书源的 KOReader 插件。把 zip 解压到 KOReader 的 plugins/ 目录即可。附件 SHA256SUMS 用于校验。\n\n与各平台官方无关,使用风险自行承担。"}))')
|
||||
BODY=$(node -e '
|
||||
const fs = require("fs");
|
||||
let notes = "";
|
||||
try {
|
||||
const lines = fs.readFileSync("CHANGELOG.md", "utf8").split(/\r?\n/);
|
||||
const start = lines.findIndex(l => l.trim() === "## " + process.env.VERSION);
|
||||
if (start >= 0) {
|
||||
let end = lines.findIndex((l, i) => i > start && /^## /.test(l));
|
||||
if (end < 0) end = lines.length;
|
||||
notes = lines.slice(start + 1, end).join("\n").trim();
|
||||
}
|
||||
} catch (e) {}
|
||||
const tail = "给月读增加在线平台书源的 KOReader 插件。把 zip 解压到 KOReader 的 plugins/ 目录即可,附件 SHA256SUMS 用于校验。与各平台官方无关,使用风险自行承担。";
|
||||
console.log(JSON.stringify({tag_name:process.env.TAG,name:process.env.TAG,prerelease:process.env.PRERELEASE==="true",body:notes?notes+"\n\n---\n"+tail:tail}));
|
||||
')
|
||||
ID=$(curl -fsS -X POST -H "$AUTH" -H "Content-Type: application/json" -d "$BODY" "${API}/releases" \
|
||||
| node -e 'let s="";process.stdin.on("data",d=>s+=d).on("end",()=>console.log(JSON.parse(s).id))')
|
||||
|
||||
|
||||
Reference in new issue
Block a user