Skip to content

Commit d921e57

Browse files
committed
refactor(ci): 拆分构建/发布工作流,接入 WebUI 构建与自更新清单
将 129 行的 build.yml「上帝工作流」按职责拆分,并修复若干潜在问题: - 拆分:build.yml → ci.yml(分支/手动:构建 + 推开发包到 Telegram) + release.yml(tag:建 Release + 上传 update.json + 发布通知) - 复用:打包逻辑抽到 composite action(.github/actions/build-module): 构建 WebUI(→webroot)、写 versionCode、打 完整/精简/纯脚本 三包 - WebUI 首次接入打包流水线(发布包将包含 webroot) - 触发修正:release 仅 on tag 并收紧为 v*,消除 push 中 paths 与 tags 混用导致的触发歧义 - 自更新:release 时以模板生成 update.json 并作为 Release 附件; module.prop 的 updateJson 改指 releases/latest/download/update.json; 修复 update.json 中失效的 changelog 路径(→ .github/changelog.md) - 重命名带空格的 "Sync to KernelSU Repo.yml" → sync-kernelsu.yml - dependabot 增加 src/webui 监控;docs.yml 命名统一中文;TG 推送去重
1 parent 5a1bec8 commit d921e57

10 files changed

Lines changed: 324 additions & 210 deletions

File tree

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: 构建并打包模块
2+
description: 构建 WebUI、写入 versionCode,并打出 完整 / 精简 / 纯脚本 三个 ZIP 包
3+
4+
# 被 ci.yml 与 release.yml 复用的共享打包逻辑(调用前需已 checkout,且 fetch-depth: 0 以便统计提交数)
5+
outputs:
6+
version:
7+
description: 模块版本号(取自 module.prop 的 version=)
8+
value: ${{ steps.meta.outputs.version }}
9+
commit_count:
10+
description: 提交数,用作 versionCode
11+
value: ${{ steps.meta.outputs.commit_count }}
12+
full_name:
13+
description: 完整包文件名
14+
value: ${{ steps.meta.outputs.full_name }}
15+
lite_name:
16+
description: 精简包文件名
17+
value: ${{ steps.meta.outputs.lite_name }}
18+
mini_name:
19+
description: 纯脚本包文件名
20+
value: ${{ steps.meta.outputs.mini_name }}
21+
22+
runs:
23+
using: composite
24+
steps:
25+
- name: 配置 Node
26+
uses: actions/setup-node@v6
27+
with:
28+
node-version: 24
29+
cache: npm
30+
cache-dependency-path: src/webui/package-lock.json
31+
32+
- name: 构建 WebUI(产物 → src/module/webroot)
33+
shell: bash
34+
working-directory: src/webui
35+
run: |
36+
npm ci
37+
npm run build
38+
39+
- name: 计算版本并写入 module.prop
40+
id: meta
41+
shell: bash
42+
run: |
43+
COMMIT_COUNT=$(git rev-list --count HEAD)
44+
sed -i "s/^versionCode=.*/versionCode=$COMMIT_COUNT/" src/module/module.prop
45+
VERSION=$(grep '^version=' src/module/module.prop | cut -d= -f2)
46+
{
47+
echo "version=$VERSION"
48+
echo "commit_count=$COMMIT_COUNT"
49+
echo "full_name=NetProxy_${VERSION}_${COMMIT_COUNT}.zip"
50+
echo "lite_name=NetProxy_${VERSION}_${COMMIT_COUNT}_lite.zip"
51+
echo "mini_name=NetProxy_${VERSION}_${COMMIT_COUNT}_mini.zip"
52+
} >> "$GITHUB_OUTPUT"
53+
54+
- name: 打包三件套(完整 / 精简 / 纯脚本)
55+
shell: bash
56+
working-directory: src/module
57+
env:
58+
FULL_NAME: ${{ steps.meta.outputs.full_name }}
59+
LITE_NAME: ${{ steps.meta.outputs.lite_name }}
60+
MINI_NAME: ${{ steps.meta.outputs.mini_name }}
61+
run: |
62+
# 完整包(全部组件)
63+
7z a -tzip -mx=9 "../../$FULL_NAME" .
64+
# 精简包(排除 IPSET 驱动,适用于内核已内置 IPSET 的设备)
65+
7z a -tzip -mx=9 "../../$LITE_NAME" . -x!"bin/IPSET-LKM/*" -x!"bin/ipset"
66+
# 纯脚本包(排除所有二进制文件)
67+
7z a -tzip -mx=9 "../../$MINI_NAME" . -x!"bin/sing-box" -x!"bin/proxylink" -x!"bin/ipset" -x!"bin/IPSET-LKM/*" -x!"bin/zashboard/*"

.github/dependabot.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,26 @@
22

