🚚 (split): 从 moon-source 拆出独立仓库,更新只管本插件
书源插件自成仓库、独立发版;update.lua 改为只检查并更新本插件(仓库 GarfieldMoon/moonsource-qimao), 打包、测试脚本与发布流程改为单插件,跨书源的测试按插件拆开。公共文件见 moonsource-template。 Co-authored-by: Copilot <[email protected]>
This commit is contained in:
1 parent
3199a28919
commit
f75457f178
8 files changed
+996
-110
No files matched your search
@@ -0,0 +1,67 @@
|
||||
name: Release
|
||||
|
||||
# 推送 vX.Y.Z(或 vX.Y.Z-rc.1 等预发布)标签:打包本仓库的插件为 zip → 建 Release 并上传。
|
||||
# 需要在仓库「设置 → Actions → 密钥」里加 RELEASE_TOKEN:Codeberg 个人访问令牌,勾 write:repository。
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- "v*"
|
||||
|
||||
jobs:
|
||||
release:
|
||||
runs-on: codeberg-tiny
|
||||
container:
|
||||
image: node:22-bookworm
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Resolve version
|
||||
id: ver
|
||||
run: |
|
||||
set -euo pipefail
|
||||
TAG="${GITHUB_REF_NAME}"
|
||||
VERSION="${TAG#v}"
|
||||
if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+([.+-].*)?$ ]]; then
|
||||
echo "标签不合法:${TAG}(应为 vMAJOR.MINOR.PATCH)"
|
||||
exit 1
|
||||
fi
|
||||
PRERELEASE=false
|
||||
[[ "$VERSION" == *-* ]] && PRERELEASE=true
|
||||
{
|
||||
echo "tag=${TAG}"
|
||||
echo "version=${VERSION}"
|
||||
echo "prerelease=${PRERELEASE}"
|
||||
} >> "$GITHUB_OUTPUT"
|
||||
shell: bash
|
||||
|
||||
- name: Install packaging tools
|
||||
run: apt-get update && apt-get install -y -o Acquire::Retries=3 rsync zip
|
||||
|
||||
- name: Package plugin
|
||||
run: tools/package.sh "${{ steps.ver.outputs.version }}" dist
|
||||
|
||||
- name: Create release and upload assets
|
||||
env:
|
||||
TOKEN: ${{ secrets.RELEASE_TOKEN || secrets.GITHUB_TOKEN }}
|
||||
TAG: ${{ steps.ver.outputs.tag }}
|
||||
PRERELEASE: ${{ steps.ver.outputs.prerelease }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
: "${TOKEN:?没有可用令牌:请配置仓库密钥 RELEASE_TOKEN}"
|
||||
API="${GITHUB_SERVER_URL}/api/v1/repos/${GITHUB_REPOSITORY}"
|
||||
AUTH="Authorization: token ${TOKEN}"
|
||||
|
||||
# 同一标签重跑:删掉旧 Release 再建,附件不会重复
|
||||
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与各平台官方无关,使用风险自行承担。"}))')
|
||||
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))')
|
||||
|
||||
for f in dist/*; do
|
||||
echo "upload $(basename "$f")"
|
||||
curl -fsS -X POST -H "$AUTH" -F "attachment=@${f}" "${API}/releases/${ID}/assets?name=$(basename "$f")" >/dev/null
|
||||
done
|
||||
shell: bash
|
||||
Reference in new issue
Block a user