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
|
|
@ -7,9 +7,6 @@ const root = join(dirname(fileURLToPath(import.meta.url)), '..', '..')
|
|||
// canonical updater feed: Forgejo Generic Package Registry
|
||||
const CANONICAL_UPDATE_FEED =
|
||||
'https://git.chanpaca.net/api/packages/yunchan/generic/d3ro-voice/latest'
|
||||
// legacy mirror: GitLab Generic Registry (pre-Forgejo installs still poll this)
|
||||
const LEGACY_UPDATE_FEED =
|
||||
'https://gitlab.twentyoz.kr:8443/api/v4/projects/1172/packages/generic/d3ro-voice/latest'
|
||||
|
||||
function read(path) {
|
||||
return readFileSync(join(root, path), 'utf8')
|
||||
|
|
@ -31,7 +28,9 @@ function loadSurfaces(readSurface = read) {
|
|||
updatePolicySource: readSurface('apps/desktop/src/main/update-policy.ts'),
|
||||
updateService: readSurface('apps/desktop/src/main/services/UpdateService.ts'),
|
||||
updateAdapters: readSurface('apps/desktop/src/main/services/update-adapters.ts'),
|
||||
publisher: readSurface('scripts/ci/publish-gitlab-release.mjs'),
|
||||
updateSignature: readSurface('apps/desktop/src/main/update-signature.ts'),
|
||||
updatePublicKey: readSurface('release/desktop-update-public.pem'),
|
||||
releaseCommand: readSurface('scripts/ci/release-desktop.mjs'),
|
||||
forgejoPublisher: readSurface('scripts/ci/publish-forgejo-release.mjs'),
|
||||
gitlab: readSurface('.gitlab-ci.yml'),
|
||||
forgejoRelease: readSurface('.forgejo/workflows/release.yml'),
|
||||
|
|
@ -128,12 +127,35 @@ function validate(surfaces) {
|
|||
|
||||
// ── canonical feed contract: runtime == builder == Forgejo canonical ──
|
||||
const sourceFeed = surfaces.updateFeed.match(/UPDATE_FEED_URL\s*=\s*\n?\s*['"]([^'"]+)['"]/)?.[1]
|
||||
const legacyFeed = surfaces.updateFeed.match(/LEGACY_UPDATE_FEED_URL\s*=\s*\n?\s*['"]([^'"]+)['"]/)?.[1]
|
||||
const builderFeed = surfaces.builder.match(/publish:\s*[\s\S]*?\n\s+url:\s*["']([^"']+)["']/)?.[1]
|
||||
fail(sourceFeed === CANONICAL_UPDATE_FEED, 'desktop_runtime_update_feed_drift')
|
||||
fail(builderFeed === CANONICAL_UPDATE_FEED, 'desktop_builder_update_feed_drift')
|
||||
fail(!/\/releases\/\d+\.\d+\.\d+/.test(sourceFeed ?? ''), 'desktop_update_feed_version_pinned')
|
||||
fail(legacyFeed === LEGACY_UPDATE_FEED, 'desktop_legacy_mirror_feed_missing')
|
||||
fail(!surfaces.updateFeed.includes('gitlab'), 'desktop_legacy_gitlab_feed_reintroduced')
|
||||
|
||||
// ── 업데이트 메타데이터 Ed25519 서명: 앱 내장 공개키 == 저장소 공개키, 앱이 실제로 검증 ──
|
||||
const embeddedKey = surfaces.updateSignature.match(/UPDATE_SIGNING_PUBLIC_KEY = `([^`]+)`/)?.[1]?.trim()
|
||||
let updateKeyValid = false
|
||||
try {
|
||||
updateKeyValid = createPublicKey(surfaces.updatePublicKey).asymmetricKeyType === 'ed25519'
|
||||
} catch {
|
||||
updateKeyValid = false
|
||||
}
|
||||
fail(updateKeyValid, 'update_signing_public_key_invalid')
|
||||
fail(embeddedKey === surfaces.updatePublicKey.trim(), 'update_signing_public_key_drift')
|
||||
fail(surfaces.updateAdapters.includes('verifyDownloadedUpdate('), 'update_signature_verification_missing')
|
||||
fail(
|
||||
surfaces.forgejoPublisher.includes('signManifest(') && surfaces.forgejoPublisher.includes('verifySignedPublicManifest()'),
|
||||
'forgejo_publisher_manifest_signing_missing',
|
||||
)
|
||||
fail(surfaces.forgejoRelease.includes('D3RO_UPDATE_SIGNING_KEY'), 'forgejo_release_signing_key_missing')
|
||||
// 로컬 한 줄 명령과 CI 예비 경로가 같은 빌드·게시 스크립트를 써야 한다
|
||||
fail(
|
||||
surfaces.releaseCommand.includes('build-desktop-installer.mjs') &&
|
||||
surfaces.releaseCommand.includes('publish-forgejo-release.mjs') &&
|
||||
surfaces.forgejoRelease.includes('build-desktop-installer.mjs'),
|
||||
'release_paths_diverged',
|
||||
)
|
||||
|
||||
// ── update policy SSOT ──
|
||||
const policy = surfaces.updatePolicy
|
||||
|
|
@ -183,12 +205,6 @@ function validate(surfaces) {
|
|||
'update_service_differential_control_missing',
|
||||
)
|
||||
|
||||
// ── legacy GitLab publisher (mirror) ──
|
||||
fail(surfaces.publisher.includes('const latestFiles = [...sortedFiles].sort'), 'publisher_asset_first_order_missing')
|
||||
fail(!surfaces.publisher.includes('deletePackagesForVersion("latest")'), 'publisher_deletes_live_feed_first')
|
||||
fail(surfaces.publisher.includes('verifyPublicLatestFile'), 'publisher_public_metadata_verification_missing')
|
||||
fail(surfaces.publisher.includes('release/product-version.json'), 'publisher_product_version_gate_missing')
|
||||
|
||||
// ── canonical Forgejo publisher contract ──
|
||||
fail(!/1\.0\.0/.test(surfaces.forgejoPublisher), 'forgejo_publisher_hardcoded_version')
|
||||
fail(surfaces.forgejoPublisher.includes('release/product-version.json'), 'forgejo_publisher_version_gate_missing')
|
||||
|
|
@ -243,7 +259,6 @@ function validate(surfaces) {
|
|||
androidVersionCode: metadata.androidVersionCode,
|
||||
iosBuildNumber: metadata.iosBuildNumber,
|
||||
updateFeed: sourceFeed,
|
||||
legacyUpdateFeed: legacyFeed,
|
||||
updateChannel: policy.defaultChannel,
|
||||
minimumSupportedVersion: policy.minimumSupportedVersion,
|
||||
electronVersion: lockedElectron,
|
||||
|
|
@ -282,9 +297,16 @@ if (process.argv.includes('--self-test')) {
|
|||
expectRejected(
|
||||
surfaces,
|
||||
(candidate) => {
|
||||
candidate.updateFeed = candidate.updateFeed.replace(LEGACY_UPDATE_FEED, 'https://example.invalid/legacy')
|
||||
candidate.updatePublicKey = candidate.desktopLicensePublicKey
|
||||
},
|
||||
'desktop_legacy_mirror_feed_missing',
|
||||
'update_signing_public_key_drift',
|
||||
)
|
||||
expectRejected(
|
||||
surfaces,
|
||||
(candidate) => {
|
||||
candidate.updateAdapters = candidate.updateAdapters.replaceAll('verifyDownloadedUpdate(', 'skipVerification(')
|
||||
},
|
||||
'update_signature_verification_missing',
|
||||
)
|
||||
expectRejected(
|
||||
surfaces,
|
||||
|
|
@ -345,9 +367,9 @@ if (process.argv.includes('--self-test')) {
|
|||
expectRejected(
|
||||
surfaces,
|
||||
(candidate) => {
|
||||
candidate.publisher = candidate.publisher.replace('const latestFiles = [...sortedFiles].sort', 'const latestFiles = sortedFiles.sort')
|
||||
candidate.forgejoPublisher = candidate.forgejoPublisher.replaceAll('signManifest(', 'noSign(')
|
||||
},
|
||||
'publisher_asset_first_order_missing',
|
||||
'forgejo_publisher_manifest_signing_missing',
|
||||
)
|
||||
expectRejected(
|
||||
surfaces,
|
||||
|
|
@ -385,7 +407,7 @@ if (process.argv.includes('--self-test')) {
|
|||
if (!missingDesktopKeyRejected) {
|
||||
throw new Error('release_metadata_self_test_failed:desktop_license_public_key_missing')
|
||||
}
|
||||
result.negativeCases = 14
|
||||
result.negativeCases = 16
|
||||
}
|
||||
|
||||
process.stdout.write(`${JSON.stringify(result, null, 2)}\n`)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue