in src/release.ts [96:127]
async function verifyZipballChecksum(
zipballPath: string,
artifactName: string,
checksumPath: string
) {
const zipballChecksum = await sha256File(zipballPath);
core.debug(
`calculated sha256 checksum of ${artifactName}: ${zipballChecksum}`
);
// format:
// {checksum} {filename}
const checksumLines = fs
.readFileSync(checksumPath, 'utf8')
.toString()
.split('\n')
.map((l) => l.split(/\s+/));
const expectedChecksum = checksumLines.find(
(l) => l[1].trim() === artifactName
);
if (!expectedChecksum) {
throw new Error(
`No checksum found for ${artifactName} from ${checksumPath}`
);
}
if (expectedChecksum[0] !== zipballChecksum) {
throw new Error(
`Checksum mismatch: expected ${expectedChecksum[0]}, got ${zipballChecksum}`
);
}
}