Name helper artifacts and packaging workflows by platform

This commit is contained in:
creatixchu authored and CreatixChu committed 2026-11-11 15:12:02 +08:00
1 parent a660c1c048
commit 1d5e1d7757
28 files changed
+121 -112

No files matched your search

+1 -1
View File
@@ -2,7 +2,7 @@
Run jobs on Windows runners (`windows-*` labels) under native `pwsh`. Native Windows pull-request jobs live in `ci-windows.yml` and Python pull-request jobs in `ci-python.yml`, so each PR workflow can be re-run independently; their checks feed the required `windows checks passed` and `python checks passed` verdicts, as Linux jobs in `ci.yml` feed `all checks passed`; Wine runs Windows Node on hosted Linux only in `ci-master.yml`. Python runtime CI checks Linux/Windows x64 on pull requests and Linux ARM64 plus both macOS architectures on master pushes; releases retain all five targets ([platform policy](workflows/ci-master.yml)). `ci.yml`, `ci-windows.yml`, and `ci-python.yml` are pull-request-only. Master-only platform checks, Linux/Windows self-hosted standbys, and manual runner benchmarks live in `ci-master.yml`, which listens to master pushes and `workflow_dispatch`, not `pull_request`; separating workflow triggers keeps master-only jobs out of PR check panels. The master standbys validate the self-hosted failover targets; preserve the existing per-platform switches (values `selfhosted` for the in-house standbys and `blacksmith` for Blacksmith's hosted runners) and the Dependabot hosted fallback under the `selfhosted` values ([failover runbook](../.agents/notes/implemented/process/2026-07-26-ci-failover-runbook.md), [blacksmith failover leg note](../.agents/notes/implemented/process/2026-09-09-blacksmith-failover-leg.md)).
The manual [Windows packaging workflow](workflows/windows-package.yml) uses the dedicated self-hosted Windows x64 label `dsh-win-package-trial` under native `pwsh`; preserve this routing separately from the automatic CI lanes.
The manual [Windows packaging workflow](workflows/desktop-package-windows-x64.yml) uses the dedicated self-hosted Windows x64 label `dsh-win-package-trial` under native `pwsh`; preserve this routing separately from the automatic CI lanes.
The merge checks run from three workflows named `Policy`, which run on `pull_request_target` and cover pull requests into master or a `release/dsh-x.y.z` branch, so their definitions come from the base branch, and call the `deepseek-harness-check` action directly: `pr-check-on-head-branch.yml` on pull-request updates gives `Policy / Master Change` and `Policy / Pre-Merge Check`, `pr-check-after-approve.yml` on pull-request updates and submitted or dismissed reviews gives `Policy / Approve Check`, which also publishes the review verdict as the check run `Policy / Reviewer Check`, and `pr-check-on-base-branch.yml` on pushes to master or a release branch re-runs the head-branch checks as `Policy / Recheck`. Branch rules require those check names, so keep the job names and the workflow name. Each job reads its mode from a repository variable: `MERGE_POLICY_MASTER_DIFF`, `MERGE_POLICY_PRE_MERGE`, and `MERGE_POLICY_HEAD_DIFF`, each `off` (skip), `report` (run without failing the job), or `block` (fail the job); a missing value or an unknown one counts as `report`. `MERGE_POLICY_HEAD_DIFF` decides whether `Policy / Approve Check` runs and fails; while it runs, `Policy / Reviewer Check` is published whatever that mode says, with `success` when every file that needs review has one and `action_required` with the reviewers to ask otherwise. `Policy / Pre-Merge Check` merges the commit `Policy / Master Change` reports, so it runs only after that job and stays off while `MERGE_POLICY_MASTER_DIFF` is `off`; a merge it cannot do and a build that fails both follow its own mode, so `report` warns and skips the build while `block` fails the job. `Policy / Pre-Merge Check` runs `scripts/pre-merge-check.ts` under plain Node with the merged base commit in `BASE_SHA` and knows nothing else about the merged tree: that script checks the released manifests against the root version, installs, rejects upgrade guides added outside the root version's directory, and builds the Host and Client contracts, so change it in one pull request together with the build it orchestrates.
@@ -1,4 +1,4 @@
name: Package CUA helper · macOS
name: Package CUA helper · macOS · arm64 + x64
on:
workflow_dispatch:
@@ -14,7 +14,7 @@ on:
reuse:
type: boolean
default: false
cua_run_id:
cua_macos_run_id:
type: string
default: ''
preset:
@@ -75,7 +75,7 @@ jobs:
id: retained
env:
GH_TOKEN: ${{ github.token }}
CUA_RUN_ID: ${{ inputs.cua_run_id }}
CUA_MACOS_RUN_ID: ${{ inputs.cua_macos_run_id }}
CUA_BUILD_KEY: ${{ steps.build-inputs.outputs.build-key }}
run: node scripts/cua-helper/select-artifact.ts
- uses: pnpm/action-setup@v5.0.0
@@ -96,7 +96,7 @@ jobs:
if: steps.retained.outputs.artifact-id == ''
id: upload
with:
name: cua-helper-${{ github.run_id }}-${{ github.run_attempt }}-${{ steps.build-inputs.outputs.build-key }}
name: cua-helper-macos-${{ github.run_id }}-${{ github.run_attempt }}-${{ steps.build-inputs.outputs.build-key }}
path: dist/cua-helper/*
if-no-files-found: error
compression-level: 0
@@ -100,7 +100,7 @@ jobs:
- uses: actions/upload-artifact@v7.0.1
id: upload
with:
name: cua-helper-${{ github.run_id }}-${{ github.run_attempt }}-${{ steps.metadata.outputs.build-key }}
name: cua-helper-windows-${{ github.run_id }}-${{ github.run_attempt }}-${{ steps.metadata.outputs.build-key }}
path: dist/cua-helper-win-x64.zip
if-no-files-found: error
compression-level: 0
+16 -16
View File
@@ -8,8 +8,8 @@ name: Release publish (dsh)
on:
workflow_dispatch:
inputs:
cua_run_id:
description: 'CUA helper run ID,留空复用源码逐字节一致的产物,无匹配则构建'
cua_macos_run_id:
description: 'macOS CUA helper run ID,留空复用源码逐字节一致的产物,无匹配则构建'
type: string
required: false
default: ''
@@ -28,17 +28,17 @@ env:
DSH_TELEMETRY_DISABLED: '1'
jobs:
cua-helper:
cua-helper-macos:
if: startsWith(github.ref, 'refs/tags/dsh-v') || inputs.skip-tag-check
uses: ./.github/workflows/cua-helper-package.yml
uses: ./.github/workflows/cua-helper-package-macos.yml
with:
reuse: true
preset: production
cua_run_id: ${{ inputs.cua_run_id }}
cua_macos_run_id: ${{ inputs.cua_macos_run_id }}
pack:
name: Pack npm tarballs
needs: cua-helper
needs: cua-helper-macos
runs-on: ubuntu-24.04
permissions:
contents: read
@@ -81,34 +81,34 @@ jobs:
RELEASE_PUBLISH: 'true'
run: pnpm run release:verify --family dsh ${{ inputs.skip-tag-check && '--skip-tag-check' || '' }}
- name: Download selected CUA helper
- name: Download selected macOS CUA helper
uses: actions/download-artifact@v8.0.1
with:
artifact-ids: ${{ needs.cua-helper.outputs.artifact-id }}
run-id: ${{ needs.cua-helper.outputs.run-id }}
artifact-ids: ${{ needs.cua-helper-macos.outputs.artifact-id }}
run-id: ${{ needs.cua-helper-macos.outputs.run-id }}
github-token: ${{ github.token }}
path: dist/cua-helper
- name: Build
run: pnpm run build:official --serial
- name: Stage verified native helper applications
- name: Stage verified macOS helper applications
env:
CUA_EXPECTED_BUILD_KEY: ${{ needs.cua-helper.outputs.build-key }}
CUA_EXPECTED_BUILD_KEY: ${{ needs.cua-helper-macos.outputs.build-key }}
run: |
mkdir dist/cua-helper/extracted
tar -xzf dist/cua-helper/cua-helper.tgz -C dist/cua-helper/extracted
pnpm exec tsx scripts/cua-helper/stage.ts --from dist/cua-helper/extracted
- name: Record CUA source and publication retry instructions
- name: Record macOS CUA source and publication retry instructions
env:
CUA_RUN_ID: ${{ needs.cua-helper.outputs.run-id }}
CUA_ARTIFACT_ID: ${{ needs.cua-helper.outputs.artifact-id }}
CUA_MACOS_RUN_ID: ${{ needs.cua-helper-macos.outputs.run-id }}
CUA_ARTIFACT_ID: ${{ needs.cua-helper-macos.outputs.artifact-id }}
run: |
{
printf '采用 CUA helper 构建 run ID `%s`,artifact ID `%s`。\n\n' "$CUA_RUN_ID" "$CUA_ARTIFACT_ID"
printf '采用 macOS CUA helper 构建 run ID `%s`,artifact ID `%s`。\n\n' "$CUA_MACOS_RUN_ID" "$CUA_ARTIFACT_ID"
printf '%s\n\n' 'npm 部分发布失败时,只重跑 Publish to npm job,复用原 dsh-npm-tarballs;不要重跑全部 job。'
printf '需要重新打包时,可留空自动查找,或填写 `cua_run_id=%s` 指定该 helper;源码和构建配置必须匹配。\n' "$CUA_RUN_ID"
printf '需要重新打包时,可留空自动查找,或填写 `cua_macos_run_id=%s` 指定该 helper;源码和构建配置必须匹配。\n' "$CUA_MACOS_RUN_ID"
} >> "$GITHUB_STEP_SUMMARY"
- name: Pack release tarballs
+4 -4
View File
@@ -24,11 +24,11 @@
en: 5b4f0f80a117f202
zh: ff05be196c181087
/desktop-packaging/windows-actions-packaging:
en: b39449c2f945cab9
zh: a742ba9efa282be8
en: 90d867fcbfb760cd
zh: a9cf66b24ebe230b
/desktop-packaging/macos-self-hosted-packaging:
en: 08619f0e26782636
zh: 7c236cbe46be4a47
en: c0340329db8ca3f8
zh: 83ef4b4f04cee71c
/desktop-packaging/unsigned-windows-test-installer:
en: f429bc0c280e2dfa
zh: 4adbcc9e906bdf80
+3 -3
View File
@@ -109,9 +109,9 @@ Each target owns its packed package inputs, prepared runtime, package set, dsh t
For supervised runner startup and recovery, follow [Windows runner machine setup](../windows-signing/README.md#machine-setup).
The `Package Desktop · Windows · x64` [manual workflow](../../../.github/workflows/windows-package.yml) selects the dedicated Windows x64 runner label `dsh-win-package-trial` and the machine preset `test` or `production`. Choose `signed` (default) or `unsigned`; signed mode uses the existing EV token preflight, signature cache and failure interlock. It does not publish or upload a release. `version_mode` defaults to `default` (`follow-dsh` for production, `build-number` for test); `build-number` uses the CI identifier in [Release versions](#release-versions). `build_version` is required for `manual` and ignored by the other modes; its value may be the checkout's product version or an extended build version such as `0.2.1-alpha.1.20261009.1` for product `0.2.1-alpha.1`. The version prefix must match the selected checkout; validation errors show its current example. Manifests remain unchanged.
The `Package Desktop · Windows · x64` [manual workflow](../../../.github/workflows/desktop-package-windows-x64.yml) selects the dedicated Windows x64 runner label `dsh-win-package-trial` and the machine preset `test` or `production`. Choose `signed` (default) or `unsigned`; signed mode uses the existing EV token preflight, signature cache and failure interlock. It does not publish or upload a release. `version_mode` defaults to `default` (`follow-dsh` for production, `build-number` for test); `build-number` uses the CI identifier in [Release versions](#release-versions). `build_version` is required for `manual` and ignored by the other modes; its value may be the checkout's product version or an extended build version such as `0.2.1-alpha.1.20261009.1` for product `0.2.1-alpha.1`. The version prefix must match the selected checkout; validation errors show its current example. Manifests remain unchanged.
Select the workflow in Actions, choose the source branch, preset, signing mode and version, then click Run workflow. Before merging input changes, test the pushed branch with `gh workflow run windows-package.yml --ref <branch> -f source_ref=<branch> -f preset=test -f signing=unsigned -f version_mode=build-number`; verify the web form after merging. There is no push or PR trigger. Logs and successful EXEs are retained for 14 days. Inspect the retained logs and installer before relying on packaging; installation is separate. Before checkout, Node removes the runner-owned source directory without following dependency junctions; the workflow validates its location and rejects linked ancestors. Never point it at a development checkout. Runs share one concurrency group without cancelling an active build; only one run remains pending, and a newer dispatch replaces it. Diagnostics upload requires a successful clean checkout. Machine settings stay outside the checkout and are never uploaded as artifacts.
Select the workflow in Actions, choose the source branch, preset, signing mode and version, then click Run workflow. Before merging input changes, test the pushed branch with `gh workflow run desktop-package-windows-x64.yml --ref <branch> -f source_ref=<branch> -f preset=test -f signing=unsigned -f version_mode=build-number`; verify the web form after merging. There is no push or PR trigger. Logs and successful EXEs are retained for 14 days. Inspect the retained logs and installer before relying on packaging; installation is separate. Before checkout, Node removes the runner-owned source directory without following dependency junctions; the workflow validates its location and rejects linked ancestors. Never point it at a development checkout. Runs share one concurrency group without cancelling an active build; only one run remains pending, and a newer dispatch replaces it. Diagnostics upload requires a successful clean checkout. Machine settings stay outside the checkout and are never uploaded as artifacts.
All Windows packaging modes, including test and unsigned, require the repository variable `DESKTOP_PUBLISH_RUNNERS`; configure the [original-machine route](../publishing/ci/README.md#machine-setup) before dispatch.
@@ -127,7 +127,7 @@ Installer uploads store the already-compressed release files without ZIP recompr
## macOS self-hosted packaging
The [Apple Silicon workflow](../../../.github/workflows/macos-package.yml) and [Intel workflow](../../../.github/workflows/macos-intel-package.yml) produce separate arm64 and x64 packages on the Apple Silicon runner labeled `dsh-mac-package-trial`. Both share one concurrency group. The Intel workflow checks Rosetta execution before dependency installation; its selected source must include the target-aware macOS CI adapter. Both select `test` or `production` and use the existing signing, notarization and packaged-runtime checks. When the selected source's dsh ships the Computer Use bundle, each workflow builds, notarizes and stages the helper for both architectures with `scripts/cua-helper/package.ts` and `stage.ts` after the configuration check, the steps npm publication uses; `skip_notarization` does not skip the helper's notarization. A source that predates helper packaging only emits a warning, and Computer Use cannot prepare its helper in that package. Successful DMG/ZIP files and diagnostic logs are retained for 14 days without publishing a release. Installer uploads disable redundant ZIP compression. Artifacts are named `macos-<arch>-<mode>-<version>-<run_id>-<package_run_attempt>.zip`, with `arch` set to `arm64` or `x64`; entry timestamps record each retained copy’s modification time as local time in the DOS field and absolute time in the Unix field; this is not a guarantee of the original build time. The operator must verify a complete Actions run and installation on the target architecture before release qualification. The `compression_level` dropdown defaults to `3` and also offers `7`; it overrides the machine preset for this run and affects only ZIP and automatic-update downloads, not DMG.
The [Apple Silicon workflow](../../../.github/workflows/desktop-package-macos-arm64.yml) and [Intel workflow](../../../.github/workflows/desktop-package-macos-x64.yml) produce separate arm64 and x64 packages on the Apple Silicon runner labeled `dsh-mac-package-trial`. Both share one concurrency group. The Intel workflow checks Rosetta execution before dependency installation; its selected source must include the target-aware macOS CI adapter. Both select `test` or `production` and use the existing signing, notarization and packaged-runtime checks. When the selected source's dsh ships the Computer Use bundle, each workflow builds, notarizes and stages the helper for both architectures with `scripts/cua-helper/package.ts` and `stage.ts` after the configuration check, the steps npm publication uses; `skip_notarization` does not skip the helper's notarization. A source that predates helper packaging only emits a warning, and Computer Use cannot prepare its helper in that package. Successful DMG/ZIP files and diagnostic logs are retained for 14 days without publishing a release. Installer uploads disable redundant ZIP compression. Artifacts are named `macos-<arch>-<mode>-<version>-<run_id>-<package_run_attempt>.zip`, with `arch` set to `arm64` or `x64`; entry timestamps record each retained copy’s modification time as local time in the DOS field and absolute time in the Unix field; this is not a guarantee of the original build time. The operator must verify a complete Actions run and installation on the target architecture before release qualification. The `compression_level` dropdown defaults to `3` and also offers `7`; it overrides the machine preset for this run and affects only ZIP and automatic-update downloads, not DMG.
Both macOS workflows require the repository variable `DESKTOP_PUBLISH_RUNNERS`, including test and unnotarized modes. Their independent `upload-artifact` job retains installer names with the original build attempt; if archival fails after packaging succeeds, rerun only that job. See [original-machine routing and recovery](../publishing/ci/README.md#recovery-and-records).
+3 -3
View File
@@ -109,9 +109,9 @@ macOS 正式发布和本地未签名 DMG 都通过 [electron-builder 配置](../
runner 的受监督启动和恢复见 [Windows runner 机器准备](../windows-signing/README.zh.md#machine-setup)。
`Package Desktop · Windows · x64` [手动工作流](../../../.github/workflows/windows-package.yml) 选择专用 Windows x64 runner 标签 `dsh-win-package-trial`,并使用机器 preset `test` 或 `production`。选择 `signed`(默认)或 `unsigned`;签名模式复用现有 EV token 预检、签名缓存与失败 interlock,不发布或上传 release。`version_mode` 默认为 `default`(production 使用 `follow-dsh`,test 使用 `build-number`);`build-number` 使用[发布版本](#release-versions)中的 CI 标识。`manual` 模式必须填写 `build_version`,其他模式忽略该字段;其值可以是源码产品版本,或扩展构建版本,例如产品 `0.2.1-alpha.1` 对应 `0.2.1-alpha.1.20261009.1`。版本前缀必须匹配所选源码;校验错误显示其当前示例。manifest 保持不变。
`Package Desktop · Windows · x64` [手动工作流](../../../.github/workflows/desktop-package-windows-x64.yml) 选择专用 Windows x64 runner 标签 `dsh-win-package-trial`,并使用机器 preset `test` 或 `production`。选择 `signed`(默认)或 `unsigned`;签名模式复用现有 EV token 预检、签名缓存与失败 interlock,不发布或上传 release。`version_mode` 默认为 `default`(production 使用 `follow-dsh`,test 使用 `build-number`);`build-number` 使用[发布版本](#release-versions)中的 CI 标识。`manual` 模式必须填写 `build_version`,其他模式忽略该字段;其值可以是源码产品版本,或扩展构建版本,例如产品 `0.2.1-alpha.1` 对应 `0.2.1-alpha.1.20261009.1`。版本前缀必须匹配所选源码;校验错误显示其当前示例。manifest 保持不变。
在 Actions 选择工作流、源码分支、preset、签名模式和版本,再点击 Run workflow。输入变更合并前,用 `gh workflow run windows-package.yml --ref <branch> -f source_ref=<branch> -f preset=test -f signing=unsigned -f version_mode=build-number` 测试已推送分支;合并后验证网页表单。它不监听 push 或 PR。日志和成功生成的 EXE 保留 14 天。依赖打包流程前检查日志和安装包;安装是独立操作。检出前,Node 删除 runner 专用源码目录,不跟随依赖 junction;工作流校验目标位置并拒绝链接祖先目录。不得指向日常开发目录。运行共享一个并发组,不取消正在进行的构建;最多保留一个待运行任务,新触发会替换它。仅在成功完成干净检出后上传诊断。机器配置位于 checkout 之外,不作为产物上传。
在 Actions 选择工作流、源码分支、preset、签名模式和版本,再点击 Run workflow。输入变更合并前,用 `gh workflow run desktop-package-windows-x64.yml --ref <branch> -f source_ref=<branch> -f preset=test -f signing=unsigned -f version_mode=build-number` 测试已推送分支;合并后验证网页表单。它不监听 push 或 PR。日志和成功生成的 EXE 保留 14 天。依赖打包流程前检查日志和安装包;安装是独立操作。检出前,Node 删除 runner 专用源码目录,不跟随依赖 junction;工作流校验目标位置并拒绝链接祖先目录。不得指向日常开发目录。运行共享一个并发组,不取消正在进行的构建;最多保留一个待运行任务,新触发会替换它。仅在成功完成干净检出后上传诊断。机器配置位于 checkout 之外,不作为产物上传。
所有 Windows 打包模式(含 test 和 unsigned)都要求仓库变量 `DESKTOP_PUBLISH_RUNNERS`;触发前配置[原机器路由](../publishing/ci/README.zh.md#machine-setup)。
@@ -127,7 +127,7 @@ runner 的受监督启动和恢复见 [Windows runner 机器准备](../windows-s
## macOS 自托管打包
[Apple Silicon 工作流](../../../.github/workflows/macos-package.yml)与 [Intel 工作流](../../../.github/workflows/macos-intel-package.yml)在带有 `dsh-mac-package-trial` 标签的 Apple Silicon runner 上分别生成 arm64 和 x64 安装包,两者共用一个并发组。Intel 工作流在安装依赖前检查 Rosetta 能否执行;所选源码必须包含按目标架构校验的 macOS CI 适配脚本。两者均选择 `test` 或 `production`,并复用现有签名、公证和打包运行时检查。所选源码的 dsh 随附 Computer Use 组合包时,两者都在配置检查之后用 `scripts/cua-helper/package.ts` 和 `stage.ts` 构建、公证并放入两种架构的 helper,与 npm 发布的步骤相同;`skip_notarization` 不会跳过 helper 的公证。源码早于 helper 打包支持时只输出警告,该安装包中的 Computer Use 无法准备 helper。成功的 DMG/ZIP 与诊断日志保留 14 天,不发布 release;安装包上传关闭重复 ZIP 压缩。产物名为 `macos-<arch>-<mode>-<version>-<run_id>-<package_run_attempt>.zip`,其中 `arch` 为 `arm64` 或 `x64`;条目时间以 DOS 字段的本地时间和 Unix 字段的绝对时间记录留存副本的修改时间,不保证是原始构建时间。操作人员须验收完整 Actions 运行及目标架构上的安装,才能确认可交付。`compression_level` 下拉选项默认为 `3`,也可选择 `7`;本次运行以该选项覆盖机器预设,只影响 ZIP 和自动升级下载,不影响 DMG。
[Apple Silicon 工作流](../../../.github/workflows/desktop-package-macos-arm64.yml)与 [Intel 工作流](../../../.github/workflows/desktop-package-macos-x64.yml)在带有 `dsh-mac-package-trial` 标签的 Apple Silicon runner 上分别生成 arm64 和 x64 安装包,两者共用一个并发组。Intel 工作流在安装依赖前检查 Rosetta 能否执行;所选源码必须包含按目标架构校验的 macOS CI 适配脚本。两者均选择 `test` 或 `production`,并复用现有签名、公证和打包运行时检查。所选源码的 dsh 随附 Computer Use 组合包时,两者都在配置检查之后用 `scripts/cua-helper/package.ts` 和 `stage.ts` 构建、公证并放入两种架构的 helper,与 npm 发布的步骤相同;`skip_notarization` 不会跳过 helper 的公证。源码早于 helper 打包支持时只输出警告,该安装包中的 Computer Use 无法准备 helper。成功的 DMG/ZIP 与诊断日志保留 14 天,不发布 release;安装包上传关闭重复 ZIP 压缩。产物名为 `macos-<arch>-<mode>-<version>-<run_id>-<package_run_attempt>.zip`,其中 `arch` 为 `arm64` 或 `x64`;条目时间以 DOS 字段的本地时间和 Unix 字段的绝对时间记录留存副本的修改时间,不保证是原始构建时间。操作人员须验收完整 Actions 运行及目标架构上的安装,才能确认可交付。`compression_level` 下拉选项默认为 `3`,也可选择 `7`;本次运行以该选项覆盖机器预设,只影响 ZIP 和自动升级下载,不影响 DMG。
两个 macOS 工作流都要求仓库变量 `DESKTOP_PUBLISH_RUNNERS`,包括 test 和未公证模式。独立 `upload-artifact` job 的安装包名称保留原构建 attempt;打包成功但归档失败时,仅重跑该 job。参见[原机器路由与恢复](../publishing/ci/README.zh.md#recovery-and-records)。
@@ -50,8 +50,8 @@ export function resolveDesktopPublishRoute(
if (diagnostic) throw new Error(diagnostic)
const jobs = jobsSchema.parse(jobsValue)
const routes = desktopPublishRunnersSchema.parse(routesValue)
const workflow = desktopPackageWorkflows[source.target]
if (run.repository.full_name !== repository || source.repository !== repository || run.path !== workflow
const workflows = desktopPackageWorkflows[source.target]
if (run.repository.full_name !== repository || source.repository !== repository || !workflows.includes(run.path)
|| source.runId !== String(run.id) || source.attempt !== String(run.run_attempt)
|| source.workflowCommit !== run.head_sha
|| source.qualification !== (source.target === 'win-x64' ? 'signed' : 'notarized')) {
@@ -1,15 +1,15 @@
/** Approved packaging workflows and machine publication targets. */
import { z } from 'zod'
/** Each target is produced by its own manually dispatched workflow. */
export const desktopPackageWorkflows = {
'mac-arm64': '.github/workflows/macos-package.yml',
'mac-x64': '.github/workflows/macos-intel-package.yml',
'win-x64': '.github/workflows/windows-package.yml',
} as const
const targetSchema = z.enum(['mac-arm64', 'mac-x64', 'win-x64'])
/** Accepted workflow paths per target, including builds retained under an earlier workflow filename. */
export const desktopPackageWorkflows: Readonly<Record<z.infer<typeof targetSchema>, readonly string[]>> = {
'mac-arm64': ['.github/workflows/desktop-package-macos-arm64.yml', '.github/workflows/macos-package.yml'],
'mac-x64': ['.github/workflows/desktop-package-macos-x64.yml', '.github/workflows/macos-intel-package.yml'],
'win-x64': ['.github/workflows/desktop-package-windows-x64.yml', '.github/workflows/windows-package.yml'],
}
/** Machine labels are unique; a scalar target is shorthand for a one-element target list. */
export const desktopPublishRunnersSchema = z.record(z.string(), z.object({
label: z.string().regex(/^dsh-[a-z0-9-]+$/u),
@@ -9,7 +9,7 @@ const positiveId = z.string().regex(/^[1-9]\d*$/u)
const inputsSchema = z.object({ package_run_id: positiveId, package_run_attempt: z.union([positiveId, z.literal('')]).optional() })
const runSchema = z.object({ id: z.number().int().positive(), run_attempt: z.number().int().positive(),
head_sha: z.string().regex(/^[a-f0-9]{40}$/u), status: z.literal('completed'), conclusion: z.string(),
event: z.literal('workflow_dispatch'), path: z.enum(Object.values(desktopPackageWorkflows)),
event: z.literal('workflow_dispatch'), path: z.enum(Object.values(desktopPackageWorkflows).flat()),
repository: z.object({ full_name: z.string() }) })
const jobsSchema = z.object({ jobs: z.array(z.object({
name: z.string(), run_attempt: z.number().int().positive(), runner_name: z.string().nullable(), conclusion: z.string().nullable(),
@@ -57,7 +57,7 @@ export function selectDesktopPackage(repository: string, inputsValue: unknown, r
const routes = desktopPublishRunnersSchema.parse(routesValue)
const route = routes[runnerName]
const target = (Object.keys(desktopPackageWorkflows) as Array<keyof typeof desktopPackageWorkflows>)
.find(name => desktopPackageWorkflows[name] === run.path)!
.find(name => desktopPackageWorkflows[name].includes(run.path))!
if (!route || !route.target.includes(target)) throw new Error('desktop publish: original machine has no configured publishing route')
if (new Set(Object.values(routes).map(value => value.label)).size !== Object.keys(routes).length) {
throw new Error('desktop publish: each configured machine needs its own unique runner label')
@@ -8,7 +8,7 @@ import { retainDesktopRelease, verifyRetainedDesktopRelease } from '../scripts/d
function fixture() {
const run = { id: 42, run_attempt: 2, head_sha: 'a'.repeat(40), status: 'completed', conclusion: 'success',
event: 'workflow_dispatch', path: '.github/workflows/macos-package.yml', repository: { full_name: 'owner/repo' } }
event: 'workflow_dispatch', path: '.github/workflows/desktop-package-macos-arm64.yml', repository: { full_name: 'owner/repo' } }
const jobs = [{ name: 'package', run_attempt: 2, runner_name: 'mini', conclusion: 'success' }]
const routes = { mini: { label: 'dsh-mini', target: 'mac-arm64' } }
const calls: string[] = []
@@ -30,7 +30,7 @@ it('pins the latest successful attempt and finds the package job across pages',
it('routes a Windows package through its own configured machine target', () => {
const f = fixture()
f.run.path = '.github/workflows/windows-package.yml'
f.run.path = '.github/workflows/desktop-package-windows-x64.yml'
const routes = { mini: { label: 'dsh-windows', target: 'win-x64' } }
expect(selectDesktopPackage('owner/repo', { package_run_id: '42' }, routes, f.api)).toMatchObject({ runnerLabel: 'dsh-windows' })
expect(() => selectDesktopPackage('owner/repo', { package_run_id: '42' }, f.routes, f.api)).toThrow(/no configured/u)
@@ -69,10 +69,11 @@ it.each(['0', '../42', '1\nrunner=x', 'abc'])('rejects malformed package ID %s b
expect(f.calls).toEqual([])
})
it('resolves an old locally retained package with publishRequested=false without a GitHub artifact', async () => {
it.each(['desktop-package-macos-arm64.yml', 'macos-package.yml'])('publishes a locally retained %s build without a GitHub artifact', async (workflow) => {
const root = await mkdtemp(join(tmpdir(), 'desktop-selection-'))
try {
const f = fixture()
f.run.path = `.github/workflows/${workflow}`
const selection = selectDesktopPackage('owner/repo', { package_run_id: '42' }, f.routes, f.api)
const file = join(root, 'installer.dmg')
await writeFile(file, 'fixture')
@@ -126,7 +127,7 @@ it('resolves an old locally retained package with publishRequested=false without
it('routes both Mac architectures to one machine without authorizing an unlisted target', () => {
const f = fixture()
const routes = { mini: { label: 'dsh-mini', target: ['mac-arm64', 'mac-x64'] } }
for (const path of ['macos-package.yml', 'macos-intel-package.yml']) {
for (const path of ['desktop-package-macos-arm64.yml', 'desktop-package-macos-x64.yml']) {
f.run.path = `.github/workflows/${path}`
expect(selectDesktopPackage('owner/repo', { package_run_id: '42' }, routes, f.api))
.toMatchObject({ runnerName: 'mini', runnerLabel: 'dsh-mini' })
@@ -2,7 +2,7 @@ import { expect, it } from 'vitest'
import { resolveDesktopPublishRoute } from '../scripts/desktop-publish-route.ts'
function fixture() {
const run = { id: 42, run_attempt: 2, head_sha: 'a'.repeat(40), path: '.github/workflows/macos-package.yml',
const run = { id: 42, run_attempt: 2, head_sha: 'a'.repeat(40), path: '.github/workflows/desktop-package-macos-arm64.yml',
conclusion: 'success', event: 'workflow_dispatch', repository: { full_name: 'owner/repo' } }
const source = { repository: 'owner/repo', runId: '42', attempt: '2', commit: run.head_sha, runnerName: 'mini',
workflowCommit: run.head_sha, sourceRef: 'master', channel: 'nightly',
@@ -80,7 +80,7 @@ it('matches Intel artifacts to the Intel workflow on a machine serving both arch
f.source.target = 'mac-x64'
const routes = { mini: { label: 'dsh-mini', target: ['mac-arm64', 'mac-x64'] } }
expect(() => resolveDesktopPublishRoute('owner/repo', f.run, { source: f.source }, f.jobs, routes)).toThrow(/does not match/u)
f.run.path = '.github/workflows/macos-intel-package.yml'
f.run.path = '.github/workflows/desktop-package-macos-x64.yml'
expect(resolveDesktopPublishRoute('owner/repo', f.run, { source: f.source }, f.jobs, routes))
.toMatchObject({ target: 'mac-x64', runnerLabel: 'dsh-mini' })
expect(() => resolveDesktopPublishRoute('owner/repo', f.run, { source: f.source }, f.jobs, f.routes)).toThrow(/no configured/u)
+2 -2
View File
@@ -244,7 +244,7 @@ it('routes without package binaries only for the explicit metadata-only reader a
try {
const env = { RUNNER_NAME: 'runner', GITHUB_REPOSITORY: 'owner/repo', DSH_PACKAGING_CONFIG_DIR: join(f.root, 'config'),
DESKTOP_PACKAGE_SELECTION: JSON.stringify({ runnerName: 'runner',
run: { id: 42, run_attempt: 1, head_sha: f.manifest.source.workflowCommit, path: '.github/workflows/macos-package.yml',
run: { id: 42, run_attempt: 1, head_sha: f.manifest.source.workflowCommit, path: '.github/workflows/desktop-package-macos-arm64.yml',
conclusion: 'success', event: 'workflow_dispatch', repository: { full_name: 'owner/repo' } },
jobs: [{ name: 'package', runner_name: 'runner', conclusion: 'success', labels: ['self-hosted', 'dsh-runner'] }],
routes: { runner: { label: 'dsh-runner', target: 'mac-arm64' } },
@@ -278,7 +278,7 @@ it('runs the real route CLI without gh and emits the selected route and preset',
if (address === null || typeof address === 'string') throw new Error('expected TCP listener')
const output = join(f.root, 'route-output')
const selection = { runnerName: 'runner',
run: { id: 42, run_attempt: 1, head_sha: f.manifest.source.workflowCommit, path: '.github/workflows/macos-package.yml',
run: { id: 42, run_attempt: 1, head_sha: f.manifest.source.workflowCommit, path: '.github/workflows/desktop-package-macos-arm64.yml',
conclusion: 'success', event: 'workflow_dispatch', repository: { full_name: 'owner/repo' } },
jobs: [{ name: 'package', runner_name: 'runner', conclusion: 'success', labels: ['self-hosted', 'dsh-runner'] }],
routes: { runner: { label: 'dsh-runner', target: 'mac-arm64' } },
@@ -15,8 +15,8 @@
en: e8cbc43d38786c40
zh: 52b3ba85d98011b9
/dsh-cua-native-helper/build-and-service:
en: 1435672513328c05
zh: 11e7a1e672410c10
en: 8989d7b8892102a8
zh: be51752344d011fa
/dsh-cua-native-helper/request-protocol:
en: 21d92283c084d8bb
zh: 7a29731b9f58c709
@@ -37,15 +37,15 @@ Certificate signatures include a signing time. Development builds record the gen
Generations in `native/.build/prepared/<arch>` and `native/bin/darwin-<arch>` are retained without automatic garbage collection. Use a fresh `--output-directory` for release staging, or clean the packaging output before building while no client uses it, so old generations do not enter the tarball. Secure signing timestamps can create distinct generations for identical sources.
The manual **Package CUA helper · macOS** [workflow](../../../../.github/workflows/cua-helper-package.yml) builds both architectures on `dsh-mac-package-trial`. For manual runs, choose a trusted branch or tag with **Use workflow from** and select the machine `preset`. Checkout uses the commit recorded for that Actions run; publication calls use the caller run's commit. Manual runs always build new artifacts. Publication reuse queries the GitHub API with Node's built-in `fetch` and the workflow's `GH_TOKEN`. Signing credentials use the existing [macOS packaging configuration](../../../../apps/desktop/packaging/README.md#macos-actions). Packaging does not require a macOS desktop login or Rosetta. `node --import tsx/esm scripts/cua-helper/package.ts --out <new-directory>` runs the same preparation from the repository root. It signs, notarizes and staples each complete application before selecting its final content digest, then verifies architectures, signatures, tickets, Gatekeeper and file integrity from the extracted `cua-helper.tgz`. Packaging does not launch the helper. Run `python3 scripts/cua-helper/smoke.py <helper-executable>` separately in a logged-in desktop session to check capabilities, helper identity and cleanup; x64 execution on Apple Silicon requires Rosetta. The smoke does not request permissions or inspect applications. Failed or timed-out commands and unreadable startup replies report captured stdout and stderr; invalid encoding is replaced only in diagnostic text, while protocol parsing remains strict. A successful package build does not certify runtime behavior. Helper packaging retains its own [diagnostic record](../../../../apps/desktop/packaging/README.md#macos-release-signing), including failures before desktop installer startup.
The manual **Package CUA helper · macOS · arm64 + x64** [workflow](../../../../.github/workflows/cua-helper-package-macos.yml) builds both architectures on `dsh-mac-package-trial`. For manual runs, choose a trusted branch or tag with **Use workflow from** and select the machine `preset`. Checkout uses the commit recorded for that Actions run; publication calls use the caller run's commit. Manual runs always build new artifacts. Publication reuse queries the GitHub API with Node's built-in `fetch` and the workflow's `GH_TOKEN`. Signing credentials use the existing [macOS packaging configuration](../../../../apps/desktop/packaging/README.md#macos-actions). Packaging does not require a macOS desktop login or Rosetta. `node --import tsx/esm scripts/cua-helper/package.ts --out <new-directory>` runs the same preparation from the repository root. It signs, notarizes and staples each complete application before selecting its final content digest, then verifies architectures, signatures, tickets, Gatekeeper and file integrity from the extracted `cua-helper.tgz`. Packaging does not launch the helper. Run `python3 scripts/cua-helper/smoke.py <helper-executable>` separately in a logged-in desktop session to check capabilities, helper identity and cleanup; x64 execution on Apple Silicon requires Rosetta. The smoke does not request permissions or inspect applications. Failed or timed-out commands and unreadable startup replies report captured stdout and stderr; invalid encoding is replaced only in diagnostic text, while protocol parsing remains strict. A successful package build does not certify runtime behavior. Helper packaging retains its own [diagnostic record](../../../../apps/desktop/packaging/README.md#macos-release-signing), including failures before desktop installer startup.
The workflow retains `cua-helper.tgz` and `cua-helper.json`. The manifest records the original build's product version, commit and Team ID, both application digests, the source digest and the build key. [Release publish](../../../../.github/workflows/release-publish.yml) always calls this workflow, then downloads its selected run ID and artifact ID before packing the provider for npm. Staging verifies the current helper source digest and selected build key, both architectures, application generations, file bytes and executable permissions. npm publication rechecks the exact provider tarball before any registry write. Reuse preserves the original manifest and signed bytes across unrelated commits or product versions. Ordinary PR release rehearsals have no signing credentials.
**Release publish (dsh)** accepts an optional `cua_run_id`: enter the numeric run ID after `/actions/runs/` in the producer's GitHub URL, not its job ID. The publisher enables `reuse` and passes this selection through the helper's `workflow_call` inputs; neither reuse input appears on the manual helper form. Leave `cua_run_id` empty for automatic discovery, which searches completed runs of these two workflows created within the last 14 days for an unexpired matching artifact. Selection runs on the Mac before pnpm setup or dependency installation. A match skips installation, compilation, signing and notarization; an automatic miss rebuilds. An explicit run pins its latest attempt and selects its last executed helper job across the run history. A pack/publish-only rerun keeps the original helper artifact eligible; a newer failed helper execution blocks reuse of earlier successes. Missing or expired artifacts and mismatched inputs fail without choosing another run. A later npm failure does not invalidate a successful helper job. GitHub API failures stop selection. The summary links the actual producer; a run that only reuses an artifact does not upload another copy, so use its linked producer run for manual selection. Artifacts are retained for 14 days. Expiry or deletion after selection stops the download; it does not silently select or build different bytes. Follow the retry instructions below.
**Release publish (dsh)** accepts an optional `cua_macos_run_id`: enter the numeric run ID after `/actions/runs/` in the producer's GitHub URL, not its job ID. The publisher enables `reuse` and passes this selection through the helper's `workflow_call` inputs; neither reuse input appears on the manual helper form. Leave `cua_macos_run_id` empty for automatic discovery, which searches completed runs of these two workflows created within the last 14 days for an unexpired matching artifact. Selection runs on the Mac before pnpm setup or dependency installation. A match skips installation, compilation, signing and notarization; an automatic miss rebuilds. An explicit run pins its latest attempt and selects its last executed helper job across the run history. A pack/publish-only rerun keeps the original helper artifact eligible; a newer failed helper execution blocks reuse of earlier successes. Missing or expired artifacts and mismatched inputs fail without choosing another run. A later npm failure does not invalidate a successful helper job. GitHub API failures stop selection. The summary links the actual producer; a run that only reuses an artifact does not upload another copy, so use its linked producer run for manual selection. Artifacts are retained for 14 days. Expiry or deletion after selection stops the download; it does not silently select or build different bytes. Follow the retry instructions below.
The [source digest](../../../../scripts/cua-helper/build-inputs.ts) covers tracked helper sources, resources, CUA/Desktop packaging scripts, both workflows, package and compiler configuration, locked dependencies, pnpm settings and patches. Tracked `node_modules` entries are also compared. Package manifest version fields are excluded; other manifest fields are retained. The build key additionally includes the preset, Node/Swift/Clang/Python versions, macOS SDK build, signing identity, Team ID and certificate-container digest; passwords are excluded. Selection independently compares the producer run's GitHub `head_sha` tree and package blobs with the current checkout, including paths, bytes and executable modes; artifact-supplied hashes cannot establish source equality. Helper dependency installation disables lifecycle scripts and pnpmfile hooks. Missing inputs or unreadable GitHub evidence fail. Artifacts without matching records require a new build. Selection still requires a Mac runner and checkout; the consuming pack job validates the downloaded application bytes.
If npm publication fails after uploading some packages, rerun only **Publish to npm** while its `dsh-npm-tarballs` artifact is retained (7 days). It uploads the original tarballs and skips already published identical bytes. Do not rerun all jobs for this retry. For a new dispatch that must repack the same commit and version, use the original producer `cua_run_id` from the pack summary. If original artifacts are unavailable or any rebuilt package differs, stop: an existing npm version cannot be replaced with different content.
If npm publication fails after uploading some packages, rerun only **Publish to npm** while its `dsh-npm-tarballs` artifact is retained (7 days). It uploads the original tarballs and skips already published identical bytes. Do not rerun all jobs for this retry. For a new dispatch that must repack the same commit and version, use the original producer `cua_macos_run_id` from the pack summary. If original artifacts are unavailable or any rebuilt package differs, stop: an existing npm version cannot be replaced with different content.
Startup errors retain their code and message through an owner-only, per-attempt failure file and the launcher’s JSON error frame. Launch-lock and readiness waits share one deadline; operating-system launch time consumes that budget. Readiness must name the newly launched PID. A failed new instance is force-terminated and awaited before the launcher reports failure; this cleanup has a separate bound equal to the startup timeout. Existing shared services are not terminated by a failed attaching launcher.
@@ -37,15 +37,15 @@ kind: "package-reference"
`native/.build/prepared/<arch>` 和 `native/bin/darwin-<arch>` 中的各代应用不会自动清理。正式打包时使用全新的 `--output-directory`,或确认没有客户端使用后清理打包输出再构建,避免旧应用进入 tarball。安全签名时间戳可能让相同源码生成不同代应用。
手动工作流 **Package CUA helper · macOS** 的[配置](../../../../.github/workflows/cua-helper-package.yml)在 `dsh-mac-package-trial` 构建两种架构。手动启动时,在 **Use workflow from** 中选择可信的分支或 tag,再选择机器 `preset`。checkout 使用本次 Actions 运行记录的提交;由发布工作流调用时使用调用方本次运行的提交。手动运行始终构建新产物。发布复用使用 Node 原生 `fetch` 和工作流提供的 `GH_TOKEN` 查询 GitHub API。签名凭据沿用[macOS 打包配置](../../../../apps/desktop/packaging/README.zh.md#macos-actions)。打包无需 macOS 桌面登录或 Rosetta。在仓库根目录运行 `node --import tsx/esm scripts/cua-helper/package.ts --out <new-directory>` 可执行相同准备。完整应用签名、公证和贴票后才确定最终内容摘要,再从解包后的 `cua-helper.tgz` 验证架构、签名、票据、Gatekeeper 和文件完整性。打包不启动 helper。在已登录的桌面会话中单独运行 `python3 scripts/cua-helper/smoke.py <helper-executable>` 检查能力、helper 身份和退出清理;Apple Silicon 上执行 x64 版本需要 Rosetta。该检查不申请权限或观察应用。命令失败、超时或启动回复无法解析时,会输出捕获的 stdout 和 stderr;无效编码只在诊断文本中替换,协议解析仍严格校验。打包成功不代表运行验收通过。 helper 打包保留独立的[诊断记录](../../../../apps/desktop/packaging/README.zh.md#macos-release-signing),包括桌面安装包开始构建前发生的失败。
手动工作流 **Package CUA helper · macOS · arm64 + x64** 的[配置](../../../../.github/workflows/cua-helper-package-macos.yml)在 `dsh-mac-package-trial` 构建两种架构。手动启动时,在 **Use workflow from** 中选择可信的分支或 tag,再选择机器 `preset`。checkout 使用本次 Actions 运行记录的提交;由发布工作流调用时使用调用方本次运行的提交。手动运行始终构建新产物。发布复用使用 Node 原生 `fetch` 和工作流提供的 `GH_TOKEN` 查询 GitHub API。签名凭据沿用[macOS 打包配置](../../../../apps/desktop/packaging/README.zh.md#macos-actions)。打包无需 macOS 桌面登录或 Rosetta。在仓库根目录运行 `node --import tsx/esm scripts/cua-helper/package.ts --out <new-directory>` 可执行相同准备。完整应用签名、公证和贴票后才确定最终内容摘要,再从解包后的 `cua-helper.tgz` 验证架构、签名、票据、Gatekeeper 和文件完整性。打包不启动 helper。在已登录的桌面会话中单独运行 `python3 scripts/cua-helper/smoke.py <helper-executable>` 检查能力、helper 身份和退出清理;Apple Silicon 上执行 x64 版本需要 Rosetta。该检查不申请权限或观察应用。命令失败、超时或启动回复无法解析时,会输出捕获的 stdout 和 stderr;无效编码只在诊断文本中替换,协议解析仍严格校验。打包成功不代表运行验收通过。 helper 打包保留独立的[诊断记录](../../../../apps/desktop/packaging/README.zh.md#macos-release-signing),包括桌面安装包开始构建前发生的失败。
工作流保留 `cua-helper.tgz` 和 `cua-helper.json`。清单记录原始构建的产品版本、commit、Team ID、两份应用摘要、源码摘要和构建摘要。[Release publish](../../../../.github/workflows/release-publish.yml)始终调用该工作流,再按返回的 run ID 和 artifact ID 下载所选产物,生成 provider 的 npm 包。准备步骤校验当前 helper 的源码摘要、选定的构建摘要、两种架构、应用目录、文件字节和执行权限。npm 发布在写入注册表前重新检查实际 provider tarball。无关 commit 或产品版本变化时,复用保留原始清单和已签名字节。普通 PR 发布检查不使用签名凭据。
**Release publish (dsh)** 接受可选的 `cua_run_id`:填写构建运行页面 URL 中 `/actions/runs/` 后的数字,不填 job ID。发布工作流开启 `reuse`,并通过 helper 的 `workflow_call` 参数传入这个选择;这两个复用参数均不出现在 helper 的手动表单中。`cua_run_id` 留空时自动查找,查询这两个工作流最近 14 天创建且已结束的运行,选择未过期的匹配产物。选择在 Mac 上执行,早于 pnpm 准备和依赖安装。命中时跳过安装、编译、签名和公证,自动查找未命中时重新构建。手动指定 run ID 时先固定最新 attempt,再选取该 run 历史中最后一次实际执行的 helper job。仅重跑 pack/publish 时仍可使用原 helper 产物;若更新的 helper 执行失败,则不复用更早的成功产物。产物缺失或过期、输入不匹配时直接失败,不改选其他运行。后续 npm 失败不影响成功的 helper job。GitHub API 读取失败会停止选择。运行摘要链接实际构建者;只复用产物的运行不重新上传副本,手动选择时填写摘要所链接的构建 run ID。产物保留 14 天。选择后过期或被删除会使下载失败,不自动改选或构建不同字节;按下方重试说明处理。
**Release publish (dsh)** 接受可选的 `cua_macos_run_id`:填写构建运行页面 URL 中 `/actions/runs/` 后的数字,不填 job ID。发布工作流开启 `reuse`,并通过 helper 的 `workflow_call` 参数传入这个选择;这两个复用参数均不出现在 helper 的手动表单中。`cua_macos_run_id` 留空时自动查找,查询这两个工作流最近 14 天创建且已结束的运行,选择未过期的匹配产物。选择在 Mac 上执行,早于 pnpm 准备和依赖安装。命中时跳过安装、编译、签名和公证,自动查找未命中时重新构建。手动指定 run ID 时先固定最新 attempt,再选取该 run 历史中最后一次实际执行的 helper job。仅重跑 pack/publish 时仍可使用原 helper 产物;若更新的 helper 执行失败,则不复用更早的成功产物。产物缺失或过期、输入不匹配时直接失败,不改选其他运行。后续 npm 失败不影响成功的 helper job。GitHub API 读取失败会停止选择。运行摘要链接实际构建者;只复用产物的运行不重新上传副本,手动选择时填写摘要所链接的构建 run ID。产物保留 14 天。选择后过期或被删除会使下载失败,不自动改选或构建不同字节;按下方重试说明处理。
[源码摘要](../../../../scripts/cua-helper/build-inputs.ts)覆盖受跟踪的 helper 源码、资源、CUA/Desktop 打包脚本、两份工作流、包与编译器配置、锁定依赖、pnpm 配置和补丁;受跟踪的 `node_modules` 文件也参与比较。包清单只排除版本字段,其余字段保留。构建摘要还包含 preset、Node/Swift/Clang/Python 版本、macOS SDK build、签名身份、Team ID 和证书容器摘要,不包含密码。选择时使用生产运行的 GitHub `head_sha`,独立比较对应 Git 树与包清单 blob 和当前 checkout 的路径、字节及执行权限,不能仅凭产物自报摘要认定源码一致。helper 依赖安装禁用生命周期脚本和 pnpmfile hooks。输入缺失或 GitHub 证据无法读取时失败。没有匹配记录的旧产物需要重新构建。选择仍需等待 Mac runner 并检出代码,消费产物的 pack job 再校验下载的应用字节。
npm 发布在上传部分包后失败时,只重跑 **Publish to npm**,复用保留期内的 `dsh-npm-tarballs`(7 天)。该 job 上传原 tarball,跳过已发布且字节相同的包。此次重试不要重跑全部 job。若必须新建运行,以同一 commit 和版本重新打包,填写 pack 摘要中的原始构建 `cua_run_id`。原产物不可用或任何重新打包的内容不同时,应停止发布;不能用不同内容替换已有 npm 版本。
npm 发布在上传部分包后失败时,只重跑 **Publish to npm**,复用保留期内的 `dsh-npm-tarballs`(7 天)。该 job 上传原 tarball,跳过已发布且字节相同的包。此次重试不要重跑全部 job。若必须新建运行,以同一 commit 和版本重新打包,填写 pack 摘要中的原始构建 `cua_macos_run_id`。原产物不可用或任何重新打包的内容不同时,应停止发布;不能用不同内容替换已有 npm 版本。
启动错误通过当前用户专用、每次启动独立的错误文件和 launcher 的 JSON 错误帧保留错误码与消息。等待启动锁和就绪状态共用一个期限,系统启动应用的耗时计入该预算。就绪记录必须指向本次启动的 PID。新实例启动失败后,launcher 强制终止并等待其退出,再报告失败;清理另有与启动超时等长的期限。连接已有服务失败时不会终止该服务。
+7 -7
View File
@@ -19,7 +19,7 @@ function fixture() {
'packages/experimental/cua-macos/native/Info.plist': 'application identity',
'scripts/cua-helper/package.ts': 'build helper',
'apps/desktop/scripts/notarize-macos.mjs': 'notarize helper',
'.github/workflows/cua-helper-package.yml': 'build configuration',
'.github/workflows/cua-helper-package-macos.yml': 'build configuration',
'.github/workflows/release-publish.yml': 'publish configuration',
'packages/client/unrelated/src/index.ts': 'unrelated feature',
}
@@ -62,7 +62,7 @@ it.each(['add', 'delete', 'rename', 'resource', 'dependency', 'script', 'workflo
if (change === 'resource') writeFileSync(join(f.root, 'packages/experimental/cua-macos/native/Info.plist'), 'changed identity')
if (change === 'dependency') writeFileSync(join(f.root, 'pnpm-lock.yaml'), 'changed dependency')
if (change === 'script') writeFileSync(join(f.root, 'apps/desktop/scripts/notarize-macos.mjs'), 'changed notarization')
if (change === 'workflow') writeFileSync(join(f.root, '.github/workflows/cua-helper-package.yml'), 'changed build configuration')
if (change === 'workflow') writeFileSync(join(f.root, '.github/workflows/cua-helper-package-macos.yml'), 'changed build configuration')
if (change === 'package manager') writeFileSync(join(f.root, 'package.json'), JSON.stringify({ packageManager: 'pnpm@12.0.0' }))
f.git('add', '-A')
expect(cuaHelperSourceDigest(f.root)).not.toBe(before)
@@ -170,7 +170,7 @@ it.each(['helper workflow', 'publish workflow', 'packaging script', 'manifest li
const f = fixture()
const previous = producerSnapshot(f.root)
const digest = cuaHelperSourceDigest(f.root)
if (change === 'helper workflow') writeFileSync(join(f.root, '.github/workflows/cua-helper-package.yml'), 'forged uploader')
if (change === 'helper workflow') writeFileSync(join(f.root, '.github/workflows/cua-helper-package-macos.yml'), 'forged uploader')
if (change === 'publish workflow') writeFileSync(join(f.root, '.github/workflows/release-publish.yml'), 'forged caller')
if (change === 'packaging script') writeFileSync(join(f.root, 'scripts/cua-helper/package.ts'), 'forged metadata')
if (change === 'manifest lifecycle') writeFileSync(join(f.root, 'package.json'), JSON.stringify({
@@ -229,11 +229,11 @@ it.skipIf(process.platform === 'win32').each(['match', 'miss', 'api failure', 'm
Object.assign(snapshot.responses, {
[base]: { run_attempt: 2 },
[`${base}/attempts/2`]: { id: 123, run_attempt: 2, status: 'completed', conclusion: 'success',
event: 'workflow_dispatch', path: '.github/workflows/cua-helper-package.yml', head_sha: snapshot.commit,
event: 'workflow_dispatch', path: '.github/workflows/cua-helper-package-macos.yml', head_sha: snapshot.commit,
repository: { full_name: repository }, head_repository: { full_name: repository } },
[`${base}/jobs?filter=all&per_page=100`]: { jobs: [{ name: 'package', conclusion: 'success', run_attempt: 2 }] },
[`${base}/artifacts?per_page=100`]: { artifacts: scenario === 'match'
? [{ id: 456, name: `cua-helper-123-2-${key}`, expired: false, size_in_bytes: 4096 }] : [] },
? [{ id: 456, name: `cua-helper-macos-123-2-${key}`, expired: false, size_in_bytes: 4096 }] : [] },
})
const data = join(f.root, 'responses.json')
writeFileSync(data, JSON.stringify(snapshot.responses))
@@ -251,7 +251,7 @@ globalThis.fetch = async (input, options) => {
}
if (process.env.FIXTURE_API_FAILURE === '1') return new Response('fixture API failure', { status: 503 });
const path = url.pathname.slice(1) + url.search;
if (path.includes('/workflows/')) return Response.json({ workflow_runs: path.includes('cua-helper-package.yml') ? [{ id: 123 }] : [] });
if (path.includes('/workflows/')) return Response.json({ workflow_runs: path.includes('cua-helper-package-macos.yml') ? [{ id: 123 }] : [] });
if (!(path in data)) throw new Error('unexpected GitHub path');
return Response.json(data[path]);
};
@@ -262,7 +262,7 @@ globalThis.fetch = async (input, options) => {
cwd: f.root, encoding: 'utf8', timeout: 60_000,
env: { ...process.env, NODE_OPTIONS: '', PATH: bin, GH_TOKEN: scenario === 'missing token' ? '' : 'fixture-token',
GITHUB_API_URL: 'https://api.github.com', GITHUB_REPOSITORY: repository, GITHUB_OUTPUT: output,
GITHUB_STEP_SUMMARY: summary, CUA_RUN_ID: '', CUA_BUILD_KEY: key,
GITHUB_STEP_SUMMARY: summary, CUA_MACOS_RUN_ID: '', CUA_BUILD_KEY: key,
FIXTURE_API_DATA: data, FIXTURE_API_FAILURE: scenario === 'api failure' ? '1' : '0' },
})
expect(result.error).toBeUndefined()
+1 -1
View File
@@ -12,7 +12,7 @@ const sourceDirectories = [
'packages/experimental/cua-macos/native', 'scripts/cua-helper', 'apps/desktop/scripts', 'patches',
]
const sourceFiles = new Set([
'.github/workflows/cua-helper-package.yml', '.github/workflows/release-publish.yml',
'.github/workflows/cua-helper-package-macos.yml', '.github/workflows/release-publish.yml',
'package.json', 'scripts/package.json', 'apps/package.json', 'apps/desktop/package.json', 'scripts/release/process.ts',
'pnpm-lock.yaml', 'pnpm-workspace.yaml', '.npmrc', '.pnpmfile.cjs', '.pnpmfile.mjs',
])
+3 -3
View File
@@ -118,15 +118,15 @@ it.skipIf(process.platform === 'win32').each(['source', 'configuration', 'archit
})
it('keeps company signing outside pull-request release rehearsals', () => {
const workflow = readFileSync(resolve('.github/workflows/cua-helper-package.yml'), 'utf8')
const workflow = readFileSync(resolve('.github/workflows/cua-helper-package-macos.yml'), 'utf8')
expect(workflow).toContain('workflow_dispatch:')
expect(workflow).toContain('workflow_call:')
expect(workflow).not.toContain('pull_request:')
expect(workflow).toContain('dsh-mac-package-trial')
const release = readFileSync(resolve('.github/workflows/release-publish.yml'), 'utf8')
expect(release).toContain('needs: cua-helper')
expect(release).toContain('needs: cua-helper-macos')
expect(release).toContain('scripts/cua-helper/stage.ts')
expect(readFileSync(resolve('.github/workflows/release.yml'), 'utf8')).not.toContain('cua-helper-package.yml')
expect(readFileSync(resolve('.github/workflows/release.yml'), 'utf8')).not.toContain('cua-helper-package-macos.yml')
})
it.skipIf(process.platform === 'win32')('retains the original build commit and version when consuming identical helper sources', () => {
+18 -17
View File
@@ -8,16 +8,16 @@ const key = 'a'.repeat(64)
function fixture() {
const run = { id: 123, run_attempt: 2, status: 'completed', conclusion: 'success', event: 'workflow_dispatch',
path: '.github/workflows/cua-helper-package.yml', head_sha: 'c'.repeat(40), repository: { full_name: repository }, head_repository: { full_name: repository } }
path: '.github/workflows/cua-helper-package-macos.yml', head_sha: 'c'.repeat(40), repository: { full_name: repository }, head_repository: { full_name: repository } }
const jobs = [{ jobs: [{ name: 'package', conclusion: 'success', run_attempt: 2 }] }]
const matchesSource = vi.fn(async (_commit: string) => true)
const artifact = { id: 456, name: `cua-helper-123-2-${key}`, expired: false, size_in_bytes: 4096 }
const artifacts = [{ artifacts: [{ ...artifact, id: 455, name: `cua-helper-123-1-${key}` }] }, { artifacts: [artifact] }]
const artifact = { id: 456, name: `cua-helper-macos-123-2-${key}`, expired: false, size_in_bytes: 4096 }
const artifacts = [{ artifacts: [{ ...artifact, id: 455, name: `cua-helper-macos-123-1-${key}` }] }, { artifacts: [artifact] }]
const api = vi.fn(async (path: string, paginate?: boolean) => {
if (path === base) { expect(paginate).toBeUndefined(); return { run_attempt: 2 } }
if (path === `${base}/attempts/2`) { expect(paginate).toBeUndefined(); return run }
expect(paginate).toBe(true)
if (path.includes('/workflows/cua-helper-package.yml/runs?')) return [{ workflow_runs: [{ id: 123 }] }]
if (path.includes('/workflows/cua-helper-package-macos.yml/runs?')) return [{ workflow_runs: [{ id: 123 }] }]
if (path.includes('/workflows/release-publish.yml/runs?')) return [{ workflow_runs: [] }]
if (path === `${base}/jobs?filter=all&per_page=100`) return jobs
if (path === `${base}/artifacts?per_page=100`) return artifacts
@@ -38,7 +38,7 @@ it('allows successful helper packaging when later npm publication failed', async
const f = fixture()
f.run.path = '.github/workflows/release-publish.yml'
f.run.conclusion = 'failure'
f.jobs[0]!.jobs = [{ name: 'cua-helper / package', conclusion: 'success', run_attempt: 2 }, { name: 'Publish to npm', conclusion: 'failure', run_attempt: 2 }]
f.jobs[0]!.jobs = [{ name: 'cua-helper-macos / package', conclusion: 'success', run_attempt: 2 }, { name: 'Publish to npm', conclusion: 'failure', run_attempt: 2 }]
expect((await selectCuaHelperArtifact(repository, '123', key, f.api, f.matchesSource))?.artifactId).toBe('456')
})
@@ -78,21 +78,22 @@ it.each(['failure', 'cancelled', 'skipped', 'missing', 'duplicate'])(
f.run.path = '.github/workflows/release-publish.yml'
f.run.conclusion = 'failure'
f.jobs[0]!.jobs = status === 'missing' ? [] : status === 'duplicate'
? [{ name: 'cua-helper / package', conclusion: 'success', run_attempt: 2 }, { name: 'cua-helper / package', conclusion: 'success', run_attempt: 2 }]
: [{ name: 'cua-helper / package', conclusion: status, run_attempt: 2 }]
await expect(selectCuaHelperArtifact(repository, '123', key, f.api, f.matchesSource)).rejects.toThrow('last executed cua-helper / package job did not succeed')
? [{ name: 'cua-helper-macos / package', conclusion: 'success', run_attempt: 2 }, { name: 'cua-helper-macos / package', conclusion: 'success', run_attempt: 2 }]
: [{ name: 'cua-helper-macos / package', conclusion: status, run_attempt: 2 }]
await expect(selectCuaHelperArtifact(repository, '123', key, f.api, f.matchesSource)).rejects.toThrow('last executed cua-helper-macos / package job did not succeed')
expect(f.api.mock.calls.some(([path]) => path.includes('/attempts/1') || path.includes('/artifacts'))).toBe(false)
},
)
it.each(['missing', 'expired', 'empty', 'mismatch', 'legacy'] as const)(
it.each(['missing', 'expired', 'empty', 'mismatch', 'windows', 'legacy'] as const)(
'rebuilds on automatic %s but rejects the same explicit selection', async (change) => {
const f = fixture()
if (change === 'missing') f.artifacts.pop()
if (change === 'expired') f.artifact.expired = true
if (change === 'empty') f.artifact.size_in_bytes = 0
if (change === 'mismatch') f.artifact.name = `cua-helper-123-2-${'b'.repeat(64)}`
if (change === 'legacy') f.artifact.name = 'cua-helper-123-2'
if (change === 'mismatch') f.artifact.name = `cua-helper-macos-123-2-${'b'.repeat(64)}`
if (change === 'windows') f.artifact.name = `cua-helper-windows-123-2-${key}`
if (change === 'legacy') f.artifact.name = 'cua-helper-macos-123-2'
expect(await selectCuaHelperArtifact(repository, '', key, f.api, f.matchesSource)).toBeUndefined()
await expect(selectCuaHelperArtifact(repository, '123', key, f.api, f.matchesSource)).rejects.toThrow('CUA reuse: run 123:')
},
@@ -101,9 +102,9 @@ it.each(['missing', 'expired', 'empty', 'mismatch', 'legacy'] as const)(
it('selects a match across workflows and pages after a newer failed producer', async () => {
const f = fixture()
const api = vi.fn(async (path: string, paginate?: boolean): Promise<unknown> => {
if (path.includes('/workflows/cua-helper-package.yml/runs?')) return [{ workflow_runs: [] }]
if (path.includes('/workflows/cua-helper-package-macos.yml/runs?')) return [{ workflow_runs: [] }]
if (path.includes('/workflows/release-publish.yml/runs?')) return [{ workflow_runs: [{ id: 124 }] }, { workflow_runs: [{ id: 123 }] }]
if (path.endsWith('/runs/124/artifacts?per_page=100')) return [{ artifacts: [{ ...f.artifact, name: `cua-helper-124-1-${key}` }] }]
if (path.endsWith('/runs/124/artifacts?per_page=100')) return [{ artifacts: [{ ...f.artifact, name: `cua-helper-macos-124-1-${key}` }] }]
if (path.endsWith('/runs/124')) return { run_attempt: 1 }
if (path.endsWith('/runs/124/attempts/1')) return { ...f.run, id: 124, run_attempt: 1, conclusion: 'failure' }
return f.api(path, paginate)
@@ -130,7 +131,7 @@ it.each(['', '123'])('propagates unavailable GitHub evidence with selection %j',
it('does not query job or attempt details when artifact names exclude the requested build key', async () => {
const f = fixture()
f.artifact.name = 'cua-helper-123-2-legacy'
f.artifact.name = 'cua-helper-macos-123-2-legacy'
f.artifacts.shift()
expect(await selectCuaHelperArtifact(repository, '', key, f.api, f.matchesSource)).toBeUndefined()
expect(f.api.mock.calls.map(([path]) => path).filter(path => !path.includes('/workflows/')))
@@ -140,7 +141,7 @@ it('does not query job or attempt details when artifact names exclude the reques
it.each(['123', ''])('retains the original helper after a publish-only rerun with selection %j', async (runId) => {
const f = fixture()
f.run.path = '.github/workflows/release-publish.yml'
f.jobs[0]!.jobs = [{ name: 'cua-helper / package', conclusion: 'success', run_attempt: 1 },
f.jobs[0]!.jobs = [{ name: 'cua-helper-macos / package', conclusion: 'success', run_attempt: 1 },
{ name: 'Publish to npm', conclusion: 'success', run_attempt: 2 }]
f.artifacts.pop()
expect(await selectCuaHelperArtifact(repository, runId, key, f.api, f.matchesSource))
@@ -151,8 +152,8 @@ it.each(['123', ''])('retains the original helper after a publish-only rerun wit
it('does not reuse an older successful helper after a newer helper execution failed', async () => {
const f = fixture()
f.run.path = '.github/workflows/release-publish.yml'
f.jobs[0]!.jobs = [{ name: 'cua-helper / package', conclusion: 'success', run_attempt: 1 },
{ name: 'cua-helper / package', conclusion: 'failure', run_attempt: 2 }]
f.jobs[0]!.jobs = [{ name: 'cua-helper-macos / package', conclusion: 'success', run_attempt: 1 },
{ name: 'cua-helper-macos / package', conclusion: 'failure', run_attempt: 2 }]
expect(await selectCuaHelperArtifact(repository, '', key, f.api, f.matchesSource)).toBeUndefined()
await expect(selectCuaHelperArtifact(repository, '123', key, f.api, f.matchesSource)).rejects.toThrow('did not succeed')
expect(f.matchesSource).not.toHaveBeenCalled()
+6 -6
View File
@@ -5,7 +5,7 @@ import { resolve } from 'node:path'
import { isEntry } from '../release/process.ts'
import { cuaHelperSourceMatches } from './build-inputs.ts'
const workflows = ['cua-helper-package.yml', 'release-publish.yml'] as const
const workflows = ['cua-helper-package-macos.yml', 'release-publish.yml'] as const
function record(value: unknown): Record<string, unknown> {
assert(value !== null && typeof value === 'object' && !Array.isArray(value), 'CUA reuse: invalid GitHub object')
@@ -61,8 +61,8 @@ export async function selectCuaHelperArtifact(repository: string, runId: string,
const workflow = workflows.find(name => run.path === `.github/workflows/${name}`)
assert(workflow && run.event === 'workflow_dispatch', 'CUA reuse: select a supported repository packaging or release run')
if (run.status !== 'completed') return 'the latest attempt has not completed'
if (workflow === 'cua-helper-package.yml' && run.conclusion !== 'success') return 'the latest packaging attempt did not succeed'
const jobName = workflow === 'cua-helper-package.yml' ? 'package' : 'cua-helper / package'
if (workflow === 'cua-helper-package-macos.yml' && run.conclusion !== 'success') return 'the latest packaging attempt did not succeed'
const jobName = workflow === 'cua-helper-package-macos.yml' ? 'package' : 'cua-helper-macos / package'
const jobs = rows(await api(`${base}/runs/${candidate}/jobs?filter=all&per_page=100`, true), 'jobs')
.filter(job => job.name === jobName)
const attempts = jobs.map(job => Number(id(job.run_attempt)))
@@ -70,7 +70,7 @@ export async function selectCuaHelperArtifact(repository: string, runId: string,
const producerAttempt = Math.max(0, ...attempts)
const producers = jobs.filter(job => job.run_attempt === producerAttempt)
if (producers.length !== 1 || producers[0]?.conclusion !== 'success') return `the last executed ${jobName} job did not succeed`
const name = `cua-helper-${candidate}-${producerAttempt}-${buildKey}`
const name = `cua-helper-macos-${candidate}-${producerAttempt}-${buildKey}`
const artifacts = (retained ?? rows(await api(`${base}/runs/${candidate}/artifacts?per_page=100`, true), 'artifacts'))
.filter(artifact => artifact.name === name)
if (artifacts.length === 0) return 'no artifact matches the current source bytes and build configuration; use the producer run linked in its summary or rebuild'
@@ -99,7 +99,7 @@ export async function selectCuaHelperArtifact(repository: string, runId: string,
const candidateId = id(candidate.id)
const artifacts = rows(await api(`${base}/runs/${candidateId}/artifacts?per_page=100`, true), 'artifacts')
if (!artifacts.some(artifact => typeof artifact.name === 'string'
&& artifact.name.startsWith(`cua-helper-${candidateId}-`) && artifact.name.endsWith(`-${buildKey}`))) continue
&& artifact.name.startsWith(`cua-helper-macos-${candidateId}-`) && artifact.name.endsWith(`-${buildKey}`))) continue
const selected = await selectRun(candidateId, artifacts)
if (typeof selected !== 'string') return selected
}
@@ -193,7 +193,7 @@ if (isEntry(import.meta.url)) {
const repository = env.GITHUB_REPOSITORY
const root = resolve(import.meta.dirname, '../..')
const sourceMatches = new Map<string, boolean>()
const selection = await selectCuaHelperArtifact(repository, env.CUA_RUN_ID ?? '', env.CUA_BUILD_KEY, githubJson, async (commit) => {
const selection = await selectCuaHelperArtifact(repository, env.CUA_MACOS_RUN_ID ?? '', env.CUA_BUILD_KEY, githubJson, async (commit) => {
let matches = sourceMatches.get(commit)
if (matches === undefined) {
matches = await cuaHelperSourceMatches(root, repository, commit, githubJson)
+1 -1
View File
@@ -4,7 +4,7 @@ import yaml from 'js-yaml'
import { expect, it } from 'vitest'
it('presents common packaging fields in the same order with the same defaults', () => {
const workflows = ['macos-package.yml', 'macos-intel-package.yml', 'windows-package.yml'].map(name =>
const workflows = ['desktop-package-macos-arm64.yml', 'desktop-package-macos-x64.yml', 'desktop-package-windows-x64.yml'].map(name =>
yaml.load(readFileSync(resolve(import.meta.dirname, '../.github/workflows', name), 'utf8')) as {
on: { workflow_dispatch: { inputs: Record<string, Record<string, unknown>> } }
})
+1 -1
View File
@@ -5,7 +5,7 @@ import yaml from 'js-yaml'
import { describe, expect, it } from 'vitest'
describe.each(['arm64', 'x64'])('macOS %s packaging', (arch) => {
const filename = arch === 'arm64' ? 'macos-package.yml' : 'macos-intel-package.yml'
const filename = arch === 'arm64' ? 'desktop-package-macos-arm64.yml' : 'desktop-package-macos-x64.yml'
const workflow = yaml.load(readFileSync(resolve(import.meta.dirname, `../.github/workflows/${filename}`), 'utf8')) as {
on: Record<string, unknown>
permissions: Record<string, string>
+23 -16
View File
@@ -188,20 +188,20 @@ it('keeps vendor publication manual and entirely hosted', () => {
it('keeps DSH publication manual and delegates all helper selections to the Mac workflow', () => {
const publish = workflow('release-publish.yml')
expect(Object.keys(publish.on)).toEqual(['workflow_dispatch'])
const helper = publish.jobs['cua-helper']!
const helper = publish.jobs['cua-helper-macos']!
expect(helper).toEqual({
if: "startsWith(github.ref, 'refs/tags/dsh-v') || inputs.skip-tag-check",
uses: './.github/workflows/cua-helper-package.yml',
with: { reuse: true, preset: 'production', cua_run_id: '${{ inputs.cua_run_id }}' },
uses: './.github/workflows/cua-helper-package-macos.yml',
with: { reuse: true, preset: 'production', cua_macos_run_id: '${{ inputs.cua_macos_run_id }}' },
})
for (const [name, job] of Object.entries(publish.jobs)) {
if (name !== 'cua-helper') expect(job['runs-on']).toBe(hosted)
if (name !== 'cua-helper-macos') expect(job['runs-on']).toBe(hosted)
}
expect(JSON.stringify(publish)).not.toContain('cua_run_attempt')
expect(publish.on['workflow_dispatch']).toMatchObject({ inputs: { 'skip-tag-check': {
description: 'Skip release tag validation for the selected ref; other publication checks still apply.',
} } })
expect(publish.jobs['pack']!.needs).toBe('cua-helper')
expect(publish.jobs['pack']!.needs).toBe('cua-helper-macos')
expect(publish.jobs['pack']!.if).toBeUndefined()
})
@@ -210,12 +210,12 @@ it.each([
['refs/heads/master', false, false],
['refs/heads/master', true, true],
] as const)('gates helper selection for ref %s, skip=%s', (ref, skip, expected) => {
const expression = workflow('release-publish.yml').jobs['cua-helper']!.if!
const expression = workflow('release-publish.yml').jobs['cua-helper-macos']!.if!
expect(evaluate(expression, { 'github.ref': ref, 'inputs.skip-tag-check': skip })).toBe(expected)
})
it('skips installation and signing on a helper match and exports the original producer identifiers', () => {
const helper = workflow('cua-helper-package.yml')
const helper = workflow('cua-helper-package-macos.yml')
expect(helper.permissions).toEqual({ contents: 'read', actions: 'read' })
const job = helper.jobs['package']!
const select = job.steps.find(step => step.name === 'Find reusable CUA helper')!
@@ -248,39 +248,46 @@ it('skips installation and signing on a helper match and exports the original pr
})
})
it.each(['macos', 'windows'])('uploads an artifact named for the %s helper and its exact build', (platform) => {
const steps = workflow(`cua-helper-package-${platform}.yml`).jobs['package']!.steps
const upload = steps.find(step => step.uses?.startsWith('actions/upload-artifact@'))
const build = platform === 'macos' ? '${{ steps.build-inputs.outputs.build-key }}' : '${{ steps.metadata.outputs.build-key }}'
expect(upload?.with?.name).toBe([`cua-helper-${platform}`, '${{ github.run_id }}', '${{ github.run_attempt }}', build].join('-'))
})
it('downloads the selected producer artifact and verifies its build key before packing', () => {
const publish = workflow('release-publish.yml')
expect(publish.permissions).toEqual({ contents: 'read', actions: 'read' })
const pack = publish.jobs['pack']!
expect(pack.permissions).toEqual({ contents: 'read', actions: 'read' })
const download = pack.steps.find(step => step.name === 'Download selected CUA helper')!
const download = pack.steps.find(step => step.name === 'Download selected macOS CUA helper')!
expect(download).toMatchObject({ uses: 'actions/download-artifact@v8.0.1', with: {
'artifact-ids': '${{ needs.cua-helper.outputs.artifact-id }}', 'run-id': '${{ needs.cua-helper.outputs.run-id }}',
'artifact-ids': '${{ needs.cua-helper-macos.outputs.artifact-id }}', 'run-id': '${{ needs.cua-helper-macos.outputs.run-id }}',
'github-token': '${{ github.token }}', path: 'dist/cua-helper',
} })
expect(download.if).toBeUndefined()
expect(download.with?.name).toBeUndefined()
const stage = pack.steps.find(step => step.name === 'Stage verified native helper applications')!
const stage = pack.steps.find(step => step.name === 'Stage verified macOS helper applications')!
expect(stage.if).toBeUndefined()
expect(stage.env).toEqual({ CUA_EXPECTED_BUILD_KEY: '${{ needs.cua-helper.outputs.build-key }}' })
expect(stage.env).toEqual({ CUA_EXPECTED_BUILD_KEY: '${{ needs.cua-helper-macos.outputs.build-key }}' })
expect(stage.run).toContain('scripts/cua-helper/stage.ts --from dist/cua-helper/extracted')
expect(pack.steps.indexOf(stage)).toBeGreaterThan(pack.steps.indexOf(download))
expect(pack.steps.indexOf(stage)).toBeLessThan(pack.steps.findIndex(step => step.name === 'Pack release tarballs'))
})
it('checks out the Actions run commit and exposes only the preset on the manual helper form', () => {
const helper = workflow('cua-helper-package.yml')
const helper = workflow('cua-helper-package-macos.yml')
const dispatch = helper.on['workflow_dispatch'] as { inputs: Record<string, unknown> }
const called = helper.on['workflow_call'] as { inputs: Record<string, unknown> }
expect(Object.keys(dispatch.inputs)).toEqual(['preset'])
expect(called.inputs).toEqual({ reuse: { type: 'boolean', default: false },
cua_run_id: { type: 'string', default: '' }, preset: { type: 'string', default: 'production' } })
cua_macos_run_id: { type: 'string', default: '' }, preset: { type: 'string', default: 'production' } })
const job = helper.jobs['package']!
const checkout = job.steps.find(step => step.uses === 'actions/checkout@v7.0.1')!
expect(checkout.with).toEqual({ 'persist-credentials': false, clean: true })
expect(job.env).not.toHaveProperty('PACKAGE_SOURCE_REF')
expect(JSON.stringify(helper)).not.toContain('source_ref')
expect(workflow('release-publish.yml').jobs['cua-helper']!.with).not.toHaveProperty('source_ref')
expect(workflow('release-publish.yml').jobs['cua-helper-macos']!.with).not.toHaveProperty('source_ref')
})
it.each([
@@ -294,7 +301,7 @@ it.each([
const directory = mkdtempSync(join(tmpdir(), 'cua-workflow-ref-'))
onTestFinished(() => { rmSync(directory, { recursive: true, force: true }) })
writeFileSync(join(directory, 'package.json'), JSON.stringify({ version: '1.2.3' }))
const job = workflow('cua-helper-package.yml').jobs['package']!
const job = workflow('cua-helper-package-macos.yml').jobs['package']!
const validation = job.steps.find(step => step.name === 'Validate run ref and preset')!
const source = /^node -e '([\s\S]+)'$/u.exec(validation.run!.trim())?.[1]
expect(source).toBeDefined()
@@ -314,7 +321,7 @@ it.each([
[true, '', true],
[true, '456', false],
] as const)('builds for reuse=%s and selected artifact=%s only when required', (reuse, artifactId, build) => {
const steps = workflow('cua-helper-package.yml').jobs['package']!.steps
const steps = workflow('cua-helper-package-macos.yml').jobs['package']!.steps
const selection = steps.find(step => step.name === 'Find reusable CUA helper')!
expect(Boolean(evaluate(selection.if!, reuse ? { 'inputs.reuse': true } : {}))).toBe(reuse)
for (const step of steps.filter(step => step.uses === 'pnpm/action-setup@v5.0.0'
+1 -1
View File
@@ -7,7 +7,7 @@ import yaml from 'js-yaml'
import { expect, it } from 'vitest'
const root = resolve(import.meta.dirname, '..')
const workflow = yaml.load(readFileSync(resolve(root, '.github/workflows/windows-package.yml'), 'utf8')) as {
const workflow = yaml.load(readFileSync(resolve(root, '.github/workflows/desktop-package-windows-x64.yml'), 'utf8')) as {
on: Record<string, { inputs: Record<string, { type?: string; required?: boolean; default?: string; description?: string }> }>
permissions: Record<string, string>
concurrency: { group: string; 'cancel-in-progress': boolean }