release: bump version to 0.80.3
ci / backend (push) Waiting to run
ci / frontend (push) Waiting to run

This commit is contained in:
linkong committed 2026-11-30 14:35:38 +08:00
1 parent 2c439b7235
commit 6d310f4dbe
19 files changed
+541 -91

No files matched your search

+117 -25
View File
@@ -1,6 +1,8 @@
import { spawnSync } from 'node:child_process'
import {
chmodSync,
copyFileSync,
cpSync,
existsSync,
mkdirSync,
mkdtempSync,
@@ -130,33 +132,123 @@ function resolveLinuxTargets() {
return targets
}
function toWslPath(winPath) {
if (!winPath) return ''
const res = spawnSync('wslpath', ['-u', winPath], { encoding: 'utf8' })
return res.status === 0 ? (res.stdout || '').trim() : ''
}
function toWinPath(linuxPath) {
const res = spawnSync('wslpath', ['-w', linuxPath], { encoding: 'utf8' })
return res.status === 0 ? (res.stdout || '').trim() : ''
}
function resolveElectronVersion() {
try {
const pkg = JSON.parse(readFileSync(join(desktopRoot, 'package.json'), 'utf8'))
const raw = String(pkg?.devDependencies?.electron || '').replace(/^[^0-9]*/, '')
return raw || ''
} catch {
return ''
}
}
function runWinViaWindowsHost() {
if (!isWsl()) return false
const winProbeScript = [
'$candidates = @(',
' (Get-Command bun.exe -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Source),',
' (Join-Path $env:USERPROFILE ".bun\\bin\\bun.exe"),',
' (Join-Path $env:USERPROFILE "scoop\\shims\\bun.exe"),',
' (Join-Path $env:LOCALAPPDATA "bun\\bin\\bun.exe")',
') | Where-Object { $_ -and (Test-Path -LiteralPath $_) }',
'$candidates | Select-Object -First 1',
'$env:PLANET_WIN_BUN_EXE',
'(Get-Command bun.exe -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Source)',
'(Join-Path $env:USERPROFILE ".bun\\bin\\bun.exe")',
'(Join-Path $env:USERPROFILE "scoop\\shims\\bun.exe")',
'(Join-Path $env:LOCALAPPDATA "bun\\bin\\bun.exe")',
'@(Get-ChildItem (Join-Path $env:LOCALAPPDATA "PlanetReleaseBuild\\*\\tools\\bun.exe") -ErrorAction SilentlyContinue | Sort-Object LastWriteTime -Descending | Select-Object -ExpandProperty FullName)',
].join(', ')
const probePs = [
`$candidates = @(${winProbeScript}) | Where-Object { $_ -and (Test-Path -LiteralPath $_) }`,
'$bunPath = $candidates | Select-Object -First 1',
'$cacheDirs = @((Get-ChildItem (Join-Path $env:LOCALAPPDATA "PlanetReleaseBuild\\*\\electron-cache") -Directory -ErrorAction SilentlyContinue | Sort-Object LastWriteTime -Descending | Select-Object -ExpandProperty FullName), (Join-Path $env:LOCALAPPDATA "electron\\Cache")) | Where-Object { $_ -and (Test-Path -LiteralPath $_) }',
'$cacheHit = $cacheDirs | Where-Object { Get-ChildItem $_ -Filter "electron-v*-win32-x64.zip" -ErrorAction SilentlyContinue } | Select-Object -First 1',
'Write-Output ("LOCALAPPDATA=" + $env:LOCALAPPDATA)',
'Write-Output ("BUN=" + $bunPath)',
'Write-Output ("ELECTRON_CACHE=" + $cacheHit)',
].join('; ')
const winBunCheck = spawnSync('powershell.exe', ['-NoProfile', '-Command', winProbeScript], { encoding: 'utf8' })
const winBunPath = (winBunCheck.stdout || '').trim().split(/\r?\n/)[0]?.trim() || ''
const winPathRes = spawnSync('wslpath', ['-w', desktopRoot], { encoding: 'utf8' })
const winDesktopRoot = (winPathRes.stdout || '').trim()
if (winBunCheck.status !== 0 || !winBunPath || !winDesktopRoot) return false
const probe = spawnSync('powershell.exe', ['-NoProfile', '-Command', probePs], { encoding: 'utf8' })
if (probe.status !== 0) return false
console.log(`WSL2 detected; building Windows NSIS + portable installers via Windows host Bun (${winBunPath})...`)
const psScript = [
"$ErrorActionPreference = 'Stop'",
`$env:ELECTRON_MIRROR = '${env.ELECTRON_MIRROR}'`,
`$env:ELECTRON_BUILDER_BINARIES_MIRROR = '${env.ELECTRON_BUILDER_BINARIES_MIRROR}'`,
`Set-Location -LiteralPath '${winDesktopRoot.replace(/'/g, "''")}'`,
`& '${winBunPath.replace(/'/g, "''")}' x electron-builder --win nsis portable --publish never`,
].join('; ')
const winRun = spawnSync('powershell.exe', ['-NoProfile', '-Command', psScript], { stdio: 'inherit' })
return (winRun.status ?? 1) === 0
const info = {}
for (const line of (probe.stdout || '').split(/\r?\n/)) {
const idx = line.indexOf('=')
if (idx > 0) info[line.slice(0, idx).trim()] = line.slice(idx + 1).trim()
}
const winBunPath = info.BUN || ''
const winLocalAppData = info.LOCALAPPDATA || ''
if (!winBunPath || !winLocalAppData) return false
const localAppDataWsl = toWslPath(winLocalAppData)
if (!localAppDataWsl) return false
const releaseOutDir = join(desktopRoot, 'release')
mkdirSync(releaseOutDir, { recursive: true })
const stageRoot = join(localAppDataWsl, 'PlanetReleaseBuild', `wsl-stage-${process.pid}`)
const stageClient = join(stageRoot, 'client')
const stageRelease = join(stageClient, 'release')
const stageCache = join(stageRoot, 'electron-cache')
mkdirSync(stageClient, { recursive: true })
let winElectronDist = info.ELECTRON_CACHE || ''
const electronVer = resolveElectronVersion()
const wslElectronZip = electronVer ? join(homedir(), '.cache', 'electron', `electron-v${electronVer}-win32-x64.zip`) : ''
if (!winElectronDist && wslElectronZip && existsSync(wslElectronZip)) {
mkdirSync(stageCache, { recursive: true })
copyFileSync(wslElectronZip, join(stageCache, `electron-v${electronVer}-win32-x64.zip`))
winElectronDist = toWinPath(stageCache)
}
try {
console.log(`WSL2 detected; staging Windows NSIS + zip build on NTFS via ${winBunPath}...`)
for (const rel of ['package.json', 'bun.lock', 'electron-builder.yml', 'dist-electron', '.earth-bundle', 'resources', 'scripts']) {
const src = join(desktopRoot, rel)
if (!existsSync(src)) {
throw new Error(`Missing required client build asset for Windows staging: ${src}`)
}
cpSync(src, join(stageClient, rel), { recursive: true })
}
const winStageClient = toWinPath(stageClient)
if (!winStageClient) return false
const builderArgs = ['--win', 'nsis', 'zip', '--x64', '--publish', 'never']
if (winElectronDist) {
builderArgs.push(`--config.electronDist=${winElectronDist}`)
}
const psArgs = builderArgs.map((arg) => `'${arg.replace(/'/g, "''")}'`).join(' ')
const psScript = [
"$ErrorActionPreference = 'Stop'",
`$env:ELECTRON_MIRROR = '${env.ELECTRON_MIRROR}'`,
`$env:ELECTRON_BUILDER_BINARIES_MIRROR = '${env.ELECTRON_BUILDER_BINARIES_MIRROR}'`,
`Set-Location -LiteralPath '${winStageClient.replace(/'/g, "''")}'`,
`& '${winBunPath.replace(/'/g, "''")}' install --frozen-lockfile --ignore-scripts`,
'if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }',
`& '${winBunPath.replace(/'/g, "''")}' ./node_modules/electron-builder/cli.js ${psArgs}`,
'if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }',
].join('; ')
const winRun = spawnSync('powershell.exe', ['-NoProfile', '-Command', psScript], { stdio: 'inherit' })
if ((winRun.status ?? 1) !== 0 || !existsSync(stageRelease)) {
return false
}
let copied = 0
for (const entry of readdirSync(stageRelease)) {
if (entry.startsWith('__uninstaller-')) continue
if (entry.toLowerCase().endsWith('.exe') || entry.toLowerCase().endsWith('-win.zip')) {
copyFileSync(join(stageRelease, entry), join(releaseOutDir, entry))
copied += 1
}
}
return copied >= 2
} finally {
rmSync(stageRoot, { recursive: true, force: true })
}
}
function runWinViaDockerWine() {
@@ -170,7 +262,7 @@ function runWinViaDockerWine() {
const uid = typeof process.getuid === 'function' ? process.getuid() : 0
const gid = typeof process.getgid === 'function' ? process.getgid() : 0
console.log(`Building Windows NSIS + portable installers via Docker Wine (${image})...`)
console.log(`Building Windows NSIS + zip installers via Docker Wine (${image})...`)
const dockerCmd = [
'run', '--rm',
'-v', `${desktopRoot}:/project`,
@@ -181,7 +273,7 @@ function runWinViaDockerWine() {
'-w', '/project',
image,
'bash', '-lc',
`./node_modules/.bin/electron-builder --win nsis portable --publish never; status=$?; chown -R ${uid}:${gid} /project/release 2>/dev/null || true; exit $status`,
`./node_modules/.bin/electron-builder --win nsis zip --publish never; status=$?; chown -R ${uid}:${gid} /project/release 2>/dev/null || true; exit $status`,
]
const res = spawnSync('docker', dockerCmd, { stdio: 'inherit' })
return (res.status ?? 1) === 0
@@ -189,7 +281,7 @@ function runWinViaDockerWine() {
function runWinBuild() {
if (process.platform === 'win32' || hasCommand('wine') || hasCommand('wine64')) {
runBuilder(['--win', 'nsis', 'portable'])
runBuilder(['--win', 'nsis', 'zip'])
return
}