build: use one cross-platform Desktop release packaging script

This commit is contained in:
techflag
2026-09-26 20:06:22 +08:00
parent 2f30140796
commit 5cac25748c
7 changed files with 70 additions and 53 deletions
+6 -48
View File
@@ -157,29 +157,9 @@ jobs:
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: yarn-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('yarn.lock', '.yarnrc.yml') }}
- run: yarn install --immutable
- run: yarn upstream:install
- run: yarn workspace dsh-plugin-desktop check:win-package
- name: Pack this commit's Web Profile for package validation
if: github.ref_type != 'tag'
working-directory: workdsh-web
run: |
corepack pnpm install --frozen-lockfile
corepack pnpm build
corepack pnpm release:project:pack
- name: Prepare WorkDSH release profile
timeout-minutes: 15
env:
WORKDSH_USE_LOCAL_RELEASE: ${{ github.ref_type != 'tag' && '1' || '0' }}
run: yarn workspace dsh-plugin-desktop prepare:workdsh-runtime
- name: Prepare official Python and Node runtime
timeout-minutes: 15
run: yarn workspace dsh-plugin-desktop prepare:workdsh-primary-runtime
- name: Build Windows installer
timeout-minutes: 30
env:
DSH_PACKAGE_CHECK_ALREADY_RAN: '1'
run: node dsh-plugin-desktop/scripts/package-win.ts
- name: Package Windows through the single release script
timeout-minutes: 60
run: node scripts/package-desktop-release.mjs --source=${{ github.ref_type == 'tag' && 'published' || 'local' }}
- name: Report unpacked Windows footprint
run: node dsh-plugin-desktop/scripts/report-package-footprint.mjs dsh-plugin-desktop/dist/win-unpacked dsh-plugin-desktop/dist/windows-footprint.json
- name: Upload Windows footprint report
@@ -229,33 +209,11 @@ jobs:
with:
path: ${{ steps.yarn-cache.outputs.dir }}
key: yarn-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('yarn.lock', '.yarnrc.yml') }}
- run: yarn install --immutable
- run: yarn upstream:install
- run: yarn workspace dsh-plugin-desktop check:mac-package
- name: Pack this commit's Web Profile for package validation
if: github.ref_type != 'tag'
working-directory: workdsh-web
run: |
corepack pnpm install --frozen-lockfile
corepack pnpm build
corepack pnpm release:project:pack
- name: Prepare WorkDSH release profile
timeout-minutes: 15
- name: Package macOS through the single release script
timeout-minutes: 55
env:
WORKDSH_MAC_ARCH: ${{ matrix.arch }}
WORKDSH_USE_LOCAL_RELEASE: ${{ github.ref_type != 'tag' && '1' || '0' }}
run: yarn workspace dsh-plugin-desktop prepare:workdsh-runtime
- name: Prepare official Python and Node runtime
timeout-minutes: 15
env:
WORKDSH_MAC_ARCH: ${{ matrix.arch }}
run: yarn workspace dsh-plugin-desktop prepare:workdsh-primary-runtime
- name: Build macOS smoke artifact
timeout-minutes: 25
env:
DSH_PACKAGE_CHECK_ALREADY_RAN: '1'
WORKDSH_MAC_ARCH: ${{ matrix.arch }}
run: node dsh-plugin-desktop/scripts/package-mac.ts
run: node scripts/package-desktop-release.mjs --source=${{ github.ref_type == 'tag' && 'published' || 'local' }}
- name: Upload macOS architecture DMG
uses: actions/upload-artifact@v4
with:
+2 -2
View File
@@ -1,5 +1,5 @@
# Bilingual-pair consistency record: the git blob hash of each side as of the last
# confirmed-consistent state. Both languages carry equal authority. Update both files
# and re-record their hashes after editing either side.
README.md: 72453b59bdb0c0cd63d5ff8058df121b6f64c35c
README.zh-CN.md: 3aabc96ad9047087264b662e1f98ba8185e8cee2
README.md: 636211746118f3e3d09c65a3301cd5c319a89a11
README.zh-CN.md: 886a541b6e12b67eeb46564f3e56b1893bdf9003
+1 -1
View File
@@ -78,7 +78,7 @@ corepack yarn install --immutable
corepack yarn dev
```
Run checks with `corepack yarn check`. [Contributing](CONTRIBUTING.en.md)
Run checks with `corepack yarn check`. On macOS or Windows, `corepack yarn release:pack` builds the Web Profile and Desktop package from the current commit. Once the Web package is published, use `corepack yarn release:pack:published` for the final installer. Both commands share the same [packaging script](scripts/package-desktop-release.mjs). [Contributing](CONTRIBUTING.en.md)
## Community and acknowledgements
+1 -1
View File
@@ -78,7 +78,7 @@ corepack yarn install --immutable
corepack yarn dev
```
运行检查:`corepack yarn check`。[参与贡献](CONTRIBUTING.md)
运行检查:`corepack yarn check`。在 macOS 或 Windows 上,从当前提交一键打包 Web Profile 与 Desktop:`corepack yarn release:pack`;Web 包发布后,正式安装包使用 `corepack yarn release:pack:published`。两条命令使用同一个[打包脚本](scripts/package-desktop-release.mjs)。[参与贡献](CONTRIBUTING.md)
## 社区与致谢
+2
View File
@@ -39,6 +39,8 @@
"dist:mac-smoke": "yarn workspace dsh-plugin-desktop dist:mac-smoke",
"dist:win": "yarn workspace dsh-plugin-desktop dist:win",
"dist:win-portable": "yarn workspace dsh-plugin-desktop dist:win-portable",
"release:pack": "node scripts/package-desktop-release.mjs --source=local",
"release:pack:published": "node scripts/package-desktop-release.mjs --source=published",
"upstream:version": "cd deepseek-harness && corepack pnpm --version",
"upstream:install": "cd deepseek-harness && CI=true corepack pnpm install --frozen-lockfile",
"upstream:build": "cd deepseek-harness && corepack pnpm run build",
+56
View File
@@ -0,0 +1,56 @@
#!/usr/bin/env node
import { spawnSync } from 'node:child_process'
import { readFileSync } from 'node:fs'
import { dirname, join, resolve } from 'node:path'
import { fileURLToPath } from 'node:url'
const root = resolve(dirname(fileURLToPath(import.meta.url)), '..')
const webRoot = join(root, 'workdsh-web')
const args = process.argv.slice(2)
const sourceArg = args.find(arg => arg.startsWith('--source='))
if (args.length !== 1 || !sourceArg || !['local', 'published'].includes(sourceArg.slice('--source='.length))) {
throw new Error('Usage: node scripts/package-desktop-release.mjs --source=local|published')
}
const source = sourceArg.slice('--source='.length)
const platform = process.platform
if (platform !== 'darwin' && platform !== 'win32') {
throw new Error(`Desktop installer packaging requires macOS or Windows; found ${platform}`)
}
const corepack = platform === 'win32' ? 'corepack.cmd' : 'corepack'
function run(label, command, commandArgs, { cwd = root, env = process.env } = {}) {
console.log(`\n==> ${label}`)
const result = spawnSync(command, commandArgs, {
cwd,
env,
stdio: 'inherit',
shell: platform === 'win32' && command === corepack,
})
if (result.error) throw result.error
if (result.status !== 0) throw new Error(`${label} failed with exit code ${result.status}`)
}
run('Install Desktop dependencies', corepack, ['yarn', 'install', '--immutable'])
run('Install the pinned official DSH checkout dependencies', corepack, ['yarn', 'upstream:install'])
run('Check Desktop packaging', corepack, ['yarn', 'workspace', 'dsh-plugin-desktop', platform === 'win32' ? 'check:win-package' : 'check:mac-package'])
if (source === 'local') {
run('Install Web dependencies', corepack, ['pnpm', 'install', '--frozen-lockfile'], { cwd: webRoot })
run('Build WorkDSH Web and plugins', corepack, ['pnpm', 'build'], { cwd: webRoot })
run('Pack this commit\'s WorkDSH Profile', corepack, ['pnpm', 'release:project:pack'], { cwd: webRoot })
const version = JSON.parse(readFileSync(join(webRoot, 'package.json'), 'utf8')).version
const manifest = JSON.parse(readFileSync(join(webRoot, '.artifacts', `project-v${version}`, 'release-manifest.json'), 'utf8'))
if (manifest.version !== version || manifest.sourceDirty) {
throw new Error('The local Web release candidate is not a clean package of this commit')
}
}
const runtimeEnv = { ...process.env, WORKDSH_USE_LOCAL_RELEASE: source === 'local' ? '1' : '0' }
run('Prepare the single WorkDSH DSH Profile', corepack, ['yarn', 'workspace', 'dsh-plugin-desktop', 'prepare:workdsh-runtime'], { env: runtimeEnv })
run('Prepare bundled Python and Node.js', corepack, ['yarn', 'workspace', 'dsh-plugin-desktop', 'prepare:workdsh-primary-runtime'], { env: runtimeEnv })
run('Build the Desktop installer', process.execPath, [join(root, 'dsh-plugin-desktop', 'scripts', platform === 'win32' ? 'package-win.ts' : 'package-mac.ts')], {
env: { ...runtimeEnv, DSH_PACKAGE_CHECK_ALREADY_RAN: '1' },
})
console.log(`\nDesktop package completed using ${source === 'local' ? 'this commit\'s Web Profile' : 'the published Web Profile'}.`)
+2 -1
View File
@@ -28,8 +28,9 @@ await rm(destination, { recursive: true, force: true });
await mkdir(destination, { recursive: true });
for (const directory of packageDirectories) {
execFileSync('corepack', ['pnpm', 'pack', '--pack-destination', destination], {
execFileSync(process.platform === 'win32' ? 'corepack.cmd' : 'corepack', ['pnpm', 'pack', '--pack-destination', destination], {
cwd: join(root, directory),
shell: process.platform === 'win32',
stdio: 'inherit',
});
}