-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathpublish.js
58 lines (52 loc) · 1.62 KB
/
publish.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import { execSync } from "child_process";
import { readFileSync, writeFileSync } from "fs";
// receive version arg
process.stdin.setEncoding("utf8");
console.log("Input new version:");
process.stdin.on("data", function (data) {
var version = data.trim();
if (!version) {
console.log("version is required");
console.log("Input new version:");
return;
}
process.stdin.pause();
console.log("publishing version: " + version);
console.log("update tauri.conf.json version");
const tauri_path = "./src-tauri/tauri.conf.json";
const tauri_lines = readFileSync(tauri_path, "utf8").split(
"\n"
);
for (let i = 0; i < tauri_lines.length; i++) {
if (tauri_lines[i].includes("version")) {
tauri_lines[i] = ` "version": "${version}",`;
break;
}
}
writeFileSync(tauri_path, tauri_lines.join("\n"));
console.log("update package.json version");
console.log(
execSync("pnpm version --no-git-tag-version " + version).toString()
);
console.log("update cargo.toml version\n");
const cargo_path = "./src-tauri/Cargo.toml";
const cargo_lines = readFileSync(cargo_path, "utf8").split(
"\n"
);
for (let i = 0; i < cargo_lines.length; i++) {
if (cargo_lines[i].startsWith("version")) {
cargo_lines[i] = `version = "${version}"`;
break;
}
}
writeFileSync(cargo_path, cargo_lines.join("\n"));
console.log("git commit and tag");
console.log(
execSync(
`git add . && git commit -m "Scrcpy Mask v${version}" && git tag v${version}`
).toString()
);
console.log(
"Pleash push commit and tag to github manually:\ngit push && git push --tags"
);
});