diff --git a/apps/ai-game-creator-shell/scripts/build-release.mjs b/apps/ai-game-creator-shell/scripts/build-release.mjs index 8e77f8295..ea65c7028 100644 --- a/apps/ai-game-creator-shell/scripts/build-release.mjs +++ b/apps/ai-game-creator-shell/scripts/build-release.mjs @@ -510,6 +510,18 @@ export function selectFirstInstallArtifact( if (!selected?.endsWith('.exe')) { throw new Error('Windows 首装包必须复用本次 NSIS .exe 更新包'); } + } else if (target === 'universal-apple-darwin') { + // universal 主程序只产出一个 DMG,aarch64 与 x86_64 首装共用它(命名见 build-macos-ci.mjs)。 + const suffix = `_${version}_universal.dmg`; + const candidates = files.filter((file) => + path.basename(file).endsWith(suffix), + ); + if (candidates.length !== 1) { + throw new Error( + `首装 DMG 必须唯一匹配本次版本 ${version} 的 universal 产物,找到 ${candidates.length} 个`, + ); + } + selected = candidates[0]; } else { // Tauri DMG 文件名使用 aarch64 / x64,而 updater 的 Intel 平台键是 x86_64。 const architecture = target.startsWith('aarch64') ? 'aarch64' : 'x64'; diff --git a/apps/ai-game-creator-shell/scripts/build-release.test.mjs b/apps/ai-game-creator-shell/scripts/build-release.test.mjs index ec5455806..a3ee68627 100644 --- a/apps/ai-game-creator-shell/scripts/build-release.test.mjs +++ b/apps/ai-game-creator-shell/scripts/build-release.test.mjs @@ -44,7 +44,11 @@ const packageVersion = JSON.parse( ).version; function createDmgFixture(root, target, version = packageVersion) { - const architecture = target.startsWith('aarch64') ? 'aarch64' : 'x64'; + const architecture = target.startsWith('aarch64') + ? 'aarch64' + : target === universalTarget + ? 'universal' + : 'x64'; const dmg = path.join(root, `陶泥儿_${version}_${architecture}.dmg`); writeFileSync(dmg, 'first installation disk image'); return dmg; @@ -440,7 +444,13 @@ test('universal uses the Mac channel and the same signed artifact for both archi assert.equal(context.channel, 'dev-mac'); assert.ok(context.bundleRoot.includes(universalTarget)); withSignedArtifact('陶泥儿.app.tar.gz', (artifact) => { - const manifest = createUpdateManifest(artifact, context); + const manifest = createUpdateManifest(artifact, { + ...context, + downloadArtifact: createDmgFixture( + path.dirname(artifact), + universalTarget, + ), + }); assert.deepEqual(Object.keys(manifest.platforms), [ 'darwin-aarch64', 'darwin-x86_64', @@ -450,6 +460,12 @@ test('universal uses the Mac channel and the same signed artifact for both archi manifest.platforms['darwin-x86_64'], ); assert.match(manifest.platforms['darwin-aarch64'].url, /\/dev-mac\//); + // 两个平台键共用同一个 universal 首装包,不能要求出两份架构 DMG。 + assert.deepEqual( + manifest.downloads['darwin-aarch64'].url, + manifest.downloads['darwin-x86_64'].url, + ); + assert.match(manifest.downloads['darwin-aarch64'].url, /_universal\.dmg$/u); }); });