mirror of
https://gitlab.com/vyla-entertainment/home.git
synced 2026-11-13 21:57:21 -05:00
feat: add signed Windows launcher self-updates with SHA-256 verification
This commit is contained in:
20
release.js
20
release.js
@@ -2,6 +2,8 @@ const fs = require('fs');
|
||||
const path = require('path');
|
||||
const https = require('https');
|
||||
const { execSync } = require('child_process');
|
||||
const crypto = require('crypto');
|
||||
const UpdateClient = require('./update-client');
|
||||
|
||||
const GITLAB_PROJECT_PATH = 'vyla-entertainment%2Fhome';
|
||||
const PROJECT_ID = process.env.CI_PROJECT_ID || GITLAB_PROJECT_PATH;
|
||||
@@ -217,6 +219,24 @@ async function main() {
|
||||
}
|
||||
}
|
||||
|
||||
if (installerPath && installerUploadName && process.platform === 'win32') {
|
||||
const signingKey = process.env.VYLA_UPDATE_SIGNING_KEY;
|
||||
if (!signingKey) {
|
||||
throw new Error('VYLA_UPDATE_SIGNING_KEY is required to sign the installer entry.');
|
||||
}
|
||||
const installerBuf = fs.readFileSync(installerPath);
|
||||
const signedManifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8'));
|
||||
signedManifest.installer = {
|
||||
file: installerUploadName,
|
||||
sha256: crypto.createHash('sha256').update(installerBuf).digest('hex'),
|
||||
size: installerBuf.length,
|
||||
version: version.replace(/^v/, '')
|
||||
};
|
||||
delete signedManifest.signature;
|
||||
signedManifest.signature = crypto.sign(null, Buffer.from(UpdateClient.canonicalManifest(signedManifest)), signingKey.replace(/\\n/g, '\n')).toString('base64');
|
||||
fs.writeFileSync(manifestPath, JSON.stringify(signedManifest, null, 2), 'utf8');
|
||||
}
|
||||
|
||||
console.log('[2/4] Uploading artifacts to GitLab Package Registry...');
|
||||
const timestamp = Date.now();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user