-
Notifications
You must be signed in to change notification settings - Fork 143
/
release.js
49 lines (40 loc) · 1.74 KB
/
release.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
"use strict";
var fs = require("fs");
var { execSync } = require("child_process");
let version = JSON.parse(fs.readFileSync("plugin/manifest.json", "utf-8")).version;
let isDraft = process.argv.includes("draft");
let isPrerelease = process.argv.includes("pre");
let commitHash = execSync("git rev-parse --short HEAD").toString().trim();
let commitLongHash = execSync("git rev-parse HEAD").toString().trim();
let nameVersion = isPrerelease ? `${version}.pre-${commitHash}` : version;
let branch = execSync("git rev-parse --abbrev-ref HEAD");
let masterCommitHash = execSync("git rev-parse origin/master").toString().trim();
if (!isPrerelease) {
if (branch != "master") {
throw new Error("Can not make a full release: not on master branch");
}
if (commitLongHash != masterCommitHash) {
throw new Error("Can not make a full release: master is not pushed to remote");
}
}
execSync("npm run lint");
let chromeName = `./eslint/WebToEpub${version}.zip`;
let firefoxName = `./eslint/WebToEpub${version}.xpi`;
let chromeCopyName = `./eslint/WebToEpub.chrome.${nameVersion}.zip`
let firefoxCopyName = `./eslint/WebToEpub.firefox.${nameVersion}.zip`;
fs.copyFileSync(chromeName, chromeCopyName);
// make firefox version a zip for user to unzip, because unsigned xpis can't be installed
fs.copyFileSync(firefoxName, firefoxCopyName);
let command = `
gh release create
${version}${isPrerelease ? ".pre-" + commitHash : ""}
--title ${version}${isPrerelease ? ".pre-" + commitHash : ""}
${chromeCopyName}
${firefoxCopyName}
--target ${isPrerelease ? commitLongHash : "master"}
--notes ""
${isPrerelease ? "--prerelease" : ""}
${isDraft ? "--draft" : ""}
`.replace(/\n\t?/g, " ").trim();
console.log(command)
execSync(command, {stdio: "inherit"});