Fix CI
CI / Build & Test (push) Successful in 2m31s

This commit is contained in:
Raven Scott
2026-03-04 00:26:34 -05:00
parent 80759f8b0c
commit 38459b1855
+43 -10
View File
@@ -339,14 +339,38 @@ async function build(hosts, doPackage) {
} }
if (doPackage) { if (doPackage) {
await createZipArchives(hosts, built) await createZipArchives(built)
} }
console.log('\nDone.') console.log('\nDone.')
return built return built
} }
async function createZipArchives(hosts, builtFiles) { /**
* Infer the host (platform-arch) from a built file path so each zip is named
* correctly. bare-build outputs into subdirs like aarch64, x86_64, linux-arm64,
* win32-x64, or a single .exe at releases root. The previous logic used
* hosts[hostIdx++] which broke when platform modules yielded a different number
* of files than hosts (e.g. apple yields 3 files for 2 hosts, windows yields
* 1 file), causing the Windows exe to get "unknown" and no win32-x64.zip.
*/
function getHostFromBuiltPath(filePath) {
const normalized = path.relative(RELEASES_DIR, filePath).replace(/\\/g, '/')
const lower = normalized.toLowerCase()
if (lower.endsWith('.exe') || lower.includes('win32-x64') || lower.includes('win32-x64/')) return 'win32-x64'
if (lower.includes('linux-arm64')) return 'linux-arm64'
if (lower.includes('linux-x64')) return 'linux-x64'
if (lower.includes('darwin-arm64')) return 'darwin-arm64'
if (lower.includes('darwin-x64')) return 'darwin-x64'
// bare-build apple platform uses aarch64 / x86_64 subdirs for darwin
if (lower.includes('aarch64/')) return 'darwin-arm64'
if (lower.includes('x86_64/')) return 'darwin-x64'
// Fallback: top-level "holesail-browser-host" (no arch) is often universal darwin
if (normalized === 'holesail-browser-host' || normalized.startsWith('holesail-browser-host/')) return 'darwin-arm64'
return null
}
async function createZipArchives(builtFiles) {
let archiver let archiver
try { try {
archiver = require('archiver') archiver = require('archiver')
@@ -355,17 +379,26 @@ async function createZipArchives(hosts, builtFiles) {
return return
} }
// Group built files by host. bare-build may output one file per host group // Group built files by host (from path) so we create exactly one zip per host
// (e.g. apple produces one fat binary for all darwin hosts), so we zip each // with the correct name. When multiple files map to the same host (e.g. apple
// unique built file once, named after the first host in its group. // yields universal + aarch64 + x86_64), keep one per host so we don't overwrite
const seen = new Set() // or mislabel (e.g. Windows exe must become holesail-browser-host-win32-x64.zip).
let hostIdx = 0 const byHost = new Map()
const hostOrder = ['darwin-arm64', 'darwin-x64', 'linux-arm64', 'linux-x64', 'win32-x64']
let fallbackIdx = 0
for (const file of builtFiles) { for (const file of builtFiles) {
if (seen.has(file)) continue let host = getHostFromBuiltPath(file)
seen.add(file) if (!host) host = hostOrder[fallbackIdx++] || 'unknown'
const rel = path.relative(RELEASES_DIR, file).replace(/\\/g, '/').toLowerCase()
// Prefer arch-specific path over generic (e.g. aarch64/holesail-browser-host over holesail-browser-host)
const isArchSpecific = rel.includes('/') && (rel.includes('aarch64') || rel.includes('x86_64') || rel.includes('linux-') || rel.includes('win32') || rel.endsWith('.exe'))
if (!byHost.has(host) || (isArchSpecific && !path.relative(RELEASES_DIR, byHost.get(host)).replace(/\\/g, '/').toLowerCase().includes('/'))) {
byHost.set(host, file)
}
}
const host = hosts[hostIdx++] || 'unknown' for (const [host, file] of byHost) {
const zipName = `holesail-browser-host-${host}.zip` const zipName = `holesail-browser-host-${host}.zip`
const zipPath = path.join(RELEASES_DIR, zipName) const zipPath = path.join(RELEASES_DIR, zipName)