33
version: 2
44
updates:
5-
6-
7-
# GitHub Actions
5+
# GitHub Actions(工作流与 composite action 引用的 actions)
86
- package-ecosystem: "github-actions"
97
directory: "/"
108
schedule:
119
interval: "daily"
1210
commit-message:
1311
prefix: "ci(deps)"
1412

15-
# Docs (VitePress)
13+
# 文档站 (VitePress)
1614
- package-ecosystem: "npm"
1715
directory: "/docs"
1816
schedule:
1917
interval: "weekly"
2018
commit-message:
2119
prefix: "docs(deps)"
20+
21+
# WebUI (Vue + Vite)
22+
- package-ecosystem: "npm"
23+
directory: "/src/webui"
24+
schedule:
25+
interval: "weekly"
26+
commit-message:
27+
prefix: "webui(deps)"

.github/update.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"version": "Module v7.0.5",
33
"versionCode": 604,
44
"zipUrl": "https://github.com/Fanju6/NetProxy-Magisk/releases/download/v7.0.5/NetProxy_v7.0.5_604.zip",
5-
"changelog": "https://raw.githubusercontent.com/Fanju6/NetProxy-Magisk/refs/heads/main/changelog.md"
5+
"changelog": "https://raw.githubusercontent.com/Fanju6/NetProxy-Magisk/refs/heads/main/.github/changelog.md"
66
}

.github/workflows/Sync to KernelSU Repo.yml

Lines changed: 0 additions & 64 deletions
This file was deleted.

.github/workflows/build.yml

Lines changed: 0 additions & 128 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: 持续集成(构建与开发包)
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches: [main]
7+
paths:
8+
- 'src/module/**'
9+
- 'src/webui/**'
10+
- '.github/workflows/ci.yml'
11+
- '.github/actions/build-module/**'
12+
13+
permissions:
14+
contents: read
15+
16+
# 同一分支的新推送取消尚未完成的旧构建
17+
concurrency:
18+
group: ci-${{ github.ref }}
19+
cancel-in-progress: true
20+
21+
jobs:
22+
build:
23+
name: 构建与推送开发包
24+
runs-on: ubuntu-latest
25+
steps:
26+
- name: 拉取代码
27+
uses: actions/checkout@v6
28+
with:
29+
fetch-depth: 0
30+
31+
- name: 构建并打包模块
32+
id: pack
33+
uses: ./.github/actions/build-module
34+
35+
- name: 推送开发包到 Telegram
36+
env:
37+
TG_BOT_TOKEN: ${{ secrets.TG_BOT_TOKEN }}
38+
TG_CHAT_ID: ${{ secrets.TG_CHAT_ID }}
39+
COMMIT_MSG: ${{ github.event.head_commit.message }}
40+
VERSION: ${{ steps.pack.outputs.version }}
41+
COMMIT_COUNT: ${{ steps.pack.outputs.commit_count }}
42+
FULL_NAME: ${{ steps.pack.outputs.full_name }}
43+
LITE_NAME: ${{ steps.pack.outputs.lite_name }}
44+
MINI_NAME: ${{ steps.pack.outputs.mini_name }}
45+
run: |
46+
CAPTION="模块构建成功通知
47+
48+
版本: \`${VERSION}\` (build ${COMMIT_COUNT})
49+
说明:
50+
\`\`\`
51+
${COMMIT_MSG:-手动触发或无说明}
52+
\`\`\`
53+
54+
[提交记录](${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }})
55+
[构建日志](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})"
56+
57+
# 统一发送函数:$1=文件 $2=说明,其余参数透传给 curl(如 -F parse_mode=Markdown)
58+
send() {
59+
curl -sS \
60+
-F "chat_id=${TG_CHAT_ID}" \
61+
-F "message_thread_id=2275" \
62+
-F "document=@$1" \
63+
-F "caption=$2" \
64+
"${@:3}" \
65+
"https://api.telegram.org/bot${TG_BOT_TOKEN}/sendDocument"
66+
}
67+
68+
send "$FULL_NAME" "$CAPTION" -F "parse_mode=Markdown"
69+
send "$LITE_NAME" "lite: 不含 IPSET 驱动,适用于内核已内置 IPSET 的设备"
70+
send "$MINI_NAME" "mini: 不含二进制文件和 IPSET 驱动,需自行放入 sing-box、proxylink、zashboard 等组件"
71+
72+
- name: 失败通知
73+
if: failure()
74+
uses: cbrgm/telegram-github-action@v1
75+
with:
76+
token: ${{ secrets.TG_BOT_TOKEN }}
77+
to: ${{ secrets.TG_CHAT_ID }}
78+
thread-id: 2275
79+
parse-mode: markdown
80+
message: |
81+
**持续集成失败!**
82+
83+
提交: `${{ github.sha }}`
84+
说明: ${{ github.event.head_commit.message }}
85+
86+
[点击查看构建日志](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})

0 commit comments

Comments
 (0)