Skip to content

Formerly KrillinAI, VideoTranslation and Dubbing Tool for 120+ Languages. Open-source AI workspace for creators, powered by Codex. Video downloader, video translation, create videos, images, audios, and edits with Agents in one place. For your Social Media like YouTube, TikTok, Instagram, etc.

ci: streamline desktop release verification

Leggettb6c04698080d
diff --git a/.codex/skills/oc-deploy/SKILL.md b/.codex/skills/oc-deploy/SKILL.md
index f4d22ae4..81272015 100644
--- a/.codex/skills/oc-deploy/SKILL.md
+++ b/.codex/skills/oc-deploy/SKILL.md
@@ -25,7 +25,7 @@ description: 验证、诊断和发布 OpenCreator Desktop,包括本地实际 A
5. GitHub 下载和 `gh` 命令设置 `HTTP_PROXY` 与 `HTTPS_PROXY` 为 `http://127.0.0.1:7897`,并先用 `gh auth status` 确认认证身份。GitHub 保存的签名 secrets 会跨 workflow 运行持续存在,不要要求重复上传。
6. 不用付费 Release 构建逐次发现问题。一次远端运行首次出现 package、E2E、签名、公证或上传失败时,立即取消仍在运行的付费 sibling jobs,读取该 run 的已生成日志和 artifacts;不得为了拿日志直接 rerun。
7. candidate 只能通过 `workflow_dispatch` 从 `master` 运行。正式发布候选必须选择 `target=all`;结束后确认候选身份凭据和全部 artifacts 已生成、`publish` skipped,并确认 tag 和 Release 均未变化。单平台 candidate 只用于诊断,不能提升为 Release。
-8. release 通常只对已经通过上述门禁和完整 candidate 的精确 commit 创建 tag。候选之后若只有 workflow、Release 附件整理、对应测试或发布文档变化,可由 tag workflow 通过祖先关系、完整 compare 和严格白名单复用不可变 artifacts;任何 App、Runtime、依赖或打包输入变化都必须重新通过完整 candidate。tag workflow 不得重新执行付费打包。
+8. release 通常只对已经通过上述门禁和完整 candidate 的精确 commit 创建 tag。候选之后若只有 workflow、Release 附件整理、对应测试或发布文档变化,可由 tag workflow 通过祖先关系和应用构建输入 SHA-256 复用不可变 artifacts;任何 App、Runtime、依赖或打包输入变化都必须重新通过完整 candidate。tag workflow 不得重新执行付费打包。
## 完成标准
diff --git a/.codex/skills/oc-deploy/references/runbook.md b/.codex/skills/oc-deploy/references/runbook.md
index a66fff40..00d33388 100644
--- a/.codex/skills/oc-deploy/references/runbook.md
+++ b/.codex/skills/oc-deploy/references/runbook.md
@@ -41,7 +41,7 @@ HTTP_PROXY=http://127.0.0.1:7897 HTTPS_PROXY=http://127.0.0.1:7897 \
pnpm --filter @opencreator/desktop e2e:package
```
-记录实际 `.app` 路径和测试总数。当前完整套件预期 16 项;以仓库当时清单为准,但 skipped/failed 必须说明。发布实现有变化时补充:
+记录实际 `.app` 路径和测试总数。当前完整套件预期 18 项;以仓库当时清单为准,但 skipped/failed 必须说明。发布实现有变化时补充:
```bash
pnpm --filter @opencreator/web test -- src/features/settings/CreatorServicesSettingsView.test.tsx
@@ -66,7 +66,7 @@ gh workflow run desktop-release.yml --repo krillinai/OpenCreator --ref master -f
```
5. 任一 package job 首次失败,立即 `gh run cancel <run-id>`,再读取失败日志;不要自动重跑。
-6. `target=all` 的成功标准:verify、三个 package jobs、Linux package 和 `candidate-ready` 成功;用户附件、KrillinAI 附件及 `opencreator-release-candidate-<commit>` 身份凭据存在;publish skipped;tag 和 Release 未变化。
+6. `target=all` 的成功标准:verify、三个 package jobs、Linux package 和 `candidate-ready` 成功;macOS arm64 运行完整 packaged App E2E,macOS x64 与 Windows x64 运行包含 Runtime、平台能力、代理、恢复、安全和进程回收的 smoke 套件;用户附件、KrillinAI 附件及 `opencreator-release-candidate-<build-input-digest>` 身份凭据存在;publish skipped;tag 和 Release 未变化。
只验证某个已知平台问题时,可在用户同意后选单平台 target 以节省费用;单平台结果不能用于正式发布,完整跨平台候选验收必须使用 `all`。
@@ -76,7 +76,7 @@ release 是独立授权边界。用户必须明确指定版本并要求发布:
1. 确认版本、目标 commit、工作区、`origin/master`、同 commit 本地 preflight 和 master push CI。
2. 确认 tag 不存在;已存在时由用户明确决定,不自行覆盖。
-3. 确认完整 candidate run 已生成身份凭据和全部附件。通常 candidate 与 tag commit 相同;若只有发布基础设施变化,确认 candidate 是 tag 的祖先,GitHub compare 完整且差异严格限于 workflow、Release 附件整理、对应测试和发布文档白名单。
+3. 确认完整 candidate run 已生成身份凭据和全部附件。通常 candidate 与 tag commit 相同;若只有发布基础设施变化,确认 candidate 是 tag 的祖先,且 tag 与 candidate 的应用构建输入 SHA-256 相同。
4. 创建并推送一次 tag,监控由 tag 触发的唯一 promotion run。tag workflow 只能下载并校验该 candidate 的 artifacts,不得重新打包、签名、公证或运行 packaged App E2E。
5. promotion 失败时读取候选解析、身份凭据或附件校验错误,不通过移动 tag 或重新付费打包绕过。
6. 成功后验证 Release 非 draft、附件完整、命名和下载说明正确,并记录被提升的 candidate run。
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 9eeddc44..74e8f4cb 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -15,9 +15,58 @@ concurrency:
cancel-in-progress: true
jobs:
- verify:
+ classify:
runs-on: ubuntu-latest
- timeout-minutes: 30
+ timeout-minutes: 5
+ outputs:
+ release-only: ${{ steps.scope.outputs.release-only }}
+ steps:
+ - uses: actions/checkout@v4
+ with:
+ fetch-depth: 0
+ - name: Classify changed files
+ id: scope
+ env:
+ BASE_SHA: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }}
+ run: |
+ release_only="$(
+ node apps/desktop/scripts/release-build-input.mjs \
+ release-only "$BASE_SHA" "$GITHUB_SHA"
+ )"
+ echo "release-only=$release_only" >> "$GITHUB_OUTPUT"
+ echo "Release-only change: $release_only"
+
+ release-checks:
+ if: needs.classify.outputs.release-only == 'true'
+ needs: classify
+ runs-on: ubuntu-latest
+ timeout-minutes: 10
+ steps:
+ - uses: actions/checkout@v4
+ - uses: pnpm/action-setup@v4
+ - uses: actions/setup-node@v4
+ with:
+ node-version: 22
+ cache: pnpm
+ - uses: actions/setup-go@v5
+ with:
+ go-version: '1.25.x'
+ - run: pnpm install --frozen-lockfile
+ - name: Validate release workflows
+ run: go run github.com/rhysd/actionlint/cmd/[email protected]
+ - name: Test release tooling
+ run: >-
+ pnpm --filter @opencreator/desktop test --
+ test/release-assets.test.mjs
+ test/release-build-input.test.mjs
+ test/release-workflow.test.mjs
+ test/desktop-release-tag.test.mjs
+
+ unit:
+ if: needs.classify.outputs.release-only != 'true'
+ needs: classify
+ runs-on: ubuntu-latest
+ timeout-minutes: 25
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
@@ -33,27 +82,54 @@ jobs:
run: |
sudo apt-get update
sudo apt-get install --yes --no-install-recommends fonts-noto-cjk
+ test -f /usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc
+ test -f /usr/share/fonts/opentype/noto/NotoSansCJK-Bold.ttc
- run: pnpm install --frozen-lockfile
- - name: Validate writing templates
- run: pnpm --filter @opencreator/writing-templates test
- - run: pnpm templates:ci
- name: Audit high severity dependencies
run: pnpm audit --audit-level high --ignore-registry-errors
timeout-minutes: 5
+ - run: pnpm templates:ci
- run: pnpm krillinai:test
- - name: Install CJK fonts for article PDF tests
- run: |
- sudo apt-get update
- sudo apt-get install -y --no-install-recommends fonts-noto-cjk
- test -f /usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc
- test -f /usr/share/fonts/opentype/noto/NotoSansCJK-Bold.ttc
- name: Prepare Electron for desktop tests
run: pnpm --filter @opencreator/desktop exec node -e "require('electron')"
- run: pnpm test
- run: pnpm release:verify-scheduled-task-upgrade
+
+ compile:
+ if: needs.classify.outputs.release-only != 'true'
+ needs: classify
+ runs-on: ubuntu-latest
+ timeout-minutes: 20
+ steps:
+ - uses: actions/checkout@v4
+ - uses: pnpm/action-setup@v4
+ - uses: actions/setup-node@v4
+ with:
+ node-version: 22
+ cache: pnpm
+ - uses: actions/setup-go@v5
+ with:
+ go-version-file: runtime/krillinai/go.mod
+ cache-dependency-path: runtime/krillinai/go.sum
+ - run: pnpm install --frozen-lockfile
- run: pnpm typecheck
- run: pnpm build
- run: pnpm smoke:ci
+
+ web-parity:
+ if: needs.classify.outputs.release-only != 'true'
+ needs: classify
+ runs-on: ubuntu-latest
+ timeout-minutes: 20
+ steps:
+ - uses: actions/checkout@v4
+ - uses: pnpm/action-setup@v4
+ - uses: actions/setup-node@v4
+ with:
+ node-version: 22
+ cache: pnpm
+ - run: pnpm install --frozen-lockfile
+ - run: pnpm --filter @opencreator/web build
- run: pnpm exec playwright install --with-deps chromium
- run: pnpm e2e apps/web/e2e/web-desktop-parity.spec.ts --project=chromium-desktop
- run: pnpm perf:measure
diff --git a/.github/workflows/desktop-release.yml b/.github/workflows/desktop-release.yml
index 5921d3b8..671ae4d1 100644
--- a/.github/workflows/desktop-release.yml
+++ b/.github/workflows/desktop-release.yml
@@ -88,7 +88,7 @@ jobs:
needs: verify
timeout-minutes: 90
strategy:
- fail-fast: false
+ fail-fast: true
matrix: ${{ fromJSON(needs.verify.outputs.matrix) }}
runs-on: ${{ matrix.os }}
environment: release
@@ -138,12 +138,23 @@ jobs:
path: |
apps/desktop/.cache/electron
apps/desktop/.cache/electron-builder
- apps/desktop/.cache/codex-runtime
apps/desktop/.cache/node-gyp
apps/desktop/.cache/npm
+ key: desktop-tools-${{ runner.os }}-${{ matrix.arch }}-${{ hashFiles('pnpm-lock.yaml', 'apps/desktop/package.json', 'apps/desktop/packaging/daemon-runtime/pnpm-lock.yaml') }}
+ - uses: actions/cache@v4
+ with:
+ path: apps/desktop/.cache/codex-runtime
+ key: codex-runtime-${{ runner.os }}-${{ matrix.arch }}-${{ hashFiles('apps/desktop/scripts/prepare-codex-runtime.mjs', 'apps/desktop/scripts/codex-runtime-contract.mjs', 'resources/codex-runtime/**') }}
+ - uses: actions/cache@v4
+ with:
+ path: |
.runtime/vendor/creator-runtime/${{ matrix.platform }}-${{ matrix.arch }}
+ key: creator-runtime-${{ runner.os }}-${{ matrix.arch }}-${{ hashFiles('apps/desktop/scripts/install-creator-runtime-dependencies.mjs', 'apps/desktop/scripts/creator-runtime-releases.mjs', 'apps/desktop/scripts/prepare-creator-runtime.mjs') }}
+ - uses: actions/cache@v4
+ with:
+ path: |
.runtime/build/krillinai/${{ matrix.platform }}-${{ matrix.arch }}
- key: desktop-build-${{ runner.os }}-${{ matrix.arch }}-${{ hashFiles('pnpm-lock.yaml', 'apps/desktop/package.json', 'apps/desktop/packaging/daemon-runtime/pnpm-lock.yaml', 'apps/desktop/scripts/install-creator-runtime-dependencies.mjs', 'apps/desktop/scripts/creator-runtime-releases.mjs', 'scripts/build-krillinai.mjs', 'runtime/krillinai/**', 'resources/codex-runtime/**/manifest.json') }}
+ key: krillinai-build-${{ runner.os }}-${{ matrix.arch }}-${{ hashFiles('scripts/build-krillinai.mjs', 'runtime/krillinai/**') }}
- name: 生成 macOS 正式签名安装包
if: matrix.platform == 'darwin'
shell: bash
@@ -181,7 +192,9 @@ jobs:
OPENCREATOR_DESKTOP_TARGET_PLATFORM: ${{ matrix.platform }}
OPENCREATOR_DESKTOP_TARGET_ARCH: ${{ matrix.arch }}
- name: 验证实际打包应用
- run: pnpm --filter @opencreator/desktop e2e:package
+ run: >-
+ pnpm --filter @opencreator/desktop
+ ${{ matrix.name == 'macos-arm64' && 'e2e:package' || 'e2e:package:smoke' }}
- name: 生成 KrillinAI Server 与 CLI 独立发布包
run: pnpm krillinai:package
env:
@@ -250,17 +263,23 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
+ - uses: actions/checkout@v4
+ - name: 计算应用构建输入指纹
+ id: build-input
+ run: echo "digest=$(node apps/desktop/scripts/release-build-input.mjs digest)" >> "$GITHUB_OUTPUT"
- name: 记录可提升候选包
env:
CANDIDATE_SHA: ${{ github.sha }}
CANDIDATE_RUN_ID: ${{ github.run_id }}
CANDIDATE_REPOSITORY: ${{ github.repository }}
+ CANDIDATE_BUILD_INPUT_DIGEST: ${{ steps.build-input.outputs.digest }}
run: |
node -e '
const fs = require("node:fs");
const candidate = {
- schemaVersion: 1,
+ schemaVersion: 2,
commit: process.env.CANDIDATE_SHA,
+ buildInputDigest: process.env.CANDIDATE_BUILD_INPUT_DIGEST,
runId: Number(process.env.CANDIDATE_RUN_ID),
repository: process.env.CANDIDATE_REPOSITORY,
event: "workflow_dispatch",
@@ -271,7 +290,7 @@ jobs:
- name: 上传候选包身份凭据
uses: actions/upload-artifact@v4
with:
- name: opencreator-release-candidate-${{ github.sha }}
+ name: opencreator-release-candidate-${{ steps.build-input.outputs.digest }}
path: release-candidate.json
if-no-files-found: error
retention-days: 90
@@ -289,71 +308,43 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version: 22
+ - name: 计算应用构建输入指纹
+ id: build-input
+ run: echo "digest=$(node apps/desktop/scripts/release-build-input.mjs digest)" >> "$GITHUB_OUTPUT"
- name: 查找可复用的完整候选构建
id: candidate
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
+ CANDIDATE_NAME: opencreator-release-candidate-${{ steps.build-input.outputs.digest }}
shell: bash
run: |
- candidate_run_id=''
- candidate_sha=''
- while IFS=$'\t' read -r run_id run_sha; do
- candidate_name="opencreator-release-candidate-$run_sha"
- artifact_count="$(
- gh api --method GET "repos/$GH_REPO/actions/runs/$run_id/artifacts" \
- -f name="$candidate_name" \
- --jq '[.artifacts[] | select(.expired == false)] | length'
- )"
- [[ "$artifact_count" == "1" ]] || continue
-
- comparison="$(gh api "repos/$GH_REPO/compare/$run_sha...$GITHUB_SHA")"
- comparison_status="$(jq -r '.status' <<< "$comparison")"
- [[ "$comparison_status" == "identical" || "$comparison_status" == "ahead" ]] || continue
- changed_files="$(jq -r '.files | length' <<< "$comparison")"
- # GitHub caps compare responses at 300 files. Reject that boundary so
- # an incomplete diff can never pass the release-only allowlist.
- (( changed_files < 300 )) || continue
-
- invalid_files="$(
- jq -r '.files[].filename' <<< "$comparison" | while IFS= read -r path; do
- case "$path" in
- .github/workflows/desktop-release.yml|\
- apps/desktop/scripts/release-assets.mjs|\
- apps/desktop/test/release-assets.test.mjs|\
- apps/desktop/test/release-workflow.test.mjs|\
- apps/desktop/release-notes/*|\
- docs/operations/opencreator-desktop-release-runbook.md|\
- .codex/skills/oc-deploy/SKILL.md|\
- .codex/skills/oc-deploy/references/runbook.md)
- ;;
- *) printf '%s\n' "$path" ;;
- esac
- done
- )"
- [[ -z "$invalid_files" ]] || continue
-
- candidate_run_id="$run_id"
- candidate_sha="$run_sha"
- break
- done < <(
- gh run list \
- --workflow desktop-release.yml \
- --branch master \
- --event workflow_dispatch \
- --status success \
- --limit 50 \
- --json databaseId,headSha \
- --jq '.[] | [.databaseId, .headSha] | @tsv'
- )
-
+ candidate_run_id="$(
+ gh api --method GET "repos/$GH_REPO/actions/artifacts" \
+ -f name="$CANDIDATE_NAME" \
+ --jq '.artifacts | map(select(.expired == false)) | sort_by(.created_at) | reverse | .[0].workflow_run.id // empty'
+ )"
if [[ -z "$candidate_run_id" ]]; then
echo "::error::当前 tag 没有可复用的完整候选构建。应用构建输入发生变化时,请先从 master 运行 target=all。"
exit 1
fi
+
+ run="$(gh api "repos/$GH_REPO/actions/runs/$candidate_run_id")"
+ candidate_sha="$(jq -r '.head_sha' <<< "$run")"
+ comparison_status="$(
+ gh api "repos/$GH_REPO/compare/$candidate_sha...$GITHUB_SHA" --jq '.status'
+ )"
+ if [[ "$(jq -r '.event' <<< "$run")" != "workflow_dispatch" \
+ || "$(jq -r '.head_branch' <<< "$run")" != "master" \
+ || "$(jq -r '.conclusion' <<< "$run")" != "success" \
+ || "$(jq -r '.path' <<< "$run")" != ".github/workflows/desktop-release.yml" \
+ || ( "$comparison_status" != "identical" && "$comparison_status" != "ahead" ) ]]; then
+ echo "::error::候选构建 $candidate_run_id 的来源或祖先关系无效。"
+ exit 1
+ fi
echo "run-id=$candidate_run_id" >> "$GITHUB_OUTPUT"
echo "sha=$candidate_sha" >> "$GITHUB_OUTPUT"
- echo "name=opencreator-release-candidate-$candidate_sha" >> "$GITHUB_OUTPUT"
+ echo "name=$CANDIDATE_NAME" >> "$GITHUB_OUTPUT"
echo "使用已验证候选构建:$candidate_run_id ($candidate_sha)"
- uses: actions/download-artifact@v4
with:
@@ -380,12 +371,14 @@ jobs:
EXPECTED_SHA: ${{ steps.candidate.outputs.sha }}
EXPECTED_RUN_ID: ${{ steps.candidate.outputs.run-id }}
EXPECTED_REPOSITORY: ${{ github.repository }}
+ EXPECTED_BUILD_INPUT_DIGEST: ${{ steps.build-input.outputs.digest }}
run: |
node -e '
const fs = require("node:fs");
const candidate = JSON.parse(fs.readFileSync("candidate/release-candidate.json", "utf8"));
- const valid = candidate.schemaVersion === 1
+ const valid = candidate.schemaVersion === 2
&& candidate.commit === process.env.EXPECTED_SHA
+ && candidate.buildInputDigest === process.env.EXPECTED_BUILD_INPUT_DIGEST
&& String(candidate.runId) === process.env.EXPECTED_RUN_ID
&& candidate.repository === process.env.EXPECTED_REPOSITORY
&& candidate.event === "workflow_dispatch"
diff --git a/apps/desktop/e2e/creator-packaged-app.spec.ts b/apps/desktop/e2e/creator-packaged-app.spec.ts
index 2cf8c5e8..a32e5abd 100644
--- a/apps/desktop/e2e/creator-packaged-app.spec.ts
+++ b/apps/desktop/e2e/creator-packaged-app.spec.ts
@@ -37,7 +37,7 @@ const OVERSIZED_WAVE_PCM_BYTES = 10 * 1024 * 1024 + 4096;
const OVERSIZED_WAVE_FILE_BYTES = OVERSIZED_WAVE_PCM_BYTES + 44;
test.describe.configure({ mode: 'serial' });
-test('实际 Desktop 包创建并重启恢复 Creator Job,且使用内嵌 Runtime', async () => {
+test('@package-smoke 实际 Desktop 包创建并重启恢复 Creator Job,且使用内嵌 Runtime', async () => {
test.setTimeout(180_000);
const fixture = await launchCreatorDesktop();
let currentApp: PackagedApp = fixture.app;
diff --git a/apps/desktop/e2e/desktop.spec.ts b/apps/desktop/e2e/desktop.spec.ts
index 86ebdaf0..6242b869 100644
--- a/apps/desktop/e2e/desktop.spec.ts
+++ b/apps/desktop/e2e/desktop.spec.ts
@@ -173,7 +173,7 @@ test('bundled 模式在最小 PATH 下忽略 ChatGPT 应用内置的 Codex', asy
}
});
-test('成功 Probe 后进入 Dashboard,刷新不重复 Probe,并代理 JSON、二进制和 SSE', async ({}, testInfo) => {
+test('@package-smoke 成功 Probe 后进入 Dashboard,刷新不重复 Probe,并代理 JSON、二进制和 SSE', async ({}, testInfo) => {
const fixture = await launchPackagedDesktop('success');
try {
await waitForWorkspace(fixture.page);
@@ -911,7 +911,7 @@ test('Dashboard 握手超时后显示本地错误页并可无 Probe 重载', asy
}
});
-test('Daemon 异常退出后自动恢复且不重复 Probe', async () => {
+test('@package-smoke Daemon 异常退出后自动恢复且不重复 Probe', async () => {
const fixture = await launchPackagedDesktop('success');
try {
await waitForWorkspace(fixture.page);
@@ -955,7 +955,7 @@ test('Daemon 异常退出后自动恢复且不重复 Probe', async () => {
}
});
-test('IPC 拒绝非 OpenCreator 页面来源', async () => {
+test('@package-smoke IPC 拒绝非 OpenCreator 页面来源', async () => {
const fixture = await launchPackagedDesktop('success');
try {
await waitForWorkspace(fixture.page);
@@ -997,7 +997,7 @@ test('启动页使用 OpenCreator 文字品牌', async ({}, testInfo) => {
}
});
-test('退出期间会回收仍在 Probe 中的 Codex 子进程', async () => {
+test('@package-smoke 退出期间会回收仍在 Probe 中的 Codex 子进程', async () => {
test.setTimeout(120_000);
const fixture = await launchPackagedDesktop('probe-hang');
const pidPath = join(fixture.stateDir, 'probe-pid.txt');
diff --git a/apps/desktop/package.json b/apps/desktop/package.json
index e11f5971..f5fbfc52 100644
--- a/apps/desktop/package.json
+++ b/apps/desktop/package.json
@@ -28,6 +28,7 @@
"verify:package": "node scripts/verify-package.mjs",
"e2e": "playwright test --config playwright.config.ts",
"e2e:package": "playwright test --config playwright.config.ts",
+ "e2e:package:smoke": "playwright test --config playwright.config.ts --grep @package-smoke",
"e2e:real-codex": "playwright test --config playwright.real.config.ts",
"typecheck": "tsc -p tsconfig.main.json --noEmit && tsc -p tsconfig.test.json",
"test": "vitest run --passWithNoTests"
diff --git a/apps/desktop/scripts/release-build-input.mjs b/apps/desktop/scripts/release-build-input.mjs
new file mode 100644
index 00000000..46fe9c45
--- /dev/null
+++ b/apps/desktop/scripts/release-build-input.mjs
@@ -0,0 +1,83 @@
+import { createHash } from 'node:crypto';
+import { execFileSync } from 'node:child_process';
+import { resolve } from 'node:path';
+import { fileURLToPath } from 'node:url';
+
+const scriptPath = fileURLToPath(import.meta.url);
+
+const releaseOnlyFiles = new Set([
+ '.github/workflows/ci.yml',
+ '.github/workflows/desktop-release.yml',
+ '.codex/skills/oc-deploy/SKILL.md',
+ '.codex/skills/oc-deploy/references/runbook.md',
+ 'apps/desktop/scripts/release-assets.mjs',
+ 'apps/desktop/scripts/release-build-input.mjs',
+ 'apps/desktop/test/release-assets.test.mjs',
+ 'apps/desktop/test/release-build-input.test.mjs',
+ 'apps/desktop/test/release-workflow.test.mjs',
+ 'docs/operations/opencreator-desktop-release-runbook.md',
+ 'docs/operations/opencreator-desktop-windows-release.md'
+]);
+
+export function isReleaseOnlyPath(path) {
+ return releaseOnlyFiles.has(path) || path.startsWith('apps/desktop/release-notes/');
+}
+
+export function digestBuildEntries(entries) {
+ const included = entries
+ .filter(entry => !isReleaseOnlyPath(entry.path))
+ .sort((left, right) => left.path.localeCompare(right.path));
+ const hash = createHash('sha256');
+ for (const entry of included) {
+ hash.update(`${entry.mode} ${entry.type} ${entry.object}\t${entry.path}\n`);
+ }
+ return hash.digest('hex');
+}
+
+export function parseTreeEntries(output) {
+ return output.split('\0').filter(Boolean).map(record => {
+ const match = /^(\d+) (\w+) ([0-9a-f]+)\t(.+)$/.exec(record);
+ if (match === null) throw new Error(`Invalid git tree entry: ${record}`);
+ return { mode: match[1], type: match[2], object: match[3], path: match[4] };
+ });
+}
+
+export function buildInputDigest(ref = 'HEAD', cwd = process.cwd()) {
+ const output = execFileSync(
+ 'git',
+ ['ls-tree', '-r', '-z', '--full-tree', ref],
+ { cwd, encoding: 'utf8' }
+ );
+ return digestBuildEntries(parseTreeEntries(output));
+}
+
+export function changedPaths(base, head, cwd = process.cwd()) {
+ if (!base || /^0+$/.test(base)) return null;
+ const output = execFileSync(
+ 'git',
+ ['diff', '--name-only', '-z', base, head],
+ { cwd, encoding: 'utf8' }
+ );
+ return output.split('\0').filter(Boolean);
+}
+
+export function changesAreReleaseOnly(paths) {
+ return paths !== null && paths.length > 0 && paths.every(isReleaseOnlyPath);
+}
+
+if (process.argv[1] && resolve(process.argv[1]) === scriptPath) {
+ try {
+ const [command = 'digest', ...args] = process.argv.slice(2);
+ if (command === 'digest') {
+ console.log(buildInputDigest(args[0] ?? 'HEAD'));
+ } else if (command === 'release-only') {
+ if (args.length !== 2) throw new Error('release-only requires <base> <head>');
+ console.log(changesAreReleaseOnly(changedPaths(args[0], args[1])) ? 'true' : 'false');
+ } else {
+ throw new Error(`Unknown command: ${command}`);
+ }
+ } catch (error) {
+ console.error(error instanceof Error ? error.message : String(error));
+ process.exitCode = 1;
+ }
+}
diff --git a/apps/desktop/test/release-build-input.test.mjs b/apps/desktop/test/release-build-input.test.mjs
new file mode 100644
index 00000000..09ac0bcc
--- /dev/null
+++ b/apps/desktop/test/release-build-input.test.mjs
@@ -0,0 +1,52 @@
+import { describe, expect, it } from 'vitest';
+import {
+ changesAreReleaseOnly,
+ digestBuildEntries,
+ isReleaseOnlyPath,
+ parseTreeEntries
+} from '../scripts/release-build-input.mjs';
+
+const appEntry = {
+ mode: '100644',
+ type: 'blob',
+ object: '1111111111111111111111111111111111111111',
+ path: 'apps/web/src/App.tsx'
+};
+const releaseEntry = {
+ mode: '100644',
+ type: 'blob',
+ object: '2222222222222222222222222222222222222222',
+ path: '.github/workflows/desktop-release.yml'
+};
+
+describe('release build input identity', () => {
+ it('classifies only explicit release infrastructure as release-only', () => {
+ expect(isReleaseOnlyPath(releaseEntry.path)).toBe(true);
+ expect(isReleaseOnlyPath('apps/desktop/release-notes/v3.2.2.md')).toBe(true);
+ expect(isReleaseOnlyPath(appEntry.path)).toBe(false);
+ expect(changesAreReleaseOnly([releaseEntry.path])).toBe(true);
+ expect(changesAreReleaseOnly([releaseEntry.path, appEntry.path])).toBe(false);
+ expect(changesAreReleaseOnly([])).toBe(false);
+ expect(changesAreReleaseOnly(null)).toBe(false);
+ });
+
+ it('keeps release-only changes out of the digest and includes product changes', () => {
+ const initial = digestBuildEntries([appEntry, releaseEntry]);
+ const changedRelease = digestBuildEntries([
+ appEntry,
+ { ...releaseEntry, object: '3333333333333333333333333333333333333333' }
+ ]);
+ const changedApp = digestBuildEntries([
+ { ...appEntry, object: '4444444444444444444444444444444444444444' },
+ releaseEntry
+ ]);
+ expect(changedRelease).toBe(initial);
+ expect(changedApp).not.toBe(initial);
+ });
+
+ it('parses null-delimited git tree records', () => {
+ expect(parseTreeEntries(
+ '100644 blob 1111111111111111111111111111111111111111\tapps/web/src/App.tsx\0'
+ )).toEqual([appEntry]);
+ });
+});
diff --git a/apps/desktop/test/release-workflow.test.mjs b/apps/desktop/test/release-workflow.test.mjs
index fd21d07c..4d629d11 100644
--- a/apps/desktop/test/release-workflow.test.mjs
+++ b/apps/desktop/test/release-workflow.test.mjs
@@ -24,6 +24,12 @@ describe('Desktop release workflow', () => {
expect(ciWorkflow).toContain('\n push:');
expect(ciWorkflow).toContain(' - master');
expect(ciWorkflow).toContain('cancel-in-progress: true');
+ expect(ciWorkflow).toContain('classify:');
+ expect(ciWorkflow).toContain('release-checks:');
+ expect(ciWorkflow).toContain('unit:');
+ expect(ciWorkflow).toContain('compile:');
+ expect(ciWorkflow).toContain('web-parity:');
+ expect(ciWorkflow).toContain("needs.classify.outputs.release-only == 'true'");
});
it('runs the network audit before expensive verification steps', () => {
@@ -73,8 +79,8 @@ describe('Desktop release workflow', () => {
expect(releaseWorkflow).not.toContain('run: pnpm build');
});
- it('keeps platform diagnostics after one package target fails', () => {
- expect(releaseWorkflow).toContain('fail-fast: false');
+ it('cancels sibling package jobs while preserving failure diagnostics', () => {
+ expect(releaseWorkflow).toContain('fail-fast: true');
expect(releaseWorkflow).toContain('tail -n 80 desktop-release.log');
expect(releaseWorkflow).toContain(
'::error title=macOS release failure details::'
@@ -95,16 +101,20 @@ describe('Desktop release workflow', () => {
);
expect(releaseWorkflow).toContain("candidate-ready:");
expect(releaseWorkflow).toContain("inputs.target == 'all'");
- expect(releaseWorkflow).toContain('opencreator-release-candidate-${{ github.sha }}');
+ expect(releaseWorkflow).toContain('e2e:package:smoke');
+ expect(releaseWorkflow).toContain("matrix.name == 'macos-arm64'");
+ expect(releaseWorkflow).toContain('opencreator-release-candidate-${{ steps.build-input.outputs.digest }}');
});
it('promotes an immutable successful master candidate instead of rebuilding a tag', () => {
expect(releaseWorkflow).toContain("if: github.event_name == 'workflow_dispatch'");
expect(releaseWorkflow).toContain('name: 查找可复用的完整候选构建');
- expect(releaseWorkflow).toContain('repos/$GH_REPO/compare/$run_sha...$GITHUB_SHA');
+ expect(releaseWorkflow).toContain('release-build-input.mjs digest');
+ expect(releaseWorkflow).toContain('repos/$GH_REPO/compare/$candidate_sha...$GITHUB_SHA');
expect(releaseWorkflow).toContain('comparison_status');
- expect(releaseWorkflow).toContain('changed_files');
- expect(releaseWorkflow).toContain('apps/desktop/scripts/release-assets.mjs');
+ expect(releaseWorkflow).toContain('CANDIDATE_BUILD_INPUT_DIGEST');
+ expect(releaseWorkflow).toContain('candidate.schemaVersion === 2');
+ expect(releaseWorkflow).toContain('candidate.buildInputDigest');
expect(releaseWorkflow).toContain('当前 tag 没有可复用的完整候选构建');
expect(releaseWorkflow).toContain('run-id: ${{ steps.candidate.outputs.run-id }}');
expect(releaseWorkflow).toContain('name: ${{ steps.candidate.outputs.name }}');
diff --git a/docs/operations/opencreator-desktop-release-runbook.md b/docs/operations/opencreator-desktop-release-runbook.md
index b519f215..9b429525 100644
--- a/docs/operations/opencreator-desktop-release-runbook.md
+++ b/docs/operations/opencreator-desktop-release-runbook.md
@@ -43,11 +43,11 @@ pnpm desktop:package
1. 更新 `apps/desktop/package.json` 的版本。
2. 确认 GitHub Release 发布权限、签名凭据和目标版本更新元数据流程可用。
-3. 先推送版本提交到 `master`,等待同一提交的 CI 通过,再从 `master` 手动运行 `.github/workflows/desktop-release.yml`,并选择 `target=all`。
-4. 完整候选工作流使用 `macos-15-intel`、`macos-15` 和 `windows-latest` 并行构建三个原生目标平台。macOS 使用正式 Developer ID 签名和 Apple 公证;每个平台都必须通过实际打包应用 E2E。单平台运行只用于诊断,不能用于正式发布。
-5. 三个平台和 Linux KrillinAI 附件全部成功后,工作流写入绑定 Git commit、workflow run 和仓库的候选身份凭据。候选附件保存于该 workflow run,不允许构建后替换。
-6. 候选全绿后才创建并推送 `v<version>` Git tag。标签版本必须与 `apps/desktop/package.json` 完全一致。通常 tag 指向候选 commit;候选后只有发布 workflow、Release 附件整理脚本、对应测试或发布文档变化时,可以复用原候选。
-7. tag 工作流不再重复构建、签名、公证或 E2E;它查找最新的成功 `target=all` 候选,并通过 GitHub compare 确认候选是 tag 的祖先、差异列表完整且全部属于严格的发布基础设施白名单。任何 App、Runtime、依赖或打包输入变化都会拒绝复用并要求新候选。随后工作流复核 run 与候选身份凭据,下载已验证附件,校验附件白名单并发布 GitHub Release。
+3. 先推送版本提交到 `master`,等待同一提交的 CI 通过,再从 `master` 手动运行 `.github/workflows/desktop-release.yml`,并选择 `target=all`。CI 会把纯发布基础设施改动分流到 release checks;产品改动并行执行 unit、compile 和 Web/Desktop parity。
+4. 完整候选工作流使用 `macos-15-intel`、`macos-15` 和 `windows-latest` 并行构建三个原生目标平台,任一 matrix job 失败会自动取消 sibling jobs。macOS 使用正式 Developer ID 签名和 Apple 公证。macOS arm64 运行完整 packaged App E2E;macOS x64 和 Windows x64 运行真实 App smoke 与平台能力套件。单平台运行只用于诊断,不能用于正式发布。
+5. 三个平台和 Linux KrillinAI 附件全部成功后,工作流计算排除发布专用文件的应用构建输入 SHA-256,并写入绑定该指纹、Git commit、workflow run 和仓库的候选身份凭据。候选附件保存于该 workflow run,不允许构建后替换。
+6. 候选全绿后才创建并推送 `v<version>` Git tag。标签版本必须与 `apps/desktop/package.json` 完全一致。通常 tag 指向候选 commit;候选后只有发布基础设施变化且应用构建输入 SHA-256 不变时,可以复用原候选。
+7. tag 工作流不再重复构建、签名、公证或 E2E;它按应用构建输入 SHA-256 查找成功的 `target=all` 候选,并确认候选 commit 是 tag commit 的祖先。任何 App、Runtime、依赖或打包输入变化都会产生不同指纹并要求新候选。随后工作流复核 run 与候选身份凭据,下载已验证附件,校验附件白名单并发布 GitHub Release。
示例:
diff --git a/docs/operations/opencreator-desktop-windows-release.md b/docs/operations/opencreator-desktop-windows-release.md
index 2c136e4a..1fbb86c8 100644
--- a/docs/operations/opencreator-desktop-windows-release.md
+++ b/docs/operations/opencreator-desktop-windows-release.md
@@ -122,7 +122,7 @@ Get-AuthenticodeSignature ".\OpenCreator Setup <version>.exe" | Format-List
1. `pnpm test`。
2. `pnpm typecheck`。
3. `pnpm desktop:release` 生成 NSIS、blockmap、`latest.yml` 和构建清单。
-4. `pnpm --filter @opencreator/desktop e2e:package`。
+4. `pnpm --filter @opencreator/desktop e2e:package:smoke`,覆盖真实 App Runtime、平台能力、代理、恢复、安全和进程回收;完整共享套件由 macOS arm64 候选执行。
5. `pnpm --filter @opencreator/desktop verify:package`,由打包脚本自动调用。
6. 上传安装包、更新元数据和构建清单。