Skip to content
This repository has been archived by the owner on Mar 11, 2023. It is now read-only.

Commit

Permalink
[Project] Gen checksum
Browse files Browse the repository at this point in the history
  • Loading branch information
UnsignedInt8 committed Jul 21, 2021
1 parent fa40797 commit 0579ef6
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions scripts/checksum.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env node

const fs = require('fs');
const yaml = require('yaml');
const { version } = require('../package.json');
const { execSync } = require('child_process');
const path = require('path');

const oss = ['mac', 'win'];
const arches = ['x64', 'arm64'];
const exts = ['exe', 'dmg'];

const latest = {
version,
files: [],
releaseDate: new Date().toISOString(),
};

for (let os of oss) {
for (let arch of arches) {
for (let ext of exts) {
const artifactName = `wallet3-${os}-${arch}-${version}.${ext}`;

const pkg = path.join(__dirname, '..', 'dist', artifactName);

let size = 0;
try {
size = fs.statSync(pkg).size;
} catch (error) {
continue;
}

const checksum = execSync(`shasum -a 512 ${pkg}`).toString('utf-8').split(' ')[0];

latest.files.push({ url: artifactName, sha512: checksum, size });
}
}
}

const result = yaml.stringify(latest);
console.log(result);
fs.writeFileSync(path.join(__dirname, '..', 'dist', 'latest.yml'), result);

0 comments on commit 0579ef6

Please sign in to comment.