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 built = []
const builtEntries = []
for (const [platform, platformHosts] of groups) { for (const [platform, platformHosts] of groups) {
for await (const file of platform(NATIVE_HOST_DIR, bundle, null, { 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)) console.log(' Built:', path.relative(ROOT, file))
built.push(file) built.push(file)
builtEntries.push({ file, platformHosts })
} }
} }
if (doPackage) { if (doPackage) {
await createZipArchives(built) await createZipArchives(builtEntries)
} }
console.log('\nDone.') 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 * 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, * correctly. bare-build may use ABI subdirs (aarch64, x86_64, arm64) for both
* win32-x64, or a single .exe at releases root. The previous logic used * darwin and linux; platformHosts disambiguates (e.g. [linux-arm64, linux-x64]
* hosts[hostIdx++] which broke when platform modules yielded a different number * vs [darwin-arm64, darwin-x64]). When not provided, path-only heuristics are used.
* 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) { function getHostFromBuiltPath(filePath, platformHosts = null) {
const normalized = path.relative(RELEASES_DIR, filePath).replace(/\\/g, '/') const normalized = path.relative(RELEASES_DIR, filePath).replace(/\\/g, '/')
const lower = normalized.toLowerCase() const lower = normalized.toLowerCase()
if (lower.endsWith('.exe') || lower.includes('win32-x64') || lower.includes('win32-x64/')) return 'win32-x64' 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('linux-x64')) return 'linux-x64'
if (lower.includes('darwin-arm64')) return 'darwin-arm64' if (lower.includes('darwin-arm64')) return 'darwin-arm64'
if (lower.includes('darwin-x64')) return 'darwin-x64' 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('aarch64/')) return 'darwin-arm64'
if (lower.includes('x86_64/')) return 'darwin-x64' 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 // 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' if (normalized === 'holesail-browser-host' || normalized.startsWith('holesail-browser-host/')) return 'darwin-arm64'
return null return null
} }
async function createZipArchives(builtFiles) { async function createZipArchives(builtEntries) {
let archiver let archiver
try { try {
archiver = require('archiver') archiver = require('archiver')
@@ -379,21 +392,21 @@ async function createZipArchives(builtFiles) {
return return
} }
// Group built files by host (from path) so we create exactly one zip per host // Group built files by host (from path + platform context) so we create exactly one zip
// with the correct name. When multiple files map to the same host (e.g. apple // per host. platformHosts disambiguates when bare-build uses ABI subdirs (arm64, x86_64)
// yields universal + aarch64 + x86_64), keep one per host so we don't overwrite // for both darwin and linux.
// or mislabel (e.g. Windows exe must become holesail-browser-host-win32-x64.zip).
const byHost = new Map() const byHost = new Map()
const hostOrder = ['darwin-arm64', 'darwin-x64', 'linux-arm64', 'linux-x64', 'win32-x64'] const hostOrder = ['darwin-arm64', 'darwin-x64', 'linux-arm64', 'linux-x64', 'win32-x64']
let fallbackIdx = 0 let fallbackIdx = 0
for (const file of builtFiles) { for (const { file, platformHosts } of builtEntries) {
let host = getHostFromBuiltPath(file) let host = getHostFromBuiltPath(file, platformHosts)
if (!host) host = hostOrder[fallbackIdx++] || 'unknown' if (!host) host = hostOrder[fallbackIdx++] || 'unknown'
const rel = path.relative(RELEASES_DIR, file).replace(/\\/g, '/').toLowerCase() 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('arm64') || rel.includes('linux-') || rel.includes('win32') || rel.endsWith('.exe'))
const isArchSpecific = rel.includes('/') && (rel.includes('aarch64') || rel.includes('x86_64') || rel.includes('linux-') || rel.includes('win32') || rel.endsWith('.exe')) const current = byHost.get(host)
if (!byHost.has(host) || (isArchSpecific && !path.relative(RELEASES_DIR, byHost.get(host)).replace(/\\/g, '/').toLowerCase().includes('/'))) { const currentRel = current ? path.relative(RELEASES_DIR, current).replace(/\\/g, '/').toLowerCase() : ''
if (!current || (isArchSpecific && !currentRel.includes('/'))) {
byHost.set(host, file) byHost.set(host, file)
} }
} }
@@ -422,6 +435,13 @@ async function createZipArchives(builtFiles) {
console.log(' Packaged:', zipName) 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() const { hosts, doPackage } = parseArgs()