Files
37duAutomation/docs/插件/发版规范.md
T

101 lines
4.7 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 插件发版与自动更新规范
> 本文档定义 37duAutomation 各交付物的**发版流程**与执行机**自动更新机制**。
> 发版统一走 agent CLI(中心机控制面),执行机端插件按账号权限自下载、壳子由用户点击升级。
> 打包产物位置、打包脚本见 [插件开发规范.md](./插件开发规范.md) 第 4 节。
## 1. 总览
版本源(插件包 + 壳子安装包 + 文件登记)全部在**中心机控制面**(`http://117.72.191.188:8800`)。
| 交付物 | 更新机制 | 入口 |
|--------|----------|------|
| 插件 | 执行机登录后按账号权限自动同步(`plugin_sync.py`) | agent CLI `publish` / `grant` / `revoke` |
| 壳子(安装包) | 执行机自动下载 + 用户点击升级重启(`shell_updater.py`) | agent CLI `file push --category shell` |
| 中心机控制面 | 源码部署,不打包 | 宝塔上传 + 重启 / 前端构建发布 |
## 2. 发版工具与鉴权
统一在 `desktop/` 目录下执行 agent CLI:
```powershell
d:\work\code\37duAutomation\.venv\Scripts\python.exe -m controlplane.tools.agent_cli
```
鉴权两种方式:
1. **密码登录(推荐,任意机器可用)**:
`--admin <管理员> --password <密码>`(或环境变量 `AGENT_ADMIN_PASSWORD` / `AGENT_ADMIN_ACCOUNT`),
远程机器再加 `--base http://<中心机地址>:8800`
2. **本机密钥自签(仅中心机本机)**:复用 `controlplane/.env` 与 `.admin_secret`
实际账号:管理员 `puddy`,密码 `123456`,中心机控制面 `http://117.72.191.188:8800`。
本开发机直接示例:
```powershell
d:\work\code\37duAutomation\.venv\Scripts\python.exe -m controlplane.tools.agent_cli `
--admin puddy --password 123456 --base http://117.72.191.188:8800 `
publish <插件.zip> --id <id> --version <v>
```
## 3. 插件发版流程
1. **打包**:在插件目录(`plugins/XQ0001-0100/XQ00xx <中文名>/`)下执行 `_pack.py`,产物输出到仓库根 `dist-plugin/<id>_v<版本>.zip`
(zip 根必须含 `plugin.json`;带 UI 插件需先 `npm run build` 出 `ui/index.html`)。
2. **发布**:在 `desktop/` 下执行:
```powershell
.venv\Scripts\python.exe -m controlplane.tools.agent_cli `
--admin puddy --password 123456 `
publish dist-plugin\<id>_v<版本>.zip --id <id> --version <版本>
```
版本号需与 `plugin.json.version` / `ScenePlugin.version` 一致,且高于中心机已有版本。
3. **授权 / 收回**(按账号管控可执行性):
```powershell
.venv\Scripts\python.exe -m controlplane.tools.agent_cli grant <账号> <id>
.venv\Scripts\python.exe -m controlplane.tools.agent_cli revoke <账号> <id>
```
4. **执行机端**:登录后按账号权限自动同步——`plugin_sync.py` 拉版本清单 → 下载 → sha256 校验 →
解压到 `plugins/<id>/` 原子替换 → 重载注册表;下次执行即用新版本。
## 4. 壳子发版流程
> 壳子 / 中心机 / 文件服务器的完整发版步骤见 [桌面端发版SOP](../桌面端/桌面端发版SOP.md),本节为摘要。
按实际流程执行:
1. 改 `desktop/webhost/tools/shell.version` 与 `install.iss` 的 `MyAppVersion` 为新版本
2. `desktop/webhost/frontend` 下执行 `npm run build`
3. PyInstaller 打 `desktop/webhost/tools/37du-host.spec`、`37du-host-runner.spec`
(`37du-host-console.spec` 是调试版,不入安装包,可跳过)
4. `ISCC.exe desktop/webhost/tools/install.iss` 出安装包
5. 上传登记:
```powershell
.venv\Scripts\python.exe -m controlplane.tools.agent_cli `
--admin puddy --password 123456 `
file push <安装包> --category shell --version <新版本> [--notes "说明"]
```
> 安装包上传到内网文件服务器(`FILESERVER_BASE_URL=172.30.35.135:8802`),并登记到中心机
> `file_sources(shell)`,执行机 `shell_updater` 从该直链下载。**不要用旧的 `shell-release` 子命令**。
6. **执行机端**:自动下载安装包,前端提示后用户点击升级重启。
## 5. 中心机发版流程
控制面为源码部署(宝塔 gunicorn 8800,不打包 exe):
- 改后端代码:按 `docs/部署/控制面前后端部署SOP.md`「后端部署流程」上传文件 + 重启项目
- 改前端代码:按同一文档「前端部署流程」构建并发布到静态站 8090
## 6. 发布后检查
- 插件发布后:执行机下次启动自动检测下载;插件登录后按权限自动下载更新。
- 壳子发布后:执行机自动下载,前端提示后点击升级。
- 版本冲突 / 更新失败:查执行机 `plugin_sync.py` 与 `shell_updater.py` 日志;核对中心机版本清单与授权。