ci: add VS Code extension publish workflow - #3332
Conversation
Publish VSIX to VS Marketplace and Open VSX on version-change pushes to main, with online-version gates and workflow_dispatch fallback.
|
commit: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 11d8d2f64f
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| if pnpm --filter kimi-code exec vsce show moonshot-ai.kimi-code --json \ | ||
| | node -e "const v=process.argv[1];let d='';process.stdin.on('data',c=>d+=c).on('end',()=>{const j=JSON.parse(d);process.exit((j.versions||[]).some(x=>x.version===v)?0:1)})" "${version}"; then | ||
| echo "${version} is already on VS Marketplace — publish:vsix will be skipped" | ||
| echo "vsix_published=true" >> "$GITHUB_OUTPUT" |
There was a problem hiding this comment.
Do not skip recovery after a partial platform publish
When one platform VSIX publishes successfully and a later platform fails, apps/vscode/scripts/vsix-publish.mjs aborts its six-target loop, but this gate treats the presence of any entry for the version as proof that the entire release is published. A rerun will therefore skip the VS Marketplace step and permanently leave the remaining platforms unpublished unless someone intervenes manually. Check that every expected target is present, or rely on the per-package --skip-duplicate behavior so retries can finish the incomplete release.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
已修复:线上闸门改为逐平台核验,6 个 targetPlatform(darwin/linux/win32 × x64/arm64)全部在线才跳过对应市场的发布步骤;Open VSX 按平台逐一 REST 查询,VS Marketplace 检查 vsce show --json 里该版本的 targetPlatform 条目。任一平台缺失(如上次部分发布失败)即放行给发布步骤,由脚本的 --skip-duplicate / already-exists 幂等补齐;查询失败保持 fail-closed(视为未发布)。修复 commit:a8cac5935
| if git show "${GITHUB_SHA}~1:${pkg}" > /tmp/prev-vscode-pkg.json 2> /dev/null; then | ||
| prev="$(node -p "require('/tmp/prev-vscode-pkg.json').version")" |
There was a problem hiding this comment.
Compare against the push's previous revision
When a single push advances main by multiple commits and the extension version changes before the final commit, ${GITHUB_SHA}~1 already contains the new version, so this gate reports it unchanged and silently skips the release. The push event's before SHA represents the actual pre-push revision and should be used for this comparison; this also avoids assuming every push contains exactly one commit.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
已修复:比较基准从 GITHUB_SHA~1 改为 push 事件的 before SHA(github.event.before),单次 push 含多个 commit 时也能正确检出旧版本号;before 为空或全 0(如新分支首推)时保守判定为版本变化放行 —— 宁可多查一次线上闸门,不可漏发。修复 commit:a8cac5935
… checks Address review on the auto-publish workflow: - Version-change detection now compares against the push event's `before` SHA instead of `GITHUB_SHA~1`, so a single push carrying multiple commits cannot skip a version bump. An empty or all-zero `before` (e.g. first push of a branch) is treated as a version change — better an extra marketplace lookup than a missed release. - Marketplace gates now verify all 6 targetPlatforms (darwin/linux/win32 x x64/arm64) instead of only the version number: Open VSX is checked per-platform via REST, VS Marketplace via the targetPlatform entries in `vsce show --json`. A partially published version now reruns the affected publish step, which backfills idempotently via --skip-duplicate / already-exists handling. Lookup failures stay fail-closed (treated as not published).
|
Codex Review: Didn't find any major issues. Keep it up! Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
背景
0.7.3 手动发版(VS Marketplace + Open VSX,全 6 平台)已全流程跑通。本 PR 把这套流程固化成自动 CI 流水线,只新增
.github/workflows/vscode-publish.yml,不动任何现有文件。设计说明
触发
push到main:仅当本次 push 改动了apps/vscode/package.json的version(即 changesets 版本 PR"ci: release packages"合入)才进入发布。版本号比较基于 push 的 SHA(git show $GITHUB_SHA~1:...),不读工作区——与 kimi-code-app 仓 desktoprelease.yml的判定方式一致。普通 PR 合入不会改变版本号,不会发布。workflow_dispatch:手动兜底,跳过版本号变化检查,直接进入后续幂等闸门。闸门(发布前查线上,双保险之一)
vsce show moonshot-ai.kimi-code --json(仓内 pinned 的 @vscode/vsce),版本已在线则跳过publish:vsix;GET https://open-vsx.org/api/moonshot-ai/kimi-code/<version>,200 则跳过publish:ovsx;步骤链(与 0.7.3 手动发版完全一致)
pnpm install --frozen-lockfile→package:platform(全 6 平台,自带 tsdown 打包,无需前置 build)→package:verify→ 上传 vsix 为 workflow artifact(retention 14 天,便于回溯审计)→ extension host 冒烟(xvfb-run,VS Code 1.100.0 =engines.vscode下限,与手动冒烟口径一致)→publish:vsix(secrets.VSCE_PAT)→publish:ovsx(secrets.OVSX_PAT)。幂等与并发
--skip-duplicate(vsce)/ already-exists 跳过(ovsx),单包失败即中止,整体可安全重跑;concurrency: ${{ github.workflow }}-${{ github.ref }}防并发重复发布;权限:
contents: read;if: github.repository_owner == 'MoonshotAI'避免 fork 上误跑。需仓库管理员预先配置 secrets:
VSCE_PAT(VS Marketplace PAT)与OVSX_PAT(Open VSX access token)。workflow 内有前置检查步骤,未配置 secrets 时会以明确报错失败,属预期。首次启用建议
合并后先用
workflow_dispatch对一个已发布版本(如 0.7.3)空跑一次:应观察到闸门识别双市场已在线、两个 publish 步骤被跳过,打包/校验/冒烟全绿——以此验证跳过逻辑,再等待首个真实版本 PR 触发。验证方式(本 PR 已做)
actionlintv1.7.7 通过,零告警;run脚本块bash -n语法检查通过;should_publish=true;② push 未改版本 →should_publish=false;③workflow_dispatch→ 跳过版本检查;④ 对线上 0.7.3 真实查询 → 双市场均正确识别"已发布"。注意点
/home/runner),vsix-verify.mjs的 homedir 禁词扫描不会像 root 下那样误报;fix(vscode): match homedir with boundaries in vsix-verify #3305(homedir 边界匹配修复)合入后更稳,但本 workflow 不依赖它。engines.vscode下限上调。源自 0.7.3 手动发版实战(tkt_SqwQhnD-Ue2D / tkt_1pc7xOiv65pA)。