waveterm/buildres/deprecated/update-latest-mac.js
Evan Simkowitz 33fc3518c0
Sign and notarize directly in build-helper (#389)
* Sign and notarize in CI

* add dmg

* remove flag

* fix env var

* add team id

* conditionally set apple specific env vars

* publish to a staging location

* upload unzipped

* add script to publish to staging, update publish url

* turn off autodiscovery again

* update scripts

* deprecate old method

* move stuff

* remove autodiscovery
2024-03-06 16:07:48 -08:00

41 lines
1.3 KiB
JavaScript

// Updates the latest-mac.yml file with the signed and notarized version of the latest installer
// Usage: node update-latest.js <path-to-installer>
const path = require("path");
const fs = require("fs");
const { hashFile } = require("./generate-hash");
const yaml = require("yaml");
/**
* Updates the latest-mac.yml file with the signed and notarized version of the latest installer
* @param {string} installerPath - Path to the installer
* @param {string} ymlPath - Path to the latest-mac.yml file
* @returns {Promise<void>}
*/
async function updateLatestMac(installerPath, ymlPath) {
const hash = (await hashFile(installerPath)).trim();
const size = fs.statSync(installerPath).size;
const yml = yaml.parse(fs.readFileSync(ymlPath, "utf8"));
for (const file of yml.files) {
if (file.url === path.basename(installerPath)) {
file.sha512 = hash;
file.size = size;
}
}
yml.sha512 = hash;
fs.writeFileSync(ymlPath, yaml.stringify(yml));
}
if (require.main === module) {
const installerPath = path.resolve(process.cwd(), process.argv[2]);
const ymlPath = path.resolve(process.cwd(), process.argv[3]);
(async () => {
await updateLatestMac(installerPath, ymlPath);
console.log("latest-mac.yml updated");
})();
}
module.exports = {
updateLatestMac,
};