fix(release): stop shipping native modules built for the wrong runtime
Some checks failed
deploy-site / deploy (push) Failing after 14m16s
Some checks failed
deploy-site / deploy (push) Failing after 14m16s
The released installer could not start: it carried a better-sqlite3 build for the host Node runtime instead of Electron, so the app died immediately with a module version mismatch when it opened its database. Packaging now proves the Electron build of every runtime-sensitive native module before an installer or archive exists, and installers are produced only from that verified tree, so the mistake cannot pass silently. The release pipelines run the same check. The default local model also pointed at a retired model: a *.gguf name that Ollama cannot serve, while the settings, onboarding, and guide screens recommended an older model. All of them now use the model the service code already preferred.
This commit is contained in:
parent
0fbbbc1756
commit
1af3cf75c7
42 changed files with 473 additions and 83 deletions
|
|
@ -41,13 +41,16 @@ const version = JSON.parse(
|
|||
const releaseDir = join(desktopDir, 'release', version)
|
||||
|
||||
if (build) {
|
||||
console.log('[updater] electron-builder NSIS 빌드 ( 전용 — 런타임 제외)')
|
||||
const appDir = join(releaseDir, 'win-unpacked')
|
||||
|
||||
// 1) 먼저 unpacked 트리빌드한다.
|
||||
console.log('[updater] electron-builder --dir (앱 전용 — 런타임 제외)')
|
||||
const result = spawnSync(
|
||||
'npx',
|
||||
[
|
||||
'electron-builder',
|
||||
'--win',
|
||||
'nsis',
|
||||
'dir',
|
||||
'--x64',
|
||||
'--config',
|
||||
'electron-builder.yml',
|
||||
|
|
@ -62,6 +65,48 @@ if (build) {
|
|||
console.error(`[updater] 빌드 실패 (exit ${result.status ?? 'null'})`)
|
||||
process.exit(result.status ?? 1)
|
||||
}
|
||||
|
||||
// 2) 네이티브 모듈 ABI 보장 + 검증 (호스트 Node ABI가 섞이면 이 시작조차 못 한다)
|
||||
runNodeScript('scripts/ci/fix-native-abi.mjs', ['--dir', appDir])
|
||||
runNodeScript('scripts/ci/verify-native-abi.mjs', ['--dir', appDir])
|
||||
|
||||
// 3) 검증된 트리에서 설치본 생성 (--prepackaged = 재빌드 없이 그대로 패키징)
|
||||
console.log('[updater] electron-builder --prepackaged (NSIS x64)')
|
||||
const packageResult = spawnSync(
|
||||
'npx',
|
||||
[
|
||||
'electron-builder',
|
||||
'--prepackaged',
|
||||
appDir,
|
||||
'--win',
|
||||
'nsis',
|
||||
'--x64',
|
||||
'--config',
|
||||
'electron-builder.yml',
|
||||
'--publish',
|
||||
'never',
|
||||
'-c.win.forceCodeSigning=false',
|
||||
'-c.npmRebuild=false',
|
||||
],
|
||||
{ cwd: desktopDir, stdio: 'inherit', shell: process.platform === 'win32' },
|
||||
)
|
||||
if (packageResult.status !== 0) {
|
||||
console.error(`[updater] 설치본 생성 실패 (exit ${packageResult.status ?? 'null'})`)
|
||||
process.exit(packageResult.status ?? 1)
|
||||
}
|
||||
}
|
||||
|
||||
/** 이 스크립트와 같은 Node로 CI 스크립트를 실행한다 */
|
||||
function runNodeScript(relativePath, scriptArgs) {
|
||||
console.log(`[updater] $ node ${relativePath} ${scriptArgs.join(' ')}`)
|
||||
const result = spawnSync(process.execPath, [join(root, relativePath), ...scriptArgs], {
|
||||
cwd: root,
|
||||
stdio: 'inherit',
|
||||
})
|
||||
if (result.status !== 0) {
|
||||
console.error(`[updater] ${relativePath} 실패 (exit ${result.status ?? 'null'})`)
|
||||
process.exit(result.status ?? 1)
|
||||
}
|
||||
}
|
||||
|
||||
const metadataPath = join(releaseDir, 'latest.yml')
|
||||
|
|
@ -143,6 +188,25 @@ if (!ackUnsigned) {
|
|||
|
||||
const authorization = forgejoAuthorization()
|
||||
|
||||
/**
|
||||
* 원격 파일이 로컬 바이트와 같은지 판단한다.
|
||||
* Forgejo generic registry는 HEAD를 405로 거부하고 해시도 주지 않으므로,
|
||||
* Range GET으로 크기를 본 뒤 1MiB 이하는 실제 바이트까지 비교한다.
|
||||
* (크기만 비교하면 버전 문자열만 바뀐 latest.yml 같은 메타데이터를 놓친다 — 실측 사고.)
|
||||
*/
|
||||
async function remoteIsIdentical(url, body, fetchImpl) {
|
||||
const probe = await fetchImpl(url, { headers: { Range: 'bytes=0-0' } }).catch(() => null)
|
||||
if (!probe?.ok) return false
|
||||
const contentRange = probe.headers.get('content-range')
|
||||
const remoteSize = contentRange ? Number(contentRange.split('/')[1]) : NaN
|
||||
if (!Number.isFinite(remoteSize) || remoteSize !== body.length) return false
|
||||
if (body.length > 1024 * 1024) return true
|
||||
const full = await fetchImpl(url).catch(() => null)
|
||||
if (!full?.ok) return false
|
||||
const remoteBytes = Buffer.from(await full.arrayBuffer())
|
||||
return remoteBytes.length === body.length && remoteBytes.equals(body)
|
||||
}
|
||||
|
||||
async function forgejoFetch(url, init = {}) {
|
||||
return fetch(url, {
|
||||
...init,
|
||||
|
|
@ -164,19 +228,16 @@ for (const target of targets) {
|
|||
const url = `${target}/${encodeURIComponent(payload.name)}`
|
||||
const body = await readFile(payload.path)
|
||||
|
||||
// Forgejo generic registry는 같은 경로에 다른 바이트가 있으면 409를 돌려준다.
|
||||
// 메타데이터(latest.yml / update-policy.json)는 최신을 가리켜야 하므로 먼저 지운다.
|
||||
// (설치본/블록맵은 파일명에 버전이 있어 충돌하지 않는다.)
|
||||
const existing = await forgejoFetch(url, { headers: { Range: 'bytes=0-0' } }).catch(
|
||||
() => null,
|
||||
)
|
||||
// Forgejo generic registry는 HEAD를 405로 거부하고 해시도 주지 않는다.
|
||||
// 크기만 비교하면 버전 문자열만 바뀐 latest.yml을 "동일"로 오판한다 — 내용까지 비교한다.
|
||||
if (await remoteIsIdentical(url, body, forgejoFetch)) {
|
||||
console.log(`[updater] 이미 동일한 파일이 있습니다(건너): ${url}`)
|
||||
continue
|
||||
}
|
||||
|
||||
// 메타데이터는 최신을 가리켜야 하므로 기존 파일을 지우고 쓴다(PUT은 409를 돌려준다).
|
||||
const existing = await forgejoFetch(url, { headers: { Range: 'bytes=0-0' } }).catch(() => null)
|
||||
if (existing?.ok) {
|
||||
const contentRange = existing.headers.get('content-range')
|
||||
const remoteSize = contentRange ? Number(contentRange.split('/')[1]) : NaN
|
||||
if (remoteSize === body.length) {
|
||||
console.log(`[updater] 이미 동일한 파일이 있습니다(건너뜀): ${url}`)
|
||||
continue
|
||||
}
|
||||
await forgejoFetch(url, { method: 'DELETE' }).catch(() => null)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue