Skip to content

ci: add VS Code extension publish workflow - #3332

Merged
wbxl2000 merged 2 commits into
mainfrom
ci/vscode-publish-workflow
Aug 28, 2026
Merged

ci: add VS Code extension publish workflow#3332
wbxl2000 merged 2 commits into
mainfrom
ci/vscode-publish-workflow

Conversation

@wbxl2000

Copy link
Copy Markdown
Collaborator

背景

0.7.3 手动发版(VS Marketplace + Open VSX,全 6 平台)已全流程跑通。本 PR 把这套流程固化成自动 CI 流水线,只新增 .github/workflows/vscode-publish.yml,不动任何现有文件。

设计说明

触发

  • pushmain:仅当本次 push 改动了 apps/vscode/package.jsonversion(即 changesets 版本 PR "ci: release packages" 合入)才进入发布。版本号比较基于 push 的 SHA(git show $GITHUB_SHA~1:...),不读工作区——与 kimi-code-app 仓 desktop release.yml 的判定方式一致。普通 PR 合入不会改变版本号,不会发布。
  • workflow_dispatch:手动兜底,跳过版本号变化检查,直接进入后续幂等闸门。

闸门(发布前查线上,双保险之一)

  • VS Marketplace:vsce show moonshot-ai.kimi-code --json(仓内 pinned 的 @vscode/vsce),版本已在线则跳过 publish:vsix
  • Open VSX:GET https://open-vsx.org/api/moonshot-ai/kimi-code/<version>,200 则跳过 publish:ovsx
  • 查询失败按"未发布"处理(fail-closed),交给 publish 步骤决定成败。

步骤链(与 0.7.3 手动发版完全一致)
pnpm install --frozen-lockfilepackage:platform(全 6 平台,自带 tsdown 打包,无需前置 build)→ package:verify → 上传 vsix 为 workflow artifact(retention 14 天,便于回溯审计)→ extension host 冒烟(xvfb-run,VS Code 1.100.0 = engines.vscode 下限,与手动冒烟口径一致)→ publish:vsixsecrets.VSCE_PAT)→ publish:ovsxsecrets.OVSX_PAT)。

幂等与并发

  • 双保险之二:发布脚本自身带 --skip-duplicate(vsce)/ already-exists 跳过(ovsx),单包失败即中止,整体可安全重跑;
  • concurrency: ${{ github.workflow }}-${{ github.ref }} 防并发重复发布;
  • 失败即停,不自动重试 publish。

权限contents: readif: github.repository_owner == 'MoonshotAI' 避免 fork 上误跑。

⚠️ 管理员待办:secrets 配置

需仓库管理员预先配置 secrets:VSCE_PAT(VS Marketplace PAT)与 OVSX_PAT(Open VSX access token)。workflow 内有前置检查步骤,未配置 secrets 时会以明确报错失败,属预期

首次启用建议

合并后先用 workflow_dispatch 对一个已发布版本(如 0.7.3)空跑一次:应观察到闸门识别双市场已在线、两个 publish 步骤被跳过,打包/校验/冒烟全绿——以此验证跳过逻辑,再等待首个真实版本 PR 触发。

验证方式(本 PR 已做)

  • actionlint v1.7.7 通过,零告警;
  • 全部 run 脚本块 bash -n 语法检查通过;
  • 闸门逻辑在本地 git 仓库模拟四种场景实测通过:① push 改版本 → should_publish=true;② push 未改版本 → should_publish=false;③ workflow_dispatch → 跳过版本检查;④ 对线上 0.7.3 真实查询 → 双市场均正确识别"已发布"。
  • 实际发布行为需合并后观察首次触发(语法与逻辑已静态检查 + 本地模拟)。

注意点

  • runner 为非 root 用户(homedir /home/runner),vsix-verify.mjs 的 homedir 禁词扫描不会像 root 下那样误报;fix(vscode): match homedir with boundaries in vsix-verify #3305(homedir 边界匹配修复)合入后更稳,但本 workflow 不依赖它。
  • 冒烟固定 VS Code 1.100.0(@vscode/test-electron 按精确版本缓存);后续可随 engines.vscode 下限上调。
  • 冒烟步骤的 GUI 依赖(xvfb/libgtk-3-0/libgbm1/libasound2t64)在 ubuntu-latest 上显式 apt 安装,与 0.7.3 手动冒烟环境清单一致。

源自 0.7.3 手动发版实战(tkt_SqwQhnD-Ue2D / tkt_1pc7xOiv65pA)。

Publish VSIX to VS Marketplace and Open VSX on version-change pushes
to main, with online-version gates and workflow_dispatch fallback.
@changeset-bot

changeset-bot Bot commented Aug 28, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: a8cac59

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Aug 28, 2026

Copy link
Copy Markdown
pnpm dlx https://pkg.pr.new/@moonshot-ai/kimi-code@a8cac59
npx https://pkg.pr.new/@moonshot-ai/kimi-code@a8cac59

commit: a8cac59

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +94 to +97
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"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已修复:线上闸门改为逐平台核验,6 个 targetPlatform(darwin/linux/win32 × x64/arm64)全部在线才跳过对应市场的发布步骤;Open VSX 按平台逐一 REST 查询,VS Marketplace 检查 vsce show --json 里该版本的 targetPlatform 条目。任一平台缺失(如上次部分发布失败)即放行给发布步骤,由脚本的 --skip-duplicate / already-exists 幂等补齐;查询失败保持 fail-closed(视为未发布)。修复 commit:a8cac5935

Comment thread .github/workflows/vscode-publish.yml Outdated
Comment on lines +74 to +75
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")"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已修复:比较基准从 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).
@wbxl2000

Copy link
Copy Markdown
Collaborator Author

@codex

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep it up!

Reviewed commit: a8cac5935e

ℹ️ 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".

@wbxl2000
wbxl2000 merged commit 44b40e6 into main Aug 28, 2026
25 of 26 checks passed
@wbxl2000
wbxl2000 deleted the ci/vscode-publish-workflow branch August 28, 2026 11:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants