feat(release): one-command desktop release with Ed25519-signed update metadata

The installer is unsigned, so latest.yml is now signed with an Ed25519 key and the
app verifies the downloaded installer against it before installing.
npm run release -- patch|minor bumps, gates, tags, builds, signs, publishes,
re-verifies the public feed and pushes; --resume continues after a failure.
The retired GitLab registry publisher is removed.
This commit is contained in:
Yun Chan 2026-10-18 07:06:55 +09:00
parent f5ae4c8c04
commit fd9c97b7cc
21 changed files with 986 additions and 144 deletions

View file

@ -8,7 +8,8 @@ import { app, dialog } from 'electron'
import { getLogger } from './LoggerService'
import { configGet } from './ConfigService'
import { getMainWindow } from '../windows/WindowManager'
import { UPDATE_FEED_URL, UPDATE_POLICY_URL } from '../update-feed'
import { UPDATE_FEED_URL, UPDATE_POLICY_URL, versionedManifestUrl } from '../update-feed'
import { verifyDownloadedUpdate } from '../update-signature'
import { DEFAULT_UPDATE_POLICY, parseUpdatePolicy, type UpdatePolicy } from '../update-policy'
import { PORTABLE_INSTALL_MARKER, detectInstallKind, type InstallProbe } from '../install-kind'
import type {
@ -24,6 +25,41 @@ const logger = getLogger('UpdateService')
/** 원격 정책 fetch 타임아웃 */
const POLICY_FETCH_TIMEOUT_MS = 8_000
/** 서명된 latest.yml fetch 타임아웃 */
const MANIFEST_FETCH_TIMEOUT_MS = 15_000
async function fetchText(url: string): Promise<string> {
const response = await fetch(url, { cache: 'no-store', signal: AbortSignal.timeout(MANIFEST_FETCH_TIMEOUT_MS) })
if (!response.ok) throw new Error(`HTTP ${response.status} ${url}`)
return response.text()
}
/**
* NsisUpdater 는 받은 파일을 넘기기 전에 `verifySignature(path)` 를 부르고, 문자열을 돌려받으면
* 파일을 지우고 ERR_UPDATER_INVALID_SIGNATURE 로 실패한다. 무서명 앱에선 이 단계가 아무것도 안 하므로
* 우리 Ed25519 검증으로 바꿔 끼운다. 라이브러리가 이 지점을 없애면 업데이트를 받지 않는다(fail-closed).
*/
function installManifestVerifier(
updater: import('electron-updater').AppUpdater,
offeredVersion: () => string | null,
): boolean {
const target = updater as unknown as { verifySignature?: (path: string) => Promise<string | null> }
if (typeof target.verifySignature !== 'function') return false
target.verifySignature = async (installerPath: string): Promise<string | null> => {
const version = offeredVersion()
if (!version) return '받으려던 버전을 알 수 없음'
const rejection = await verifyDownloadedUpdate({
version,
installerPath,
fetchText,
manifestUrl: versionedManifestUrl(version),
})
if (rejection) logger.error(`업데이트 v${version} 설치 거부 — ${rejection}`)
else logger.info(`업데이트 v${version} 서명 확인 완료`)
return rejection
}
return true
}
/** 실행 중인 설치본의 형태를 파일 시스템에서 읽는다 (판단은 detectInstallKind). */
function probeInstall(): InstallProbe {
@ -74,6 +110,13 @@ export function createElectronUpdater(handlers: UpdaterEventHandlers): UpdaterPo
return null
}
let offeredVersion: string | null = null
// macOS 는 Squirrel.Mac 이 앱 코드 서명을 직접 요구하므로 이 검증은 Windows(NSIS) 전용이다.
if (process.platform === 'win32' && !installManifestVerifier(updater, () => offeredVersion)) {
logger.error('electron-updater 에 설치 파일 검증 지점(verifySignature)이 없음 — 자동 업데이트 비활성')
return null
}
updater.setFeedURL({ provider: 'generic', url: UPDATE_FEED_URL })
// 사용자 인가를 위해 자동 다운로드는 비활성화 (동의 시 downloadUpdate 호출)
updater.autoDownload = false
@ -87,7 +130,10 @@ export function createElectronUpdater(handlers: UpdaterEventHandlers): UpdaterPo
}
updater.on('checking-for-update', () => handlers.onChecking())
updater.on('update-available', (info) => handlers.onAvailable(info))
updater.on('update-available', (info) => {
offeredVersion = info.version
handlers.onAvailable(info)
})
updater.on('update-not-available', (info) => handlers.onNotAvailable(info.version))
updater.on('download-progress', (progress) =>
handlers.onProgress({