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:
parent
f5ae4c8c04
commit
fd9c97b7cc
21 changed files with 986 additions and 144 deletions
46
scripts/ci/create-update-signing-key.mjs
Normal file
46
scripts/ci/create-update-signing-key.mjs
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
// scripts/ci/create-update-signing-key.mjs
|
||||
// 업데이트 메타데이터 서명용 Ed25519 키를 한 번 만든다.
|
||||
// - 비밀키 → 루트 .env 의 D3RO_UPDATE_SIGNING_KEY (이미 있으면 중단 — 키를 바꾸면 기존 앱이 새 릴리스를 거부한다)
|
||||
// - 공개키 → release/desktop-update-public.pem
|
||||
// 그 다음 공개키를 apps/desktop/src/main/update-signature.ts 의 UPDATE_SIGNING_PUBLIC_KEY 에 넣고,
|
||||
// `npm run release:secrets` 로 Forgejo 시크릿에 동기화한다.
|
||||
//
|
||||
// 키를 잃어버리면 이 공개키를 내장한 설치본은 새 릴리스를 더는 받지 못한다(수동 재설치 필요).
|
||||
// .env 백업이 유일한 복구 수단이다.
|
||||
|
||||
import { generateKeyPairSync } from 'node:crypto'
|
||||
import { appendFileSync, existsSync, readFileSync, writeFileSync } from 'node:fs'
|
||||
import { dirname, join } from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import { SIGNING_KEY_ENV, signManifest, verifyManifest } from './lib/update-manifest-signature.mjs'
|
||||
|
||||
const root = join(dirname(fileURLToPath(import.meta.url)), '..', '..')
|
||||
const envPath = join(root, '.env')
|
||||
const publicPath = join(root, 'release', 'desktop-update-public.pem')
|
||||
|
||||
const envText = existsSync(envPath) ? readFileSync(envPath, 'utf8') : ''
|
||||
if (new RegExp(`^${SIGNING_KEY_ENV}=`, 'm').test(envText)) {
|
||||
process.stderr.write(`[update-key] .env 에 ${SIGNING_KEY_ENV} 가 이미 있습니다 — 덮어쓰지 않습니다.\n`)
|
||||
process.exit(1)
|
||||
}
|
||||
if (existsSync(publicPath)) {
|
||||
process.stderr.write(`[update-key] ${publicPath} 가 이미 있습니다 — 덮어쓰지 않습니다.\n`)
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
const { privateKey, publicKey } = generateKeyPairSync('ed25519')
|
||||
const publicPem = publicKey.export({ type: 'spki', format: 'pem' }).toString()
|
||||
const probe = 'version: 0.0.0\n'
|
||||
if (!verifyManifest(probe, signManifest(probe, privateKey), publicPem)) {
|
||||
process.stderr.write('[update-key] 생성한 키 자체 검사 실패\n')
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
const privateB64 = privateKey.export({ type: 'pkcs8', format: 'der' }).toString('base64')
|
||||
const separator = envText && !envText.endsWith('\n') ? '\n' : ''
|
||||
appendFileSync(
|
||||
envPath,
|
||||
`${separator}\n# 데스크톱 업데이트 메타데이터 서명 키 (Ed25519, 잃어버리면 기존 앱이 새 릴리스를 거부)\n${SIGNING_KEY_ENV}=${privateB64}\n`,
|
||||
)
|
||||
writeFileSync(publicPath, publicPem, { flag: 'wx' })
|
||||
process.stdout.write(`[update-key] 비밀키 → .env ${SIGNING_KEY_ENV}\n[update-key] 공개키 → ${publicPath}\n${publicPem}`)
|
||||
Loading…
Add table
Add a link
Reference in a new issue