Add SHA hashes of packages to the release note directly
This commit is contained in:
parent
35a664a56d
commit
1ba0b8d182
7 changed files with 4541 additions and 4677 deletions
|
@ -43,9 +43,6 @@ export default async function main(argv) {
|
|||
`<tr><td align="center"><h1>` +
|
||||
`<a href="${baseUrl}/PACKAGE-LIST.md">View package list</a>` +
|
||||
`</h1></td></tr>` +
|
||||
`<tr><td align="center">` +
|
||||
`<a href="${baseUrl}/packages-sha.txt">Package hashes (SHA-256)</a>` +
|
||||
`</td></tr>` +
|
||||
`</table>`,
|
||||
);
|
||||
await fs.promises.writeFile(argv.outputPath, out.data);
|
||||
|
|
|
@ -1,36 +0,0 @@
|
|||
"use strict";
|
||||
|
||||
import crypto from "crypto";
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
|
||||
export default async function (out, archiveFiles) {
|
||||
const filesToAnalyze = Array.from(new Set(archiveFiles.map(f => f.full))).sort();
|
||||
|
||||
let s = "";
|
||||
for (const filePath of filesToAnalyze) {
|
||||
s += `${await hashFile(filePath)}\t${path.basename(filePath)}\n`;
|
||||
}
|
||||
|
||||
await fs.promises.writeFile(out, s);
|
||||
}
|
||||
|
||||
function hashFile(filePath) {
|
||||
return new Promise((resolve, reject) => {
|
||||
let sum = crypto.createHash("sha256");
|
||||
let fileStream = fs.createReadStream(filePath);
|
||||
fileStream.on("error", err => {
|
||||
return reject(err);
|
||||
});
|
||||
fileStream.on("data", chunk => {
|
||||
try {
|
||||
sum.update(chunk);
|
||||
} catch (ex) {
|
||||
return reject(ex);
|
||||
}
|
||||
});
|
||||
fileStream.on("end", () => {
|
||||
return resolve(sum.digest("hex"));
|
||||
});
|
||||
});
|
||||
}
|
56
tools/misc/src/update-release-sha-file.mjs
Normal file
56
tools/misc/src/update-release-sha-file.mjs
Normal file
|
@ -0,0 +1,56 @@
|
|||
"use strict";
|
||||
|
||||
import crypto from "crypto";
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
|
||||
import { glob } from "glob";
|
||||
|
||||
setTimeout(
|
||||
() =>
|
||||
main().catch(e => {
|
||||
console.error(e);
|
||||
process.exit(1);
|
||||
}),
|
||||
0,
|
||||
);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
async function main() {
|
||||
const outMd = await glob("release-archives/*.md");
|
||||
if (outMd.length != 1) throw new Error("Expected exactly one .md file in release-archives");
|
||||
|
||||
const o = fs.createWriteStream(outMd[0], { flags: "a" });
|
||||
|
||||
o.write("\n\n## SHA256 checksums\n\n");
|
||||
o.write("<details>\n\n");
|
||||
const zipFilesToArchive = (await glob("release-archives/*.zip")).sort();
|
||||
for (const filePath of zipFilesToArchive) {
|
||||
console.log(`Checking ${filePath}...`);
|
||||
o.write(`* \`${await hashFile(filePath)}\` ${path.basename(filePath)}\n`);
|
||||
}
|
||||
o.write("</details>\n\n");
|
||||
|
||||
o.end();
|
||||
}
|
||||
|
||||
function hashFile(filePath) {
|
||||
return new Promise((resolve, reject) => {
|
||||
let sum = crypto.createHash("sha256");
|
||||
let fileStream = fs.createReadStream(filePath);
|
||||
fileStream.on("error", err => {
|
||||
return reject(err);
|
||||
});
|
||||
fileStream.on("data", chunk => {
|
||||
try {
|
||||
sum.update(chunk);
|
||||
} catch (ex) {
|
||||
return reject(ex);
|
||||
}
|
||||
});
|
||||
fileStream.on("end", () => {
|
||||
return resolve(sum.digest("hex"));
|
||||
});
|
||||
});
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue