CI
CI / Build & Test (push) Successful in 3m8s

This commit is contained in:
Raven Scott
2026-03-04 00:32:31 -05:00
parent 38459b1855
commit b03f67b126
+38 -18
View File
@@ -323,6 +323,7 @@ async function build(hosts, doPackage) {
}
const built = []
const builtEntries = []
for (const [platform, platformHosts] of groups) {
for await (const file of platform(NATIVE_HOST_DIR, bundle, null, {
@@ -335,11 +336,12 @@ async function build(hosts, doPackage) {
})) {
console.log(' Built:', path.relative(ROOT, file))
built.push(file)
builtEntries.push({ file, platformHosts })
}
}
if (doPackage) {
await createZipArchives(built)
await createZipArchives(builtEntries)
}
console.log('\nDone.')
@@ -348,13 +350,11 @@ async function build(hosts, doPackage) {
/**
* 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.
* correctly. bare-build may use ABI subdirs (aarch64, x86_64, arm64) for both
* darwin and linux; platformHosts disambiguates (e.g. [linux-arm64, linux-x64]
* vs [darwin-arm64, darwin-x64]). When not provided, path-only heuristics are used.
*/
function getHostFromBuiltPath(filePath) {
function getHostFromBuiltPath(filePath, platformHosts = null) {
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'
@@ -362,15 +362,28 @@ function getHostFromBuiltPath(filePath) {
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
// bare-build linux platform may use arm64 / x86_64 (ABI names), same as apple's aarch64/x86_64
if (platformHosts && platformHosts.length > 0) {
if (lower.includes('arm64/') || lower.includes('aarch64/')) {
const arm = platformHosts.find(h => h.includes('arm64') || h.includes('aarch64'))
if (arm) return arm
}
if (lower.includes('x86_64/')) {
const x64 = platformHosts.find(h => h.includes('x64'))
if (x64) return x64
}
}
// Path-only: apple typically uses aarch64 / x86_64 for darwin
if (lower.includes('aarch64/')) return 'darwin-arm64'
if (lower.includes('x86_64/')) return 'darwin-x64'
// Linux ABI subdir without "linux-" prefix (e.g. arm64/ on Linux runner)
if (lower.includes('arm64/')) return 'linux-arm64'
// 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) {
async function createZipArchives(builtEntries) {
let archiver
try {
archiver = require('archiver')
@@ -379,21 +392,21 @@ async function createZipArchives(builtFiles) {
return
}
// Group built files by host (from path) so we create exactly one zip per host
// with the correct name. When multiple files map to the same host (e.g. apple
// yields universal + aarch64 + x86_64), keep one per host so we don't overwrite
// or mislabel (e.g. Windows exe must become holesail-browser-host-win32-x64.zip).
// Group built files by host (from path + platform context) so we create exactly one zip
// per host. platformHosts disambiguates when bare-build uses ABI subdirs (arm64, x86_64)
// for both darwin and linux.
const byHost = new Map()
const hostOrder = ['darwin-arm64', 'darwin-x64', 'linux-arm64', 'linux-x64', 'win32-x64']
let fallbackIdx = 0
for (const file of builtFiles) {
let host = getHostFromBuiltPath(file)
for (const { file, platformHosts } of builtEntries) {
let host = getHostFromBuiltPath(file, platformHosts)
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('/'))) {
const isArchSpecific = rel.includes('/') && (rel.includes('aarch64') || rel.includes('x86_64') || rel.includes('arm64') || rel.includes('linux-') || rel.includes('win32') || rel.endsWith('.exe'))
const current = byHost.get(host)
const currentRel = current ? path.relative(RELEASES_DIR, current).replace(/\\/g, '/').toLowerCase() : ''
if (!current || (isArchSpecific && !currentRel.includes('/'))) {
byHost.set(host, file)
}
}
@@ -422,6 +435,13 @@ async function createZipArchives(builtFiles) {
console.log(' Packaged:', zipName)
}
const expectedHosts = ['darwin-arm64', 'darwin-x64', 'linux-arm64', 'linux-x64', 'win32-x64']
const missing = expectedHosts.filter(h => !byHost.has(h))
if (missing.length > 0) {
console.warn(' Warning: no build output for:', missing.join(', '))
console.warn(' Run on Linux (e.g. CI) with --all --package to get all platform zips.')
}
}
const { hosts, doPackage } = parseArgs()