mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2024-11-16 19:56:50 +08:00
48 lines
1.3 KiB
JavaScript
48 lines
1.3 KiB
JavaScript
import fs from "fs-extra";
|
|
import { createRequire } from "module";
|
|
import { execSync } from "child_process";
|
|
|
|
const require = createRequire(import.meta.url);
|
|
|
|
async function resolvePublish() {
|
|
const flag = process.argv[2] ?? "patch";
|
|
const packageJson = require("../package.json");
|
|
const tauriJson = require("../src-tauri/tauri.conf.json");
|
|
|
|
let [a, b, c] = packageJson.version.split(".").map(Number);
|
|
|
|
if (flag === "major") {
|
|
a += 1;
|
|
b = 0;
|
|
c = 0;
|
|
} else if (flag === "minor") {
|
|
b += 1;
|
|
c = 0;
|
|
} else if (flag === "patch") {
|
|
c += 1;
|
|
} else throw new Error(`invalid flag "${flag}"`);
|
|
|
|
const nextVersion = `${a}.${b}.${c}`;
|
|
packageJson.version = nextVersion;
|
|
tauriJson.package.version = nextVersion;
|
|
|
|
await fs.writeFile(
|
|
"./package.json",
|
|
JSON.stringify(packageJson, undefined, 2)
|
|
);
|
|
await fs.writeFile(
|
|
"./src-tauri/tauri.conf.json",
|
|
JSON.stringify(tauriJson, undefined, 2)
|
|
);
|
|
|
|
execSync("git add ./package.json");
|
|
execSync("git add ./src-tauri/tauri.conf.json");
|
|
execSync(`git commit -m "v${nextVersion}"`);
|
|
execSync(`git tag -a v${nextVersion} -m "v${nextVersion}"`);
|
|
execSync(`git push`);
|
|
execSync(`git push origin v${nextVersion}`);
|
|
console.log(`Publish Successfully...`);
|
|
}
|
|
|
|
resolvePublish();
|