From 96c83d27b0565cb39c8e9b33eb7a0b409815a7d6 Mon Sep 17 00:00:00 2001 From: zijunchiang Date: Sat, 26 Sep 2026 12:52:05 +0800 Subject: [PATCH] =?UTF-8?q?docs:=20=E4=BF=AE=E5=A4=8D=E5=87=AD=E6=8D=AE=20?= =?UTF-8?q?helper=20=E4=BD=9C=E7=94=A8=E5=9F=9F=E4=B8=8E=E4=BB=A4=E7=89=8C?= =?UTF-8?q?=E6=8F=90=E5=8F=96=EF=BC=88=E5=8F=91=E5=B8=83=E6=97=B6=E8=B8=A9?= =?UTF-8?q?=E5=88=B0=E7=9A=84=20401=20=E6=A0=B9=E5=9B=A0=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 仓库级 credential.helper(无主机限定) 会让 git 在 Gitee 认证成功后调用 store, 把 Gitee 凭据追加写进 ~/.git-credentials-gitea(一行变两行), 此后按单行提取的令牌变成两行拼接值,Gitea API 报 401 - 改为按主机限定的 credential.https://gitea.kasugano.cn.helper, 并把发布小节的 TOKEN 提取改成带主机锚点的 sed -nE ... p - 新增「发布新版本(Gitee Release)」小节:建 Release 与 attach_files(字段名 file) 两个 API 写法、中文附件名可用、发布后必须校验下载 md5 - 纯文档改动,未改 App 代码,版本号保持 1.4.0 --- AGENTS.md | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index e773536..7841c40 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -34,11 +34,16 @@ - 凭据: - **Gitea**(代码主仓库):访问令牌 `dsh-sync-20260926`(2026-09-26 数据迁移后重建;可在 Gitea 「设置 → 应用 → 访问令牌」随时吊销),存放于 `~/.git-credentials-gitea`(权限 600), - 由本仓库级 `credential.helper` 引用; + 由**按主机限定**的仓库级 `credential.https://gitea.kasugano.cn.helper` 引用; - **Gitee**(仅发布 Release,按规则 2 不推代码):访问令牌存放于 `~/.git-credentials-gitee` (权限 600),由全局 `credential.https://gitee.com.helper` 引用;**只用于 API 建 Release / 传附件**,不得用于推送源码。 - 账号密码不写入仓库配置。 + - ⚠️ **两个 helper 都必须按主机限定作用域**(`credential.https://.helper`,不要用无主机限定的 + `credential.helper`):git 认证成功后会调用**每个** helper 的 `store`,无主机限定会把 Gitee 凭据 + 追加写进 Gitea 的凭据文件(一个文件两行),此后「取第一行」式的令牌提取会拿到错误令牌、API 报 401。 + - ⚠️ **提取令牌必须按主机过滤**:用 `sed -nE 's|https://[^:]+:([^@]+)@.*|\1|p'`, + 不要用不带主机锚点的 `sed -E 's|https://[^:]+:([^@]+)@.*|\1|'`(多行文件会输出多行、拼成错令牌)。 ### 推送方式 @@ -63,7 +68,7 @@ App 内部两处端点已指向 Gitea(随本版 APK 生效): ### 发布新版本(Gitea Release) ```bash -TOKEN=$(sed -E 's|https://zijunchiang:([^@]+)@.*|\1|' ~/.git-credentials-gitea) +TOKEN=$(sed -nE 's|https://[^:]+:([^@]+)@gitea\.kasugano\.cn.*|\1|p' ~/.git-credentials-gitea) # 1) 创建 Release(tag 需高于当前 versionName 才会提示更新) curl -X POST -u "zijunchiang:$TOKEN" -H "Content-Type: application/json" \ @@ -84,6 +89,26 @@ curl -X POST -u "zijunchiang:$TOKEN" \ > > 上传 22MB APK 约需 70s,注意命令超时设置。 +### 发布新版本(Gitee Release) + +```bash +GT=$(sed -nE 's|https://[^:]+:([^@]+)@gitee\.com.*|\1|p' ~/.git-credentials-gitee) + +# 1) 创建 Release(Gitee 会自动创建同名 tag) +curl -X POST -H "Authorization: token $GT" -H "Content-Type: application/json" \ + -d '{"tag_name":"v1.4.0","name":"麦动KTV V1.4.0","body":"更新说明","target_commitish":"master"}' \ + https://gitee.com/api/v5/repos/zijunchiang/maidong-ktv/releases + +# 2) 上传 APK 附件(表单字段名是 file,不是 attachment;用返回的 release id) +curl -X POST -H "Authorization: token $GT" \ + -F "file=@麦动KTV-V1.4.0-release.apk" \ + "https://gitee.com/api/v5/repos/zijunchiang/maidong-ktv/releases//attach_files" +``` + +> Gitee 附件名**可用中文**(ASCII 限制只针对 Gitea 1.27),上传 22MB 约 4s。 +> 发布后务必校验下载:`curl -sL | md5sum` 应与本地发布包一致 +> (Gitea 侧同样要校验 `/releases/download//<文件>` 规范路径返回 200)。 + ## 二、构建与产物 ### 构建(release,双 ABI)