1、新增上传命令行参数:upload
2、上传参数关联函数调整与优化
This commit is contained in:
117
README.md
117
README.md
@@ -15,6 +15,7 @@ gitver nuitkabuild=<pid> [repodir=<path>] [-test] [params="<mainPy> <nuitka参
|
||||
gitver nuitkapydbuild=<pid> [repodir=<path>] [-test] [params="<modulePy> <nuitka参数>"]
|
||||
gitver pyinstaller=<pid> [repodir=<path>] [-test] [params="<mainPy|specFile> <pyinstaller参数>"]
|
||||
gitver setup=n [pid=m] [repodir=<path>] [-test]
|
||||
gitver upload username=<用户名> [file=<上传文件>] [info=<配置.txt>] [url=<PMC基址>]
|
||||
```
|
||||
|
||||
**通用参数说明:**
|
||||
@@ -116,8 +117,21 @@ gitver setver=5 -test
|
||||
```
|
||||
ProductVersion=5.0.1920.11
|
||||
FileVersion=5.26.0519.3
|
||||
已更新 upload_info.txt: E:\Code\MyProj\upload_info.txt
|
||||
```
|
||||
|
||||
**upload_info.txt 自动更新:**
|
||||
|
||||
`setver` 成功生成版本号后,会在仓库目录(`repodir`,缺省为当前目录)写入或更新 `upload_info.txt`:
|
||||
|
||||
| 字段 | 来源 |
|
||||
|---|---|
|
||||
| `product_version` | 本次生成的 ProductVersion |
|
||||
| `file_version` | 本次生成的 FileVersion |
|
||||
| `file_change_log` | 文件版本对应日期的 git 提交说明(`origin/<分支>` 当天 log,多条以换行分隔) |
|
||||
|
||||
`setup` 成功编译安装包后,还会写入 `file`(安装包路径)。文件中已有的其他字段(如 `package_name`、`package_type_id`、`url` 等)会保留不变。
|
||||
|
||||
**回写说明:**
|
||||
|
||||
- **C++**:回写 `.rc` 文件中的 FILEVERSION、PRODUCTVERSION 及对应字符串字段
|
||||
@@ -265,6 +279,81 @@ gitver setup=0 pid=5
|
||||
gitver setup=1 pid=5 repodir=E:\Code\MyProj
|
||||
```
|
||||
|
||||
**upload_info.txt 自动更新:**
|
||||
|
||||
`setup` 编译成功后,会在仓库目录(`repodir`,缺省为当前目录)写入或更新 `upload_info.txt` 的 `file` 字段(安装包完整路径)。路径从 ISCC/NSIS 编译输出中解析;若无法解析,则尝试脚本目录下 `Output\*.exe` 或脚本目录内最新 `.exe`。
|
||||
|
||||
**输出示例:**
|
||||
|
||||
```
|
||||
安装包路径: E:\Code\MyProj\Output\MyApp_Setup_5.26.0624.3.exe
|
||||
已更新 upload_info.txt: E:\Code\MyProj\upload_info.txt
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### `gitver upload`(上传包到 PMC)
|
||||
|
||||
将构建产物上传到 PMC 包管理中心。需 PMC 服务已运行,且账号具有管理员权限。
|
||||
|
||||
```
|
||||
gitver upload username=<用户名> [file=<上传文件>] [info=<配置.txt>] [url=<PMC基址>]
|
||||
```
|
||||
|
||||
| 参数 | 说明 |
|
||||
|---|---|
|
||||
| `username=` | PMC 登录账号(必填);登录密码从**同名环境变量**读取,如 `username=admin` 读取 `%admin%` |
|
||||
| `file=` | 可选,要上传的包文件路径;省略时从 info 文件的 `file` 字段读取(通常由 `setup` 写入) |
|
||||
| `info=` | 可选,上传配置信息文件路径,默认 `upload_info.txt`(见下方格式) |
|
||||
| `url=` | 可选,PMC 服务基址,默认 `http://127.0.0.1:8000` |
|
||||
|
||||
**info 配置文件格式**(UTF-8 或 ANSI,每行 `key=value`,`#` 开头为注释):
|
||||
|
||||
```ini
|
||||
url=http://127.0.0.1:8000
|
||||
|
||||
package_name=daily-report
|
||||
package_type_id=1
|
||||
file=E:\dist\MyApp_Setup_5.26.0624.3.exe
|
||||
product_version=5.0.1920.11
|
||||
file_version=5.26.0624.3
|
||||
file_change_log=修复导出 bug
|
||||
description=日报工具
|
||||
wiki_url=https://example.com/wiki
|
||||
product_change_log=首次发布
|
||||
```
|
||||
|
||||
| info 字段 | 必填 | 说明 |
|
||||
|---|---|---|
|
||||
| `package_name` | 是 | 包名称 |
|
||||
| `package_type_id` | 是 | 包类型 ID(整数) |
|
||||
| `file` | 否* | 安装包路径;`upload` 省略 `file=` 时必填,通常由 `setup` 自动写入 |
|
||||
| `product_version` | 是 | 产品版本号 |
|
||||
| `file_version` | 是 | 文件版本号 |
|
||||
| `file_change_log` | 是 | 文件版本更新说明 |
|
||||
| `description` | 否 | 包描述 |
|
||||
| `wiki_url` | 否 | Wiki 链接 |
|
||||
| `product_change_log` | 否 | 产品版本更新说明 |
|
||||
| `url` | 否 | PMC 基址,默认 `http://127.0.0.1:8000` |
|
||||
|
||||
上传流程:先 `POST /auth/login` 获取 Session,再 `POST /admin/packages/upload`(multipart/form-data),最后通过 `/api/packages/latest` 验证版本是否写入。
|
||||
|
||||
HTTP 实现基于 [cpp-httplib](https://github.com/yhirose/cpp-httplib)([`GitVer/httplib.h`](GitVer/httplib.h)),默认支持 `http://`;若需 `https://` 须另行启用 OpenSSL 支持。
|
||||
|
||||
**示例:**
|
||||
|
||||
```powershell
|
||||
# 先设置与 username 同名的环境变量作为登录密码
|
||||
$env:admin = "your_admin_password"
|
||||
```
|
||||
|
||||
```
|
||||
gitver upload username=admin
|
||||
gitver upload username=admin info=E:\upload_info.txt
|
||||
gitver upload username=admin file=E:\dist\app.zip info=E:\upload_info.txt
|
||||
gitver upload username=admin url=http://192.168.1.10:8000
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Nuitka 与 PyInstaller 常用参数速查
|
||||
@@ -505,6 +594,13 @@ VSVersionInfo(
|
||||
| 44 | `pyinstaller=` 获取当天分支提交次数失败 |
|
||||
| 45 | `pyinstaller=` 版本信息文件无法生成或更新 |
|
||||
| 46 | `pyinstaller=` spec 文件无法注入或修改版本信息 |
|
||||
| 47 | `upload` 缺少必填参数(username),或 file 未指定且 info 中无 file 字段 |
|
||||
| 48 | `upload` 上传文件不存在 |
|
||||
| 49 | `upload` info 文件无效、缺少必填字段,或未设置与 username 同名的环境变量 |
|
||||
| 50 | `upload` PMC 登录失败 |
|
||||
| 51 | `upload` HTTP 上传请求失败 |
|
||||
| 52 | `upload` 上传后未找到对应版本(校验失败或版本冲突) |
|
||||
| 53 | `upload` 网络/HTTP 错误 |
|
||||
|
||||
---
|
||||
|
||||
@@ -592,6 +688,16 @@ gitver setup=0 pid=5
|
||||
# 预期: 使用 pid=5 生成版本号,修改 setup.iss 并调用 ISCC.exe 编译
|
||||
```
|
||||
|
||||
### 验证 upload
|
||||
|
||||
```powershell
|
||||
# 前提:PMC 运行于 http://127.0.0.1:8000,且已有 admin 账号
|
||||
$env:admin = "your_admin_password"
|
||||
# 准备 upload_info.txt(含 package_name、file 等字段,不含 password)
|
||||
gitver upload username=admin
|
||||
# 预期: 读取当前目录 upload_info.txt,返回码 0,PMC 管理页可见新版本
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 回归清单
|
||||
@@ -658,6 +764,17 @@ gitver setup=0 pid=5
|
||||
| `gitver setup=9` | 36 |
|
||||
| `gitver setup=0 pid=abc` | 4 |
|
||||
|
||||
### upload 组
|
||||
|
||||
| 命令 | 预期返回码 |
|
||||
|---|---|
|
||||
| `gitver upload username=admin` | 0 / 47 / 48 / 49 / 50 / 52 / 53 |
|
||||
| `gitver upload username=admin info=E:\upload_info.txt` | 0 / 50 / 52 / 53 |
|
||||
| `gitver upload username=admin file=E:\dist\app.zip info=E:\upload_info.txt` | 0 / 50 / 52 / 53 |
|
||||
| `gitver upload username=admin file=E:\NotExists info=E:\upload_info.txt` | 48 |
|
||||
| `gitver upload username=admin info=E:\NotExists` | 49 |
|
||||
| `gitver upload` | 47 |
|
||||
|
||||
> **注意**:如果打包时提示“未找到安装编译器(ISCC.exe / makensis.exe)”,请手动下载安装对应工具,并将其可执行文件路径(如 `ISCC.exe` 或 `makensis.exe` 所在目录)添加到系统环境变量 `PATH`。常见下载地址:
|
||||
>
|
||||
> - Inno Setup: https://jrsoftware.org/isinfo.php
|
||||
|
||||
Reference in New Issue
Block a user