-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathpack.mjs
119 lines (100 loc) · 3.34 KB
/
pack.mjs
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
import exec from "node:child_process";
import fs from "node:fs";
import util from "node:util";
const client_version = JSON.parse(
fs.readFileSync("./client-vue/package.json")
).version;
const server_version = JSON.parse(
fs.readFileSync("./server/package.json")
).version;
const dumper_version = JSON.parse(
fs.readFileSync("./twitch-chat-dumper/package.json")
).version;
const vodchat_version = JSON.parse(
fs.readFileSync("./twitch-vod-chat/package.json")
).version;
const pexec = util.promisify(exec.exec);
console.log(`Client version: ${client_version}`);
console.log(`Server version: ${server_version}`);
console.log(`twitch-chat-dumper version: ${dumper_version}`);
console.log(`twitch-vod-chat version: ${vodchat_version}`);
const prerelease = process.argv.includes("--prerelease");
// simple iso date string without time
const date_string = new Date().toISOString().split("T")[0];
const release_name = `LiveStreamDVR-${date_string}-c${client_version}-s${server_version}-d${dumper_version}-v${vodchat_version}${
prerelease ? "-alpha" : ""
}`;
if (fs.existsSync(`./release/${release_name}.zip`)) {
fs.unlinkSync(`./release/${release_name}.zip`);
}
console.log(`Release name: ${release_name}`);
console.log("Building...");
// build twitch-vod-chat
await pexec("cd twitch-vod-chat && yarn install && yarn run buildlib");
console.log("twitch-vod-chat built");
// build client
await pexec("cd client-vue && yarn install && yarn run build");
console.log("Client built");
// build server
await pexec("cd server && yarn install && yarn run build");
console.log("Server built");
// build twitch-chat-dumper
await pexec("cd twitch-chat-dumper && yarn install && yarn run build");
console.log("twitch-chat-dumper built");
// package files
await pexec(
`7za a -tzip -xr!node_modules ./release/${release_name}.zip ` +
`client-vue/dist ` +
`client-vue/package.json ` +
`server/build ` +
`server/package.json ` +
`server/tsconfig.json ` +
`twitch-chat-dumper/build ` +
// `twitch-vod-chat/dist ` +
`start.bat ` +
`start.sh ` +
`requirements.txt ` +
`binaries.txt ` +
`Pipfile ` +
`Pipfile.lock ` +
`README.md ` +
`LICENSE `
);
console.log("Files packaged");
// output metadata
fs.writeFileSync(
`./release/${release_name}.json`,
JSON.stringify({
client_version,
server_version,
dumper_version,
vodchat_version,
release_name,
})
);
fs.writeFileSync(`./release_name.txt`, release_name);
fs.writeFileSync(
`./release_notes.md`,
`This release was created automatically by the build script.\n\n` +
`It includes the following versions:\n\n` +
`* Client: ${client_version}\n` +
`* Server: ${server_version}\n` +
`* twitch-chat-dumper: ${dumper_version}\n` +
`* twitch-vod-chat: ${vodchat_version}\n\n` +
`## Changelog\n\n` +
`TODO: make better commit messages so this can be generated automatically\n\n`
);
console.log("Metadata written");
// upload to github
await pexec(
`gh release create ${release_name} ` +
`./release/${release_name}.zip ` +
`-t "${release_name}" ` + // title
// `-n "${release_name}" ` + // description
// `--generate-notes ` + // TODO: generate release notes automatically
`--notes-file ./release_notes.md ` +
(prerelease ? "--prerelease " : "") +
`-R "mrbrax/LiveStreamDVR" ` +
`--draft`
);
console.log("Release created");