已合并
fix(release): converge brew/nfpm metadata to atomgit-cli and lock npm coordinate allowlists #570
aflyingto创建于 9月23日
fix(release): converge brew/nfpm metadata to atomgit-cli and lock npm coordinate allowlists #570
已合并
共 13 个文件变更+125-67
| @@ -456,7 +456,7 @@ jobs: | |||
| 456 | printf '%s\n' "github.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOMqqnkVzqKEHvnCg2BRkOjFMiQ24aN3n5j0JpnewHSk" > ~/.ssh/known_hosts | 456 | printf '%s\n' "github.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOMqqnkVzqKEHvnCg2BRkOjFMiQ24aN3n5j0JpnewHSk" > ~/.ssh/known_hosts |
| 457 | eval "$(ssh-agent -s)" | 457 | eval "$(ssh-agent -s)" |
| 458 | ssh-add - <<< "${HOMEBREW_TAP_DEPLOY_KEY}" | 458 | ssh-add - <<< "${HOMEBREW_TAP_DEPLOY_KEY}" |
| 459 | - git clone git@github.com:gitcode-cli/homebrew-tap.git /tmp/tap | 459 | + git clone git@github.com:atomgit-cli/homebrew-tap.git /tmp/tap |
| 460 | cp formula/gc.rb /tmp/tap/gc.rb | 460 | cp formula/gc.rb /tmp/tap/gc.rb |
| 461 | cd /tmp/tap | 461 | cd /tmp/tap |
| 462 | git config user.name "github-actions[bot]" | 462 | git config user.name "github-actions[bot]" |
| @@ -93,14 +93,14 @@ changelog: | |||
| 93 | brews: | 93 | brews: |
| 94 | - name: gc | 94 | - name: gc |
| 95 | repository: | 95 | repository: |
| 96 | - owner: gitcode-cli | 96 | + owner: atomgit-cli |
| 97 | name: homebrew-tap | 97 | name: homebrew-tap |
| 98 | branch: main | 98 | branch: main |
| 99 | commit_author: | 99 | commit_author: |
| 100 | name: github-actions[bot] | 100 | name: github-actions[bot] |
| 101 | email: 41898282+github-actions[bot]@users.noreply.github.com | 101 | email: 41898282+github-actions[bot]@users.noreply.github.com |
| 102 | commit_msg_template: "chore: update gc formula for {{ .Tag }}" | 102 | commit_msg_template: "chore: update gc formula for {{ .Tag }}" |
| 103 | - homepage: https://gitcode.com/gitcode-cli/cli | 103 | + homepage: https://gitcode.com/atomgit-cli/cli |
| 104 | description: GitCode CLI - Command line tool for GitCode | 104 | description: GitCode CLI - Command line tool for GitCode |
| 105 | license: MIT | 105 | license: MIT |
| 106 | install: | | 106 | install: | |
| @@ -118,7 +118,7 @@ release: | |||
| 118 | prerelease: auto | 118 | prerelease: auto |
| 119 | mode: replace | 119 | mode: replace |
| 120 | footer: | | 120 | footer: | |
| 121 | - **Full Changelog**: https://gitcode.com/gitcode-cli/cli/compare/{{ .PreviousTag }}...{{ .Tag }} | 121 | + **Full Changelog**: https://gitcode.com/atomgit-cli/cli/compare/{{ .PreviousTag }}...{{ .Tag }} |
| 122 | 122 | ||
| 123 | announce: | 123 | announce: |
| 124 | skip: false | 124 | skip: false |
| @@ -5,7 +5,7 @@ | |||
| 5 | GitCode CLI 把这些工作带回终端:仓库、Issue、Pull Request、Commit、标签、里程碑、Release 和 Actions 都可以通过统一命令完成。对开发者,它减少上下文切换;对团队,它让操作可以复用和审计;对 AI 代理,它提供结构化、可发现、带安全边界的 GitCode 执行入口。本文统一使用跨平台入口 `gitcode`;通过 npm、PyPI、Homebrew、DEB/RPM 或 wheel 安装时都会同时提供 `gitcode` 和 `gc` 两个入口。 | 5 | GitCode CLI 把这些工作带回终端:仓库、Issue、Pull Request、Commit、标签、里程碑、Release 和 Actions 都可以通过统一命令完成。对开发者,它减少上下文切换;对团队,它让操作可以复用和审计;对 AI 代理,它提供结构化、可发现、带安全边界的 GitCode 执行入口。本文统一使用跨平台入口 `gitcode`;通过 npm、PyPI、Homebrew、DEB/RPM 或 wheel 安装时都会同时提供 `gitcode` 和 `gc` 两个入口。 |
| 6 | 6 | ||
| 7 | - 项目仓库:[gitcode-cli/cli](https://gitcode.com/gitcode-cli/cli) | 7 | - 项目仓库:[gitcode-cli/cli](https://gitcode.com/gitcode-cli/cli) |
| 8 | -- 安装渠道:[npm](https://www.npmjs.com/package/@gitcode-cli/cli)|[PyPI](https://pypi.org/project/gitcode-cli/)|[GitCode Release](https://gitcode.com/gitcode-cli/cli/releases)|[GitHub Release](https://github.com/gitcode-cli/cli/releases) | 8 | +- 安装渠道:[npm](https://www.npmjs.com/package/@gitcode-cli/cli)|[PyPI](https://pypi.org/project/gitcode-cli/)|[GitCode Release](https://gitcode.com/atomgit-cli/cli/releases)|[GitHub Release](https://github.com/atomgit-cli/cli/releases) |
| 9 | - 完整命令手册:[docs/COMMANDS.md](https://gitcode.com/gitcode-cli/cli/blob/main/docs/COMMANDS.md) | 9 | - 完整命令手册:[docs/COMMANDS.md](https://gitcode.com/gitcode-cli/cli/blob/main/docs/COMMANDS.md) |
| 10 | 10 | ||
| 11 | ## 五分钟开始使用 | 11 | ## 五分钟开始使用 |
| @@ -41,9 +41,9 @@ npm 安装默认使用 `notify` 模式:普通命令最多每 24 小时在后 | |||
| 41 | |------|-------------|------| | 41 | |------|-------------|------| |
| 42 | | npm bootstrap(Windows、Node/AI 环境首选) | `npx -y @gitcode-cli/cli@latest install` | https://www.npmjs.com/package/@gitcode-cli/cli | | 42 | | npm bootstrap(Windows、Node/AI 环境首选) | `npx -y @gitcode-cli/cli@latest install` | https://www.npmjs.com/package/@gitcode-cli/cli | |
| 43 | | PyPI(隔离安装) | `pipx install gitcode-cli` / `pipx upgrade gitcode-cli`(或仅在已激活 venv 中使用 pip) | https://pypi.org/project/gitcode-cli/ | | 43 | | PyPI(隔离安装) | `pipx install gitcode-cli` / `pipx upgrade gitcode-cli`(或仅在已激活 venv 中使用 pip) | https://pypi.org/project/gitcode-cli/ | |
| 44 | -| Homebrew (macOS/Linux) | `brew install gitcode-cli/homebrew-tap/gc` / `brew upgrade gc` | [homebrew-tap](https://github.com/gitcode-cli/homebrew-tap) | | 44 | +| Homebrew (macOS/Linux) | `brew install atomgit-cli/homebrew-tap/gc` / `brew upgrade gc` | [homebrew-tap](https://github.com/atomgit-cli/homebrew-tap) | |
| 45 | -| GitCode Release | 从归档下载 wheel/DEB/RPM/二进制 | https://gitcode.com/gitcode-cli/cli/releases | | 45 | +| GitCode Release | 从归档下载 wheel/DEB/RPM/二进制 | https://gitcode.com/atomgit-cli/cli/releases | |
| 46 | -| GitHub Release | 同上制品镜像 | https://github.com/gitcode-cli/cli/releases | | 46 | +| GitHub Release | 同上制品镜像 | https://github.com/atomgit-cli/cli/releases | |
| 47 | 47 | ||
| 48 | > npm 全局安装备选:`npm install -g --ignore-scripts --registry=https://registry.npmjs.org --@gitcode-cli:registry=https://registry.npmjs.org @gitcode-cli/cli@latest` | 48 | > npm 全局安装备选:`npm install -g --ignore-scripts --registry=https://registry.npmjs.org --@gitcode-cli:registry=https://registry.npmjs.org @gitcode-cli/cli@latest` |
| 49 | 49 | ||
| @@ -16,7 +16,7 @@ echo "To get started:" | |||
| 16 | echo " 1. Run 'gitcode auth login' or 'gc auth login' to authenticate" | 16 | echo " 1. Run 'gitcode auth login' or 'gc auth login' to authenticate" |
| 17 | echo " 2. Set your token: export GC_TOKEN=your_token" | 17 | echo " 2. Set your token: export GC_TOKEN=your_token" |
| 18 | echo "" | 18 | echo "" |
| 19 | -echo "Project README: https://gitcode.com/gitcode-cli/cli" | 19 | +echo "Project README: https://gitcode.com/atomgit-cli/cli" |
| 20 | -echo "Command docs: https://gitcode.com/gitcode-cli/cli/blob/main/docs/COMMANDS.md" | 20 | +echo "Command docs: https://gitcode.com/atomgit-cli/cli/blob/main/docs/COMMANDS.md" |
| 21 | 21 | ||
| 22 | exit 0 | 22 | exit 0 |
| @@ -213,7 +213,7 @@ go build -o ./gc ./cmd/gc | |||
| 213 | Homebrew formula (`gc.rb`) 是发布产物,不属于本地产物: | 213 | Homebrew formula (`gc.rb`) 是发布产物,不属于本地产物: |
| 214 | 214 | ||
| 215 | - 由 GoReleaser 在 release workflow `artifacts` job 生成到 `dist/homebrew/gc.rb`(含 version/sha256/URL/install/test,来自 `.goreleaser.yaml` `brews:` 段) | 215 | - 由 GoReleaser 在 release workflow `artifacts` job 生成到 `dist/homebrew/gc.rb`(含 version/sha256/URL/install/test,来自 `.goreleaser.yaml` `brews:` 段) |
| 216 | -- 由 `brew` job 用 deploy key 推送到 tap 仓 `gitcode-cli/homebrew-tap`(见 [release-process.md](./release-process.md) §6.5) | 216 | +- 由 `brew` job 用 deploy key 推送到 tap 仓 `atomgit-cli/homebrew-tap`(见 [release-process.md](./release-process.md) §6.5) |
| 217 | - 本地 `homebrew/gc.rb` 仅作参考副本,实际 formula 以 GoReleaser 生成结果为准(DSL 风格可能与本副本不同) | 217 | - 本地 `homebrew/gc.rb` 仅作参考副本,实际 formula 以 GoReleaser 生成结果为准(DSL 风格可能与本副本不同) |
| 218 | 218 | ||
| 219 | > **技术债务(保留 brews 的决策依据)**:GoReleaser `brews:` 段自 v2.16 起标记废弃,但仍可生成 formula(`goreleaser release` 兼容,仅 `goreleaser check` 报错)。正式 release workflow 固定 GoReleaser v2.17.1。GoReleaser 推荐迁移到 `homebrew_casks`,但 cask 假定签名公证、依赖 macOS app bundle 特性、Linux 支持有限,**不适用于跨平台未签名 CLI**——gc 是 CLI 二进制,需 macOS + Linux 双平台 `brew install`,formula 是 Homebrew 对 CLI 工具的标准做法(如 gh/jq/ripgrep)。故保留 `brews` 生成 formula,跟踪 GoReleaser 后续是否提供 CLI 友好替代;若未来大版本移除 `brews`,再评估自定义 formula 生成(`after.hooks` + 脚本)。不阻塞当前发布。 | 219 | > **技术债务(保留 brews 的决策依据)**:GoReleaser `brews:` 段自 v2.16 起标记废弃,但仍可生成 formula(`goreleaser release` 兼容,仅 `goreleaser check` 报错)。正式 release workflow 固定 GoReleaser v2.17.1。GoReleaser 推荐迁移到 `homebrew_casks`,但 cask 假定签名公证、依赖 macOS app bundle 特性、Linux 支持有限,**不适用于跨平台未签名 CLI**——gc 是 CLI 二进制,需 macOS + Linux 双平台 `brew install`,formula 是 Homebrew 对 CLI 工具的标准做法(如 gh/jq/ripgrep)。故保留 `brews` 生成 formula,跟踪 GoReleaser 后续是否提供 CLI 友好替代;若未来大版本移除 `brews`,再评估自定义 formula 生成(`after.hooks` + 脚本)。不阻塞当前发布。 |
| @@ -63,8 +63,8 @@ CI 不替代任何现有门禁层,只在 PR 提交时自动运行跨平台验 | |||
| 63 | 63 | ||
| 64 | CI 同时运行在两个平台: | 64 | CI 同时运行在两个平台: |
| 65 | 65 | ||
| 66 | -- **GitCode Actions**:GitCode 主仓 `gitcode.com/gitcode-cli/cli` 的原生 Linux CI,是 GitCode PR 的首要自动化证据 | 66 | +- **GitCode Actions**:GitCode 主仓 `gitcode.com/atomgit-cli/cli` 的原生 Linux CI,是 GitCode PR 的首要自动化证据 |
| 67 | -- **GitHub Actions**:GitHub 镜像仓 `github.com/gitcode-cli/cli` 的跨平台 CI,继续覆盖 Linux、macOS 和 Windows | 67 | +- **GitHub Actions**:GitHub 镜像仓 `github.com/atomgit-cli/cli` 的跨平台 CI,继续覆盖 Linux、macOS 和 Windows |
| 68 | 68 | ||
| 69 | GitCode 原生 CI 当前只覆盖 Linux;macOS 和 Windows 兼容性仍以 GitHub Actions 结果为准。 | 69 | GitCode 原生 CI 当前只覆盖 Linux;macOS 和 Windows 兼容性仍以 GitHub Actions 结果为准。 |
| 70 | 70 | ||
| @@ -72,7 +72,7 @@ GitCode 原生 CI 当前只覆盖 Linux;macOS 和 Windows 兼容性仍以 GitH | |||
| 72 | 72 | ||
| 73 | | 平台 | 自动触发 | 查看运行 | 查看 Job / 日志 | | 73 | | 平台 | 自动触发 | 查看运行 | 查看 Job / 日志 | |
| 74 | |------|---------|---------|-----------------| | 74 | |------|---------|---------|-----------------| |
| 75 | -| GitCode Actions | GitCode PR 提交/更新到 `main` | `gc actions run list -R gitcode-cli/cli --pr <pr> --json` | `gc actions job list/view/log` | | 75 | +| GitCode Actions | GitCode PR 提交/更新到 `main` | `gc actions run list -R atomgit-cli/cli --pr <pr> --json` | `gc actions job list/view/log` | |
| 76 | | GitHub Actions | GitHub PR 提交/更新到 `main` | `gh run list --workflow=ci.yml` | `gh run view --log` | | 76 | | GitHub Actions | GitHub PR 提交/更新到 `main` | `gh run list --workflow=ci.yml` | `gh run view --log` | |
| 77 | 77 | ||
| 78 | GitCode 平台操作固定使用 `gc`,GitHub 镜像仓操作使用 `gh`。 | 78 | GitCode 平台操作固定使用 `gc`,GitHub 镜像仓操作使用 `gh`。 |
| @@ -164,9 +164,9 @@ GitCode 日常 CI 使用最小仓库只读权限 `permissions: repository: read` | |||
| 164 | 164 | ||
| 165 | ```bash | 165 | ```bash |
| 166 | # GitCode:查看 PR 关联的运行、详情和 Jobs | 166 | # GitCode:查看 PR 关联的运行、详情和 Jobs |
| 167 | -gc actions run list -R gitcode-cli/cli --pr <pr-number> --workflow "CI" --json | 167 | +gc actions run list -R atomgit-cli/cli --pr <pr-number> --workflow "CI" --json |
| 168 | -gc actions run view <run-id> -R gitcode-cli/cli --json | 168 | +gc actions run view <run-id> -R atomgit-cli/cli --json |
| 169 | -gc actions job list <run-id> -R gitcode-cli/cli --json | 169 | +gc actions job list <run-id> -R atomgit-cli/cli --json |
| 170 | 170 | ||
| 171 | # GitHub:查看镜像 PR 分支的最新 CI 运行 | 171 | # GitHub:查看镜像 PR 分支的最新 CI 运行 |
| 172 | gh run list --workflow=ci.yml --branch <pr-branch> --limit 1 | 172 | gh run list --workflow=ci.yml --branch <pr-branch> --limit 1 |
| @@ -186,8 +186,8 @@ GitCode CLI 当前不提供 watch 子命令;需要等待时,按合理间隔 | |||
| 186 | CI 失败时,AI 必须: | 186 | CI 失败时,AI 必须: |
| 187 | 187 | ||
| 188 | 1. 获取失败 Job 的详细日志: | 188 | 1. 获取失败 Job 的详细日志: |
| 189 | - - GitCode:先用 `gc actions job list <run-id> -R gitcode-cli/cli --json` 取 `<job-id>`,再执行 | 189 | + - GitCode:先用 `gc actions job list <run-id> -R atomgit-cli/cli --json` 取 `<job-id>`,再执行 |
| 190 | - `gc actions job log <run-id> <job-id> -R gitcode-cli/cli --output job-log.zip` | 190 | + `gc actions job log <run-id> <job-id> -R atomgit-cli/cli --output job-log.zip` |
| 191 | - GitHub:`gh run view <run-id> --log --job=<job-id>` | 191 | - GitHub:`gh run view <run-id> --log --job=<job-id>` |
| 192 | 2. 分析根因(代码问题 vs 环境问题 vs 偶发问题) | 192 | 2. 分析根因(代码问题 vs 环境问题 vs 偶发问题) |
| 193 | 3. 修复后重新推送并重新触发 CI | 193 | 3. 修复后重新推送并重新触发 CI |
| @@ -225,7 +225,7 @@ PR 作者自检中至少包含: | |||
| 225 | - build: ✅ | 225 | - build: ✅ |
| 226 | - package: ✅ | 226 | - package: ✅ |
| 227 | - GitHub Actions: | 227 | - GitHub Actions: |
| 228 | - - Run URL: https://github.com/gitcode-cli/cli/actions/runs/<run-id> | 228 | + - Run URL: https://github.com/atomgit-cli/cli/actions/runs/<run-id> |
| 229 | - 结论: success | 229 | - 结论: success |
| 230 | - test/build (ubuntu, macOS, Windows): ✅ | 230 | - test/build (ubuntu, macOS, Windows): ✅ |
| 231 | - lint/secret-scan/docker (ubuntu): ✅ | 231 | - lint/secret-scan/docker (ubuntu): ✅ |
| @@ -146,9 +146,9 @@ go test -tags=system ./tests/system | |||
| 146 | 146 | ||
| 147 | ```bash | 147 | ```bash |
| 148 | # 查看 GitCode PR 的 CI 运行、详情和 Jobs | 148 | # 查看 GitCode PR 的 CI 运行、详情和 Jobs |
| 149 | -gc actions run list -R gitcode-cli/cli --pr <pr-number> --workflow "CI" --json | 149 | +gc actions run list -R atomgit-cli/cli --pr <pr-number> --workflow "CI" --json |
| 150 | -gc actions run view <run-id> -R gitcode-cli/cli --json | 150 | +gc actions run view <run-id> -R atomgit-cli/cli --json |
| 151 | -gc actions job list <run-id> -R gitcode-cli/cli --json | 151 | +gc actions job list <run-id> -R atomgit-cli/cli --json |
| 152 | ``` | 152 | ``` |
| 153 | 153 | ||
| 154 | 如果存在对应的 GitHub 镜像 PR,再通过 `gh` 核验跨平台 CI: | 154 | 如果存在对应的 GitHub 镜像 PR,再通过 `gh` 核验跨平台 CI: |
| @@ -167,7 +167,7 @@ CI 通过标准: | |||
| 167 | 167 | ||
| 168 | CI 失败处理: | 168 | CI 失败处理: |
| 169 | 169 | ||
| 170 | -- GitCode:通过 `gc actions job log <run-id> <job-id> -R gitcode-cli/cli --output job-log.zip` 获取失败日志 | 170 | +- GitCode:通过 `gc actions job log <run-id> <job-id> -R atomgit-cli/cli --output job-log.zip` 获取失败日志 |
| 171 | - GitHub:通过 `gh run view <run-id> --log --job=<job-id>` 获取失败日志 | 171 | - GitHub:通过 `gh run view <run-id> --log --job=<job-id>` 获取失败日志 |
| 172 | - 分析根因并修复,修复后重新推送并重新触发 CI | 172 | - 分析根因并修复,修复后重新推送并重新触发 CI |
| 173 | - 如是环境/平台偶发问题(非代码问题),在自检中记录后仍可继续 | 173 | - 如是环境/平台偶发问题(非代码问题),在自检中记录后仍可继续 |
| @@ -0,0 +1,58 @@ | |||
| 1 | +package contracts | ||
| 2 | + | ||
| 3 | +import ( | ||
| 4 | + "path/filepath" | ||
| 5 | + "reflect" | ||
| 6 | + "regexp" | ||
| 7 | + "sort" | ||
| 8 | + "strings" | ||
| 9 | + "testing" | ||
| 10 | +) | ||
| 11 | + | ||
| 12 | +var quotedNamePattern = regexp.MustCompile(`"[^"]+"`) | ||
| 13 | + | ||
| 14 | +func extractQuotedNames(t *testing.T, content string, pattern *regexp.Regexp, source string) []string { | ||
| 15 | + t.Helper() | ||
| 16 | + match := pattern.FindStringSubmatch(content) | ||
| 17 | + if match == nil { | ||
| 18 | + t.Fatalf("failed to locate %s", source) | ||
| 19 | + } | ||
| 20 | + names := quotedNamePattern.FindAllString(match[1], -1) | ||
| 21 | + if len(names) == 0 { | ||
| 22 | + t.Fatalf("no quoted names found in %s", source) | ||
| 23 | + } | ||
| 24 | + for i, name := range names { | ||
| 25 | + names[i] = strings.Trim(name, `"`) | ||
| 26 | + } | ||
| 27 | + sort.Strings(names) | ||
| 28 | + return names | ||
| 29 | +} | ||
| 30 | + | ||
| 31 | +// TestNPMCoordinateAllowlistsStayInSync asserts that the installer's symlink | ||
| 32 | +// migration allowlist (OWN_NPM_PACKAGES in npm/lib/install.js) and the release | ||
| 33 | +// assembly allowlist (NPM_COORDINATES in scripts/prepare-npm-package.sh) | ||
| 34 | +// carry the same coordinate set. A coordinate shipped through the release | ||
| 35 | +// pipeline but missing from the installer would recreate the hard-refusal | ||
| 36 | +// fixed in issue #591 for leftovers of that coordinate's classic global | ||
| 37 | +// installs. | ||
| 38 | +func TestNPMCoordinateAllowlistsStayInSync(t *testing.T) { | ||
| 39 | + installer := extractQuotedNames( | ||
| 40 | + t, | ||
| 41 | + readRepositoryFile(t, filepath.Join("npm", "lib", "install.js")), | ||
| 42 | + regexp.MustCompile(`(?s)const OWN_NPM_PACKAGES = \[([^\]]*)\]`), | ||
| 43 | + "OWN_NPM_PACKAGES in npm/lib/install.js", | ||
| 44 | + ) | ||
| 45 | + release := extractQuotedNames( | ||
| 46 | + t, | ||
| 47 | + readRepositoryFile(t, filepath.Join("scripts", "prepare-npm-package.sh")), | ||
| 48 | + regexp.MustCompile(`(?s)readonly NPM_COORDINATES=\(([^)]*)\)`), | ||
| 49 | + "NPM_COORDINATES in scripts/prepare-npm-package.sh", | ||
| 50 | + ) | ||
| 51 | + if !reflect.DeepEqual(installer, release) { | ||
| 52 | + t.Fatalf( | ||
| 53 | + "npm coordinate allowlists drifted: installer OWN_NPM_PACKAGES=%v, release NPM_COORDINATES=%v; keep them in sync to avoid recreating the issue #591 hard refusal", | ||
| 54 | + installer, | ||
| 55 | + release, | ||
| 56 | + ) | ||
| 57 | + } | ||
| 58 | +} | ||