purescript-csv-stream/bun/prepare.js

35 lines
1.1 KiB
JavaScript
Raw Normal View History

import { readFile, writeFile } from "fs/promises";
import { execSync } from "child_process";
2024-04-30 19:09:12 +00:00
let ver = process.argv[2];
2024-04-30 19:09:12 +00:00
if (!ver) {
console.error(`tag required: bun bun/prepare.js v1.0.0`);
process.exit(1);
2024-04-30 19:09:12 +00:00
} else if (!/v\d+\.\d+\.\d+/.test(ver)) {
console.error(`invalid tag: ${ver}`);
process.exit(1);
2024-04-30 19:09:12 +00:00
}
ver = (/\d+\.\d+\.\d+/.exec(ver) || [])[0] || "";
2024-04-30 19:09:12 +00:00
const pkg = await readFile("./package.json", "utf8");
const pkgnew = pkg.replace(/"version": ".+"/, `"version": "v${ver}"`);
await writeFile("./package.json", pkgnew);
2024-04-30 19:09:12 +00:00
const spago = await readFile("./spago.yaml", "utf8");
const spagonew = spago.replace(/version: .+/, `version: '${ver}'`);
await writeFile("./spago.yaml", spagonew);
2024-04-30 19:09:12 +00:00
const readme = await readFile("./README.md", "utf8");
2024-04-30 19:09:12 +00:00
const readmenew = readme.replace(
2024-04-30 19:10:49 +00:00
/packages\/purescript-csv-stream\/.+?\//g,
`/packages/purescript-csv-stream/${ver}/`,
);
await writeFile("./README.md", readmenew);
2024-04-30 19:09:12 +00:00
execSync(`git add spago.yaml package.json README.md`);
execSync(`git commit -m 'chore: prepare v${ver}'`);
execSync(`git tag v${ver}`);
execSync(`git push --tags`);
execSync(`git push --mirror github-mirror`);