Repository navigation
fix(ci): force-push release branch so retries replace failed attempts (#9076) #9082
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 6 commits
807940a
d83f72e
d8422c8
be388a5
43ca009
6754c22
4301929
044fa33
45e5f84
298e729
71a3250
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -180,7 +180,7 @@ function detectRollbackAndGetBaseline(npmDistTag) { | |||||||||||||
| * All packages that share the same release version. A version is considered | ||||||||||||||
| * "taken" if it exists on *any* of them — not just the main package. | ||||||||||||||
| */ | ||||||||||||||
| const PUBLISHED_PACKAGES = [ | ||||||||||||||
| export const PUBLISHED_PACKAGES = [ | ||||||||||||||
| '@qwen-code/qwen-code', | ||||||||||||||
| '@qwen-code/audio-capture', | ||||||||||||||
| '@qwen-code/channel-base', | ||||||||||||||
|
|
@@ -193,31 +193,76 @@ const PUBLISHED_PACKAGES = [ | |||||||||||||
| '@qwen-code/channel-weixin', | ||||||||||||||
| ]; | ||||||||||||||
|
|
||||||||||||||
| function doesVersionExist(version) { | ||||||||||||||
| function doesVersionExist(version, { strict = false, shippedTo } = {}) { | ||||||||||||||
| // Check NPM across all published packages | ||||||||||||||
| const shippedPackages = []; | ||||||||||||||
| for (const pkg of PUBLISHED_PACKAGES) { | ||||||||||||||
| try { | ||||||||||||||
| const command = `npm view ${pkg}@${version} version 2>/dev/null`; | ||||||||||||||
| // The best-effort path silences npm's expected E404 noise; strict | ||||||||||||||
| // mode needs that stderr to tell "absent" from a failed probe. | ||||||||||||||
| const command = strict | ||||||||||||||
| ? `npm view ${pkg}@${version} version` | ||||||||||||||
| : `npm view ${pkg}@${version} version 2>/dev/null`; | ||||||||||||||
|
Comment on lines
+203
to
+205
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Suggestion]
Suggested change
— deepseek-v4-flash via Qwen Code /review (v0.21.11) 中文说明
— deepseek-v4-flash via Qwen Code /review (v0.21.11)
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Declined — not worth the diff growth. The guard's Also, the suggested regex is not end-anchored, so it accepts the finding's own injection example: Implementing it as suggested would grow the diff without closing the hypothetical hole. 中文说明不予采纳——不值得增加 diff。该守卫的 另外,建议的正则未做结尾锚定,因此它会放行该发现自己举的注入示例: 按建议原样实现会增大 diff,却无法堵住这个假想的漏洞。 |
||||||||||||||
| const output = execSync(command).toString().trim(); | ||||||||||||||
| if (output === version) { | ||||||||||||||
| console.error(`Version ${version} already exists on NPM (${pkg}).`); | ||||||||||||||
| return true; | ||||||||||||||
| if (!strict) { | ||||||||||||||
| console.error(`Version ${version} already exists on NPM (${pkg}).`); | ||||||||||||||
| return true; | ||||||||||||||
| } | ||||||||||||||
| shippedPackages.push(pkg); | ||||||||||||||
| } | ||||||||||||||
| } catch (error) { | ||||||||||||||
| // E404 means the version is absent from this package. Strict mode | ||||||||||||||
| // guards the force push, so any other probe failure is "cannot | ||||||||||||||
| // verify" and must throw instead of passing. | ||||||||||||||
| if (strict && !error.message?.includes('E404')) { | ||||||||||||||
| throw new Error( | ||||||||||||||
| `Failed to verify ${pkg}@${version} on npm: ${error.message}`, | ||||||||||||||
| ); | ||||||||||||||
| } | ||||||||||||||
| } catch (_error) { | ||||||||||||||
| // This is expected if the version doesn't exist on this package. | ||||||||||||||
| } | ||||||||||||||
| } | ||||||||||||||
| // Strict mode scans every package instead of stopping at the first hit | ||||||||||||||
| // so a partial publish's refusal can name everything that shipped. A hit | ||||||||||||||
| // ends the check: the remaining probes can no longer change the outcome, | ||||||||||||||
| // and a failed one would mask the refusal's recovery guidance. | ||||||||||||||
| if (shippedPackages.length > 0) { | ||||||||||||||
| console.error( | ||||||||||||||
| `Version ${version} already exists on NPM (${shippedPackages.join(', ')}).`, | ||||||||||||||
| ); | ||||||||||||||
| shippedTo?.push(...shippedPackages); | ||||||||||||||
| return true; | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| // Check Git tags | ||||||||||||||
| // Check Git tags. Push-time callers pass strict: the checkout at job | ||||||||||||||
| // start can only know tags that existed when the job began, and the | ||||||||||||||
| // version may ship between that fetch and this push — check origin. | ||||||||||||||
| try { | ||||||||||||||
| if (strict) { | ||||||||||||||
| execSync(`git ls-remote --exit-code origin "refs/tags/v${version}"`); | ||||||||||||||
| console.error(`Git tag v${version} already exists on origin.`); | ||||||||||||||
| shippedTo?.push(`origin tag v${version}`); | ||||||||||||||
| return true; | ||||||||||||||
| } | ||||||||||||||
| const command = `git tag -l 'v${version}'`; | ||||||||||||||
| const tagOutput = execSync(command).toString().trim(); | ||||||||||||||
| if (tagOutput === `v${version}`) { | ||||||||||||||
| console.error(`Git tag v${version} already exists.`); | ||||||||||||||
| return true; | ||||||||||||||
| } | ||||||||||||||
| } catch (error) { | ||||||||||||||
| console.error(`Failed to check git tags for conflicts: ${error.message}`); | ||||||||||||||
| if (strict) { | ||||||||||||||
| // ls-remote exits 2 when no ref matches; that is "tag absent". Any | ||||||||||||||
| // other failure means the check could not run — fail the push | ||||||||||||||
| // instead of reading a failed check as "unreleased". | ||||||||||||||
| if (error.status !== 2) { | ||||||||||||||
| throw new Error( | ||||||||||||||
| `Failed to verify tag v${version} on origin: ${error.message}`, | ||||||||||||||
| ); | ||||||||||||||
| } | ||||||||||||||
| } else { | ||||||||||||||
| console.error(`Failed to check git tags for conflicts: ${error.message}`); | ||||||||||||||
| } | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| // Check GitHub releases | ||||||||||||||
|
|
@@ -226,10 +271,16 @@ function doesVersionExist(version) { | |||||||||||||
| const output = execSync(command).toString().trim(); | ||||||||||||||
| if (output === `v${version}`) { | ||||||||||||||
| console.error(`GitHub release v${version} already exists.`); | ||||||||||||||
| shippedTo?.push(`GitHub release v${version}`); | ||||||||||||||
| return true; | ||||||||||||||
| } | ||||||||||||||
| } catch (error) { | ||||||||||||||
| if (!isExpectedMissingGitHubRelease(error)) { | ||||||||||||||
| if (strict) { | ||||||||||||||
| throw new Error( | ||||||||||||||
| `Failed to verify release v${version} on GitHub: ${error.message}`, | ||||||||||||||
| ); | ||||||||||||||
| } | ||||||||||||||
| console.error( | ||||||||||||||
| `Failed to check GitHub releases for conflicts: ${error.message}`, | ||||||||||||||
| ); | ||||||||||||||
|
|
@@ -239,6 +290,28 @@ function doesVersionExist(version) { | |||||||||||||
| return false; | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| /** | ||||||||||||||
| * Push-time re-validation of prepare's doesVersionExist invariant, for the | ||||||||||||||
| * release branch force push. Throws when the version has shipped anywhere | ||||||||||||||
| * (an error coded VERSION_SHIPPED, naming where it was found), or when a | ||||||||||||||
| * probe cannot run — a failed probe must not read as "unreleased". | ||||||||||||||
| */ | ||||||||||||||
| export function assertVersionUnreleased(version) { | ||||||||||||||
| if (typeof version !== 'string' || version.length === 0) { | ||||||||||||||
| throw new Error( | ||||||||||||||
| 'assert-unreleased requires a version, e.g. --assert-unreleased=1.2.3', | ||||||||||||||
| ); | ||||||||||||||
| } | ||||||||||||||
| const shippedTo = []; | ||||||||||||||
| if (doesVersionExist(version, { strict: true, shippedTo })) { | ||||||||||||||
| const error = new Error( | ||||||||||||||
| `Version ${version} has already shipped; refusing to force-push the release branch over it. Found on: ${shippedTo.join(', ')}. If a previous attempt published only part of the release, complete the remaining artifacts manually — re-running this job will keep failing here while the version stays published.`, | ||||||||||||||
| ); | ||||||||||||||
| error.code = 'VERSION_SHIPPED'; | ||||||||||||||
| throw error; | ||||||||||||||
| } | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| function getAndVerifyTags(npmDistTag, _gitTagPattern) { | ||||||||||||||
| // Detect rollback scenarios and get the correct baseline | ||||||||||||||
| const rollbackInfo = detectRollbackAndGetBaseline(npmDistTag); | ||||||||||||||
|
|
@@ -508,6 +581,32 @@ export function getVersion(options = {}) { | |||||||||||||
| return result; | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| /** | ||||||||||||||
| * CLI dispatch, exported for tests: `--assert-unreleased=<version>` runs | ||||||||||||||
| * the push-time guard; anything else prints the version JSON. Returns the | ||||||||||||||
| * exit code. Guard codes: 0 = unreleased, 3 = already shipped (a decisive, | ||||||||||||||
| * benign refusal the workflow marks to skip the release-failed | ||||||||||||||
| * notification), 2 = probe or usage failure. 1 is never returned on | ||||||||||||||
| * purpose: node exits 1 on uncaught errors, and those must stay on the | ||||||||||||||
| * real-failure path. | ||||||||||||||
| */ | ||||||||||||||
| export function runCli(args) { | ||||||||||||||
| if (args['assert-unreleased'] !== undefined) { | ||||||||||||||
| try { | ||||||||||||||
| assertVersionUnreleased(args['assert-unreleased']); | ||||||||||||||
| } catch (error) { | ||||||||||||||
| console.error(`::error::${error.message}`); | ||||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Suggestion] GitHub Actions parses workflow commands like
Suggested change
— deepseek-v4-flash via Qwen Code /review (v0.21.11) 中文说明
— deepseek-v4-flash via Qwen Code /review (v0.21.11) |
||||||||||||||
| return error.code === 'VERSION_SHIPPED' ? 3 : 2; | ||||||||||||||
| } | ||||||||||||||
| return 0; | ||||||||||||||
| } | ||||||||||||||
| console.log(JSON.stringify(getVersion(args), null, 2)); | ||||||||||||||
| return 0; | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| if (process.argv[1] === fileURLToPath(import.meta.url)) { | ||||||||||||||
| console.log(JSON.stringify(getVersion(getArgs()), null, 2)); | ||||||||||||||
| const exitCode = runCli(getArgs()); | ||||||||||||||
| if (exitCode !== 0) { | ||||||||||||||
| process.exit(exitCode); | ||||||||||||||
| } | ||||||||||||||
| } | ||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deferred — critical-only mode is active on this PR, so non-Critical automated-reviewer suggestions are not implemented in this round. The suggested fix (commenting on an open “Release Failed” issue on refusal, or writing the refusal detail to the step summary) extends release.yml’s notification path and needs a design call beyond this round’s scope; it stays open for human follow-up.
中文说明
暂缓 —— 本 PR 已触发仅处理 Critical 的模式,本轮不实施自动审查器的非 Critical 建议。建议的修复(拒绝时在已打开的 “Release Failed” issue 上评论,或将拒绝明细写入步骤摘要)会扩展 release.yml 的通知路径,需要超出本轮范围的设计决策;保持开放,留待人工跟进。