fix(desktop): align rollout approval with parsed percentage
This commit is contained in:
1 parent
d6649ac75b
commit
05b12e4aff
7 files changed
+29
-18
No files matched your search
+1
-1
@@ -8,4 +8,4 @@ The merge checks run from three workflows named `Policy`, which run on `pull_req
|
||||
|
||||
The manual Desktop publication workflow selects the original successful `package` job attempt independently of `upload-artifact` archival status, then routes each retained build through `DESKTOP_PUBLISH_RUNNERS` to its original machine's unique label. Keep Windows run steps on native PowerShell and Mac run steps on the default POSIX shell; shared entrypoints are Node scripts. Test and production jobs use separate `desktop-test` and `desktop-production` approval Environments after a credential-free preparation job.
|
||||
|
||||
`Publish Desktop · Rollout & Website` reuses the same original-machine routing and approval Environments. Its preparation reads retained metadata and initial publication evidence without revalidating package binaries; it does not create release tags. Cache-only recovery uses the existing website approval and upload journal. Rollout installs only publisher production dependencies in `desktop-rollout` and `website-rollout` checkouts; do not reuse the full-install publication checkouts. Both publication workflows run dependency-free preflights from `apps/desktop-publisher/src`. The required CI verdicts include isolated publisher installation checks: Linux/macOS in `ci.yml`, native Windows in `ci-windows.yml`.
|
||||
`Publish Desktop · Rollout & Website` reuses the same original-machine routing and approval Environments. Its preparation reads retained metadata and initial publication evidence without revalidating package binaries; it does not create release tags. Cache-only recovery validates the prepared website approval digest and upload journal without another Environment approval. Rollout installs only publisher production dependencies in `desktop-rollout` and `website-rollout` checkouts; do not reuse the full-install publication checkouts. Both publication workflows run dependency-free preflights from `apps/desktop-publisher/src`. The required CI verdicts include isolated publisher installation checks: Linux/macOS in `ci.yml`, native Windows in `ci-windows.yml`.
|
||||
@@ -67,6 +67,7 @@ jobs:
|
||||
outputs:
|
||||
route: ${{ steps.local.outputs.route }}
|
||||
preset: ${{ steps.local.outputs.preset }}
|
||||
rollout-requested: ${{ steps.check.outputs.rollout-requested }}
|
||||
approval: ${{ steps.check.outputs.approval }}
|
||||
website-approval: ${{ steps.check.outputs.website-approval }}
|
||||
website-destination: ${{ steps.check.outputs.website-destination }}
|
||||
@@ -109,9 +110,9 @@ jobs:
|
||||
run: node --import tsx src/publish-desktop-rollout-ci.ts check
|
||||
|
||||
publish:
|
||||
if: inputs.rollout_percentage != ''
|
||||
name: Approve ${{ needs.prepare.outputs.label }}
|
||||
needs: [route, prepare]
|
||||
if: needs.prepare.outputs.rollout-requested == 'true'
|
||||
runs-on: [self-hosted, '${{ needs.route.outputs.runner }}']
|
||||
environment: ${{ needs.prepare.outputs.preset == 'production' && 'desktop-production' || 'desktop-test' }}
|
||||
concurrency:
|
||||
@@ -162,8 +163,9 @@ jobs:
|
||||
retention-days: 30
|
||||
|
||||
upload-website-installer:
|
||||
name: Website ${{ needs.prepare.outputs.label }}
|
||||
needs: [route, prepare, publish]
|
||||
if: ${{ !cancelled() && inputs.upload_website && needs.prepare.result == 'success' && needs.prepare.outputs.preset != 'test' && (needs.publish.result == 'success' || (needs.publish.result == 'skipped' && inputs.rollout_percentage == '')) }}
|
||||
if: ${{ !cancelled() && inputs.upload_website && needs.prepare.result == 'success' && needs.prepare.outputs.preset != 'test' && (needs.publish.result == 'success' || (needs.publish.result == 'skipped' && needs.prepare.outputs.rollout-requested == 'false')) }}
|
||||
runs-on: [self-hosted, '${{ needs.route.outputs.runner }}']
|
||||
environment: desktop-production
|
||||
timeout-minutes: 60
|
||||
|
||||
@@ -84,7 +84,7 @@ export async function publishDesktopRolloutCi(mode: 'check' | 'apply' | 'website
|
||||
const { route, root, recordsRoot, config, manifest, plan, target, website, destination, approval } = context
|
||||
if (mode === 'check') {
|
||||
if (env.GITHUB_OUTPUT) await appendFile(env.GITHUB_OUTPUT,
|
||||
`approval=${approval}\nwebsite-approval=${websiteApproval(manifest, config.bucket)}\nwebsite-destination=${createHash('sha256').update(`${config.bucket}/${route.target}`).digest('hex')}\nlabel=${manifest.source.version} / ${route.channel} / ${route.target} → ${target === undefined ? 'website only' : `${target}%`}\n`)
|
||||
`rollout-requested=${target !== undefined}\napproval=${approval}\nwebsite-approval=${websiteApproval(manifest, config.bucket)}\nwebsite-destination=${createHash('sha256').update(`${config.bucket}/${route.target}`).digest('hex')}\nlabel=${manifest.source.version} / ${route.channel} / ${route.target} → ${target === undefined ? 'website only' : `${target}%`}\n`)
|
||||
if (env.GITHUB_STEP_SUMMARY && !env.DESKTOP_ROLLOUT_APPROVAL) await appendFile(env.GITHUB_STEP_SUMMARY,
|
||||
`## 桌面放量与官网发布确认\n\n打包运行:${route.runId} / 第 ${route.attempt} 次;版本:${manifest.source.version};平台:${route.target};环境 / 渠道:${route.preset} / ${route.channel}。\n\n目标放量比例:${target === undefined ? '保持当前比例' : `${target}%`}。执行时从 COS 核对当前比例,不允许降低比例。\n\n官网:${website ? desktopWebsiteInstallerUrl(route.target) + '(上传安装包并刷新缓存)' : '不变'}。${website ? '官网安装包面向所有下载用户,不受自动更新放量比例限制,也不要求放量达到 100%。固定下载地址无防降级保护,发布较早版本会替换较新安装包。' : ''}\n\n已确认首次 COS 发布记录;不重新计算全部安装包哈希或校验签名。\n`)
|
||||
return
|
||||
|
||||
@@ -27,11 +27,11 @@
|
||||
en: 6325c71df74a9915
|
||||
zh: edaa8a4502ed80a1
|
||||
/desktop-ci-publication/rollout-and-website-publication:
|
||||
en: 2246b060fc03c9a2
|
||||
zh: ea43c995ac7aa593
|
||||
en: bdb414ffe0f8c051
|
||||
zh: 3a6014ffbbec81f1
|
||||
/desktop-ci-publication/recovery-and-records:
|
||||
en: d6eb9cbac5b819a0
|
||||
zh: 0de1ec24055d1007
|
||||
en: e99be89c81a50a3c
|
||||
zh: 1643ad2760ed08e3
|
||||
/desktop-ci-publication/restore-a-channel:
|
||||
en: d82e2ccf70cce397
|
||||
zh: d93dcb77cc4b463e
|
||||
|
||||
@@ -87,7 +87,7 @@ For a 10% → 30% → 100% rollout, first publish through COS with `staging_perc
|
||||
|
||||
Preparation checks GitHub identity, the retained manifest, the small update YAML and a completed initial publication record; it does not rehash package binaries or repeat signature/notarization checks. After Environment approval, execution reads the current COS feed, verifies that its version, payload URL, size, hash and other metadata still match the published package, and changes only `stagingPercentage`. Missing or replaced feeds reject the operation. Repeating the same percentage is a no-op; lowering the percentage is rejected. The approval shows the requested percentage; the current percentage is read from COS during execution.
|
||||
|
||||
Website upload reuses the original retained installer, hashes that installer alone and uses the existing upload/purge recovery records. Cache-only retries use the existing website approval and upload journal without requiring the retained update YAML or initial feed journal. The website upload holds the feed channel lock through installer verification and upload so a newer feed cannot replace the selected version midway; competing publications on that channel fail while the lock is held. A metadata-only rollout therefore does not require installer files, but website publication requires its installer. Percentage changes retain before/after YAML in separate rollout audit records. Initial COS publication remains required; this workflow never builds packages, uploads versioned binaries or creates release tags.
|
||||
Website upload reuses the original retained installer, hashes that installer alone and uses the existing upload/purge recovery records. Rollout cache-only retries validate the prepared website approval digest and upload journal without another Environment approval without requiring the retained update YAML or initial feed journal. The website upload holds the feed channel lock through installer verification and upload so a newer feed cannot replace the selected version midway; competing publications on that channel fail while the lock is held. A metadata-only rollout therefore does not require installer files, but website publication requires its installer. Percentage changes retain before/after YAML in separate rollout audit records. Initial COS publication remains required; this workflow never builds packages, uploads versioned binaries or creates release tags.
|
||||
|
||||
<a id="recovery-and-records"></a>
|
||||
|
||||
@@ -99,7 +99,7 @@ The packaging workflows separate `package` from `upload-artifact` (GitHub artifa
|
||||
|
||||
Production COS publication enables website installer upload and cache refresh by default (`upload_website=true`). Clear it to publish only versioned resources and automatic-update feeds; test publication never changes the production website. `upload-website-installer` uploads the fixed installer and `purge-website-installer` refreshes its URL. The website installer validator needs only the final DMG/EXE and retained manifest. It matches production qualification, build identity and target, hashes the installer once and uploads through the same open file handle. Both production nightly and stable packages can replace the fixed website installer. Operators select the intended version; the fixed object has no downgrade protection, so rerunning an older publication can replace a newer installer. The pre-approval summary names the fixed website URL, selected version and lack of downgrade protection when website upload is selected. The existing version/update publication retains its own checks.
|
||||
|
||||
Set the repository variable `DOWNLOAD_PROD_EO_ZONE_ID` to the production EdgeOne zone. The production COS credential pair also needs `teo:CreatePurgeTask` and `teo:DescribePurgeTasks`. Website uploads serialize by bucket/target in Actions and by bucket/object on the original machine. Cache observation runs separately. Version publication, website upload and cache refresh each use the production approval Environment; later jobs and reruns may require another approval. GitHub concurrency retains at most one pending job per group, so a newer pending job can cancel an older pending job; inspect canceled jobs before rerunning them.
|
||||
Set the repository variable `DOWNLOAD_PROD_EO_ZONE_ID` to the production EdgeOne zone. The production COS credential pair also needs `teo:CreatePurgeTask` and `teo:DescribePurgeTasks`. Website uploads serialize by bucket/target in Actions and by bucket/object on the original machine. Cache observation runs separately. In the COS workflow, version publication, website upload and cache refresh each use the production approval Environment. In the Rollout workflow, only percentage changes and website upload use it; cache refresh follows the approved upload without another Environment approval. Rerunning a job with an Environment may require approval again. GitHub concurrency retains at most one pending job per group, so a newer pending job can cancel an older pending job; inspect canceled jobs before rerunning them.
|
||||
|
||||
Website state lives in `upload-records/website-<publication run ID>-<target>/state.json`, beside the retained releases root. macOS and Windows use the same record format on separate local disks. Website URLs and download filenames follow the [fixed-download rules](../README.md#fixed-downloads). Upload retries reconcile both bytes and `Content-Disposition`; identical bytes with a missing or different header receive one upload and readback. A completed journal with different remote bytes stops recovery and requires a newly approved publication. Completion evidence survives failed metadata repairs. Each new upload intent clears the previous purge record, so repaired metadata requires a new cache refresh; inspect EdgeOne history for the previous task ID and diagnostics. Unknown writes are read before any retry; CDN header forwarding requires real-environment validation. Rerun only the purge job to inspect its saved task when the original routing and preparation outputs remain available. With website upload enabled, website jobs skip only an explicitly selected test deployment. Each job requires its injected `route` or `selection` output for local preflight. Missing or changed website approval fails before upload or purge submission. Missing `website-destination` broadens both website concurrency groups. Missing `runner` output can prevent scheduling before preflight. Stop partial retries when outputs are missing; the workflow does not reconstruct them. Before restarting the publication workflow, inspect current remote state and obtain approval for its upload scope; this is not cache-only recovery. Do not rerun packaging to recover publication outputs. A manually rerun purge may submit once after confirming the previous task failed. A lost submission response queries matching history instead of resubmitting. An unknown result with a task ID means submission was confirmed; without an ID it may never have been submitted. Inspect EdgeOne history before manual recovery, and a fresh publication run is one recovery option. Operators may instead use the documented [fixed-download purge command](../README.md#fixed-downloads); Windows operators use the existing DPAPI credential launcher described there. This submits only a fixed-URL purge: it does not observe completion or update this Actions run’s journal. Inspect the returned task in EdgeOne before considering recovery complete.
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ Environment 审批限制此工作流,不限制同一机器账户运行的任
|
||||
|
||||
准备阶段检查 GitHub 身份、保留清单、小体积更新 YAML 和已完成的首次发布记录,不重新计算安装包哈希,也不重复检查签名或公证。Environment 审批后,执行阶段读取当前 COS 更新清单,核对版本、安装包 URL、大小、哈希和其他元数据仍对应已发布包,只修改 `stagingPercentage`。更新清单缺失或已被其他包替换时拒绝执行。同一比例重复执行不写入;不允许降低比例。审批展示目标比例,当前比例在执行时从 COS 读取。
|
||||
|
||||
官网上传复用原机保留的安装器,只校验该安装器的哈希,沿用已有上传与刷新恢复记录。仅重试缓存刷新时沿用官网审批和上传记录,不再依赖原更新 YAML 或首次 feed 发布记录。官网上传在安装器校验、上传期间保持频道锁,防止中途被更新的 feed 替换;此时竞争该频道的发布会失败。因此纯放量不需要安装器文件,发布官网则需要。比例变更前后的 YAML 写入独立放量审计记录。此流程必须在首次 COS 发布之后执行,不构建安装包、不上传版本化安装包,也不创建 release tag。
|
||||
官网上传复用原机保留的安装器,只校验该安装器的哈希,沿用已有上传与刷新恢复记录。Rollout 仅重试缓存刷新时校验准备阶段生成的官网审批摘要和上传记录,不再要求 Environment 审批,不再依赖原更新 YAML 或首次 feed 发布记录。官网上传在安装器校验、上传期间保持频道锁,防止中途被更新的 feed 替换;此时竞争该频道的发布会失败。因此纯放量不需要安装器文件,发布官网则需要。比例变更前后的 YAML 写入独立放量审计记录。此流程必须在首次 COS 发布之后执行,不构建安装包、不上传版本化安装包,也不创建 release tag。
|
||||
|
||||
<a id="recovery-and-records"></a>
|
||||
|
||||
@@ -99,7 +99,7 @@ Environment 审批限制此工作流,不限制同一机器账户运行的任
|
||||
|
||||
生产 COS 发布默认启用官网安装包上传和缓存刷新(`upload_website=true`)。取消后仅发布版本化资源及自动更新清单;test 发布不修改生产官网。`upload-website-installer` 上传固定安装包,`purge-website-installer` 刷新该 URL。官网安装包校验器只需要最终 DMG/EXE 和保留的 manifest,匹配生产资格、构建身份及平台,只计算一次安装包 hash,并通过同一打开的文件句柄上传。production nightly 和 stable 包都可以替换官网固定安装包。操作者负责选择预期版本;固定对象没有防降级保护,重跑旧发布可能覆盖新安装包。勾选官网上传时,审批前摘要展示固定官网 URL、选定版本和无防降级保护的说明。原有版本与自动更新发布保留自身校验。
|
||||
|
||||
将仓库变量 `DOWNLOAD_PROD_EO_ZONE_ID` 配置为生产 EdgeOne 站点。生产 COS 凭据还需要 `teo:CreatePurgeTask` 和 `teo:DescribePurgeTasks` 权限。官网上传在 Actions 中按 bucket/平台互斥,在原机器上按 bucket/对象互斥;缓存观察单独运行。版本发布、官网上传和缓存刷新分别使用生产审批 Environment,后续 job 和重跑可能需要再次审批。GitHub 每个并发组最多保留一个排队 job,新排队 job 可能取消旧排队 job;重跑前应检查取消记录。
|
||||
将仓库变量 `DOWNLOAD_PROD_EO_ZONE_ID` 配置为生产 EdgeOne 站点。生产 COS 凭据还需要 `teo:CreatePurgeTask` 和 `teo:DescribePurgeTasks` 权限。官网上传在 Actions 中按 bucket/平台互斥,在原机器上按 bucket/对象互斥;缓存观察单独运行。COS 工作流的版本发布、官网上传和缓存刷新分别使用生产审批 Environment。Rollout 工作流仅在放量修改和官网上传时使用它;缓存刷新跟随已批准的上传执行,不再要求 Environment 审批。重跑带 Environment 的 job 可能需要再次审批。GitHub 每个并发组最多保留一个排队 job,新排队 job 可能取消旧排队 job;重跑前应检查取消记录。
|
||||
|
||||
官网状态保存在 releases 根目录同级的 `upload-records/website-<发布 run ID>-<target>/state.json`。macOS 和 Windows 在各自本地磁盘使用相同记录格式。官网 URL 和保存文件名遵循[固定下载规则](../README.zh.md#fixed-downloads)。上传重跑同时核对字节和 `Content-Disposition`;字节相同但响应头缺失或错误时,上传一次并读回验证。记录已完成但远端字节改变时停止恢复,需要重新审批发布。完成标记在元数据修复失败后仍保留。每次新的上传意图清除旧刷新记录,因此修复元数据后需重新刷新缓存;上一次任务 ID 和诊断需查 EdgeOne 历史。未知写入先读取再决定重试;CDN 响应头透传仍需实测。原机器路由和准备阶段输出完整时,仅重跑刷新 job 即可查询已保存任务。启用官网上传时,官网 job 仅跳过明确选择的 test 环境。各 job 的本地预检要求其注入的 `route` 或 `selection` 输出存在。官网审批缺失或变化时,在上传或提交刷新任务前失败。`website-destination` 缺失会扩大两个官网并发组的互斥范围。`runner` 输出缺失可能导致无法调度,尚未进入预检。输出缺失时停止局部重试,workflow 不重建这些输出。重新启动发布 workflow 前,先检查当前远端状态并确认上传范围的审批;这不属于仅缓存恢复。不要为恢复发布输出重跑打包。人工重跑确认旧任务失败后可提交一次。提交响应丢失时查询匹配的历史记录,不重新提交。unknown 带任务 ID 表示提交已确认;没有 ID 则可能从未提交。人工恢复前应检查 EdgeOne 历史,重新发起发布运行是恢复方式之一。操作者也可使用已有的[固定下载刷新命令](../README.zh.md#fixed-downloads);Windows 操作者使用该处说明的 DPAPI 凭据启动器。该命令只提交固定 URL 刷新,不观察完成状态,也不更新本次 Actions 运行的 journal。确认恢复完成前应在 EdgeOne 检查返回的任务。
|
||||
|
||||
|
||||
@@ -166,23 +166,31 @@ it('keeps rollout approval and website recovery separate without tag creation or
|
||||
const workflow = load(text) as {
|
||||
name: string
|
||||
on: { workflow_dispatch: { inputs: Record<string, { required?: boolean; default?: unknown }> } }
|
||||
jobs: Record<string, { if?: string; environment?: unknown; env?: Record<string, string>; needs?: string[] }>
|
||||
jobs: Record<string, {
|
||||
name?: string
|
||||
outputs?: Record<string, string>
|
||||
if?: string
|
||||
environment?: unknown
|
||||
env?: Record<string, string>
|
||||
needs?: string[]
|
||||
}>
|
||||
}
|
||||
expect(workflow.name).toBe('Publish Desktop · Rollout & Website')
|
||||
expect(workflow.on.workflow_dispatch.inputs.package_run_attempt!.required).toBe(true)
|
||||
expect(workflow.on.workflow_dispatch.inputs.upload_website!.default).toBe(false)
|
||||
expect(workflow.on.workflow_dispatch.inputs.rollout_percentage!.default).toBe('')
|
||||
expect(workflow.jobs.publish!.environment).toContain('desktop-production')
|
||||
expect(workflow.jobs.publish!.if).toBe("inputs.rollout_percentage != ''")
|
||||
expect(workflow.jobs.publish!.if).toBe("needs.prepare.outputs.rollout-requested == 'true'")
|
||||
const upload = workflow.jobs['upload-website-installer']!
|
||||
const purge = workflow.jobs['purge-website-installer']!
|
||||
expect(workflow.jobs.prepare!.outputs!['rollout-requested']).toBe('${{ steps.check.outputs.rollout-requested }}')
|
||||
expect(upload.name).toBe('Website ${{ needs.prepare.outputs.label }}')
|
||||
expect(upload.environment).toBe('desktop-production')
|
||||
expect(upload.if).toBe("${{ !cancelled() && inputs.upload_website && needs.prepare.result == 'success' && needs.prepare.outputs.preset != 'test' && (needs.publish.result == 'success' || (needs.publish.result == 'skipped' && inputs.rollout_percentage == '')) }}")
|
||||
expect(upload.if).toBe("${{ !cancelled() && inputs.upload_website && needs.prepare.result == 'success' && needs.prepare.outputs.preset != 'test' && (needs.publish.result == 'success' || (needs.publish.result == 'skipped' && needs.prepare.outputs.rollout-requested == 'false')) }}")
|
||||
expect(purge.environment).toBeUndefined()
|
||||
expect(purge.if).toBe("${{ !cancelled() && inputs.upload_website && needs.prepare.outputs.preset != 'test' && needs.upload-website-installer.result == 'success' }}")
|
||||
expect(purge.needs).toEqual(['route', 'prepare', 'upload-website-installer'])
|
||||
expect(workflow.jobs['upload-website-installer']!.needs).toContain('publish')
|
||||
expect(workflow.jobs['purge-website-installer']!.needs).toContain('upload-website-installer')
|
||||
expect(upload.needs).toEqual(['route', 'prepare', 'publish'])
|
||||
expect(text).not.toMatch(/create-github-app-token|publish-desktop-ci.ts|resolve-retained-desktop-publish-ci.ts/u)
|
||||
expect(text).toContain('publish-desktop-rollout-ci.ts route')
|
||||
expect(workflow.jobs.publish!.env!.DESKTOP_UPLOAD_WEBSITE).toBe('${{ inputs.upload_website }}')
|
||||
@@ -207,11 +215,12 @@ it.each(['apply', 'changed-approval', 'replaced-feed', 'website'] as const)('che
|
||||
await record.record({ type: 'feeds-complete' })
|
||||
const env = { RUNNER_NAME: 'runner', GITHUB_REPOSITORY: 'owner/repo', DSH_PACKAGING_CONFIG_DIR: config,
|
||||
DESKTOP_PUBLISH_ROUTE: JSON.stringify({ ...f.manifest.source, runnerLabel: 'dsh-runner' }),
|
||||
DESKTOP_ROLLOUT_PERCENTAGE: scenario === 'website' ? '' : '30', DESKTOP_UPLOAD_WEBSITE: scenario === 'website' ? 'true' : 'false',
|
||||
DESKTOP_ROLLOUT_PERCENTAGE: scenario === 'website' ? ' ' : '30', DESKTOP_UPLOAD_WEBSITE: scenario === 'website' ? 'true' : 'false',
|
||||
DOWNLOAD_PROD_EO_ZONE_ID: 'zone-fixture', GITHUB_OUTPUT: join(f.root, 'output'), GITHUB_STEP_SUMMARY: join(f.root, 'summary') }
|
||||
const context = await prepareDesktopRolloutCi(env)
|
||||
await publishDesktopRolloutCi('check', env)
|
||||
expect(await readFile(env.GITHUB_OUTPUT, 'utf8')).toContain(`approval=${context.approval}`)
|
||||
expect(await readFile(env.GITHUB_OUTPUT, 'utf8')).toContain(`rollout-requested=${scenario !== 'website'}\n`)
|
||||
if (scenario === 'website') {
|
||||
const summary = await readFile(env.GITHUB_STEP_SUMMARY, 'utf8')
|
||||
expect(summary).toContain('官网安装包面向所有下载用户,不受自动更新放量比例限制')
|
||||
|
||||
Reference in new issue
Block a user