d3ro-voice/scripts/ci/generate-checksums.mjs
Yun Chan 708e20f747
Some checks failed
CI Pipeline / Code Quality & Typecheck (push) Waiting to run
CI Pipeline / Test Suite (macos-latest) (push) Blocked by required conditions
CI Pipeline / Test Suite (ubuntu-latest) (push) Blocked by required conditions
CI Pipeline / Test Suite (windows-latest) (push) Blocked by required conditions
CI Pipeline / Build Validation (admin) (push) Blocked by required conditions
CI Pipeline / Build Validation (desktop) (push) Blocked by required conditions
Deploy Landing Page / deploy (push) Blocked by required conditions
Deploy Landing Page / build (push) Waiting to run
Release & Packaging Pipeline / Build & Publish Admin Docker Image (push) Failing after 8s
Release & Code Signing CA Pipeline / build-and-sign-windows (push) Failing after 1m51s
Build macOS / Build & Package (macOS) (push) Failing after 4s
Build macOS / Build & Package (macOS)-1 (push) Failing after 5s
Release & Code Signing CA Pipeline / build-and-sign-macos (push) Failing after 3s
Release & Packaging Pipeline / Package macOS Desktop App (push) Failing after 4s
Release & Packaging Pipeline / Package Windows Desktop App (push) Failing after 2m28s
Release & Packaging Pipeline / Publish Official GitHub Release (push) Has been skipped
feat: complete release preparation, 10+ ad mediation, CI/CD, and docker deployment
2026-08-20 11:12:05 +09:00

55 lines
1.7 KiB
JavaScript

// scripts/ci/generate-checksums.mjs
// Computes SHA-256 hashes for all binaries in a release directory
import { createReadStream } from 'node:fs';
import { readdir, writeFile, stat } from 'node:fs/promises';
import { createHash } from 'node:crypto';
import { join, resolve } from 'node:path';
async function sha256File(filePath) {
return new Promise((resolveHash, reject) => {
const hash = createHash('sha256');
const stream = createReadStream(filePath);
stream.on('data', (chunk) => hash.update(chunk));
stream.on('end', () => resolveHash(hash.digest('hex')));
stream.on('error', reject);
});
}
async function main() {
const targetDir = resolve(process.argv[2] || './apps/desktop/release');
console.log(`Scanning release assets in: ${targetDir}`);
const lines = [];
async function scan(dir) {
const entries = await readdir(dir, { withFileTypes: true });
for (const entry of entries) {
const fullPath = join(dir, entry.name);
if (entry.isDirectory()) {
await scan(fullPath);
} else if (/\.(exe|dmg|zip|blockmap|yml)$/i.test(entry.name) && !entry.name.includes('SHA256SUMS')) {
const hash = await sha256File(fullPath);
const relName = entry.name;
lines.push(`${hash} ${relName}`);
console.log(`${relName}: ${hash}`);
}
}
}
try {
await scan(targetDir);
if (lines.length > 0) {
const outPath = join(targetDir, 'SHA256SUMS.txt');
await writeFile(outPath, lines.join('\n') + '\n', 'utf8');
console.log(`\nChecksums written to: ${outPath}`);
} else {
console.log('No matching release binaries found.');
}
} catch (err) {
console.error('Error calculating checksums:', err.message);
process.exit(1);
}
}
main();