feat(builder): load publish credentials from .env.builder
Keep DEB/Docker publish keys out of the project's .env. Scripts and check.py --ready only read .env.builder; empty values count as missing.
This commit is contained in:
+15
-12
@@ -15,8 +15,8 @@ description: >-
|
||||
复用项目已有发布约定,安全地完成"校验 → 构建 → 检查 → 授权 → 上传 → 验证"。
|
||||
|
||||
分工原则:**make 管构建,skill 脚本管发布,本 SKILL.md 只留脚本做不了的决策。**
|
||||
项目状态是根目录 `makefile.builder` 与发布用 `.env`,不要创建 `.pouch/builder/`,
|
||||
不要改用户的 `Makefile` / `makefile`。
|
||||
项目状态是根目录 `makefile.builder` 与发布用 `.env.builder`,不要创建
|
||||
`.pouch/builder/`,不要改用户的 `Makefile` / `makefile` / `.env`。
|
||||
|
||||
开始时解析当前 `SKILL.md` 所在目录,记为 `<skill-dir>`。优先
|
||||
`git rev-parse --show-toplevel` 解析项目根。
|
||||
@@ -39,9 +39,9 @@ description: >-
|
||||
|
||||
## 初始化
|
||||
|
||||
1. 确认项目根。探测 `makefile.builder`、用户 `Makefile`/`makefile`(只当证据,
|
||||
不改)、`Dockerfile`、`debian/`、语言清单、`.env` 键名(只看键是否存在,不读、
|
||||
不打印值)。
|
||||
1. 确认项目根。探测 `makefile.builder`、`.env.builder`、用户 `Makefile`/`makefile`
|
||||
(只当抄 build 配方的证据,不改)、`Dockerfile`、`debian/`、语言清单。
|
||||
`.env.builder` 只看键是否存在且非空,不读、不打印值。不要读取用户 `.env`。
|
||||
2. 判定轨道:有 Dockerfile → docker;有 deb 信号或用户要打 deb → deb;都不清则问。
|
||||
不要猜测 registry、token 或仓库名。
|
||||
3. 没有 `makefile.builder`:把 `<skill-dir>/templates/makefile.builder` 拷到项目根。
|
||||
@@ -51,7 +51,9 @@ description: >-
|
||||
`push: push-deb push-docker`。不要改用户的 `Makefile` / `makefile`。
|
||||
4. 已有 `makefile.builder`:跑检查;按 FAIL 给出修补说明。不覆盖该文件,除非
|
||||
用户明确要求按契约改。不要调用 create-makefile(其版本规则与本契约冲突)。
|
||||
5. 不要创建 `.env`。缺发布键时在报告里给出可粘贴示例,并说明 `.env` 不进 Git。
|
||||
5. 没有 `.env.builder`:把 `<skill-dir>/templates/env.builder` 拷到项目根为
|
||||
`.env.builder`(注释键,不含值)。不要改、不要读取用户 `.env`。缺发布键时在
|
||||
报告里给出可粘贴示例,并说明把 `.env.builder` 加入 `.gitignore`,不要提交。
|
||||
6. 运行:
|
||||
|
||||
```bash
|
||||
@@ -74,6 +76,7 @@ description: >-
|
||||
发布键示例(只示范键名):
|
||||
|
||||
```text
|
||||
# .env.builder
|
||||
DEB_SERVER_URL=https://deb.example.com
|
||||
DEB_REPOSITORY=main
|
||||
DEB_TOKEN=
|
||||
@@ -83,8 +86,8 @@ DOCKER_REGISTRY=registry.example.com
|
||||
## 检查
|
||||
|
||||
只读。运行 `check.py <project-dir> --ready`,用同一报告格式,标题改为
|
||||
`## builder 检查:…`。不写 `makefile.builder`、不改用户 Makefile、不创建 `.env`。
|
||||
用户明确要求修复后再转入初始化。
|
||||
`## builder 检查:…`。不写 `makefile.builder` / `.env.builder`,不改用户 Makefile
|
||||
或 `.env`。用户明确要求修复后再转入初始化。
|
||||
|
||||
## 工作流
|
||||
|
||||
@@ -108,7 +111,7 @@ python3 -I -S <skill-dir>/scripts/check.py <project-dir> --build # 额外实构
|
||||
|
||||
执行上传前确认:
|
||||
|
||||
- 目标服务和仓库来自项目配置(`.env`)或用户输入,不猜测生产端点。
|
||||
- 目标服务和仓库来自项目配置(`.env.builder`)或用户输入,不猜测生产端点。
|
||||
- 认证令牌已通过环境变量或密钥系统提供;绝不写入命令输出、文件、提交或回复,
|
||||
不用 `set -x` 执行含凭据的命令。
|
||||
- 相同版本是否允许覆盖;无法确认且可能覆盖时,先询问。
|
||||
@@ -152,7 +155,7 @@ DOCKER_REGISTRY=… \
|
||||
<skill-dir>/scripts/publish_docker.sh # env 优先,flag 可覆盖
|
||||
```
|
||||
|
||||
环境变量缺失时脚本会自动向上查找项目 `.env` 加载(shell 显式值优先)。不把 token
|
||||
环境变量缺失时脚本会加载项目 `.env.builder`(shell 显式值优先),不读 `.env`。不把 token
|
||||
作为命令行参数;不把脚本复制进项目。upload_deb.sh 默认请求 `/api/v2/upload/package`
|
||||
(multipart 字段 `package`/`token`/`repository_name`,接受 200/201),协议不符时设
|
||||
`DEB_UPLOAD_PATH` 或改用项目专属逻辑。publish_docker.sh 用 buildx 一步完成构建+推送,
|
||||
@@ -188,8 +191,8 @@ rg -n -i --hidden --glob '!.git' \
|
||||
- 上传/发布脚本是 SSOT:通用行为修改落在 `skills/builder/scripts/`,不同步复制到
|
||||
业务项目。产物版本只通过 `scripts/version.sh` 推导,不要在 `makefile.builder` 内联
|
||||
`git describe` 或 `sort -V`。
|
||||
- 契约变更先改 `scripts/check.py`,再同步 `references/contract.md` 与
|
||||
`templates/makefile.builder`。
|
||||
- 契约变更先改 `scripts/check.py`,再同步 `references/contract.md`、
|
||||
`templates/makefile.builder` 与 `templates/env.builder`。
|
||||
- 可用 `bash -n` 检查脚本语法;有 ShellCheck 时一并运行。
|
||||
- 不通过真实生产上传测试脚本,除非用户明确授权并给出测试版本/仓库。
|
||||
|
||||
|
||||
Reference in New Issue
Block a user