22 lines
694 B
TypeScript
22 lines
694 B
TypeScript
import * as core from "@actions/core";
|
|
import * as crypto from "crypto";
|
|
import * as fs from "fs";
|
|
|
|
export function verifyChecksum(downloadPath: string) {
|
|
const fileBuffer: Buffer = fs.readFileSync(downloadPath);
|
|
const checksum: string = crypto
|
|
.createHash("sha256")
|
|
.update(fileBuffer)
|
|
.digest("hex"); // checksum of downloaded file
|
|
|
|
const expectedChecksum: string =
|
|
"7027c15a988395f3dde5e77d9a58889669adbda52fbd527ae8216e6d81dd8b1a"; // checksum for v0.11.0
|
|
|
|
if (checksum !== expectedChecksum) {
|
|
core.setFailed(
|
|
`Checksum verification failed, expected ${expectedChecksum} instead got ${checksum}`
|
|
);
|
|
}
|
|
|
|
core.debug("Checksum verification passed.");
|
|
}
|