Skip to content

Commit a6c084f

Browse files
Merge pull request #341 from preactjs/release-automation
2 parents d31f593 + df86844 commit a6c084f

File tree

5 files changed

+71
-4
lines changed

5 files changed

+71
-4
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "preact-devtools",
3-
"version": "1.4.4",
3+
"version": "4.0.0",
44
"description": "Preact Devtools Extension",
55
"main": "dist/preact-devtools.js",
66
"module": "dist/preact-devtools.module.js",

src/shells/chrome/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"manifest_version": 2,
33
"name": "Preact Developer Tools",
44
"description": "Adds debugging tools for Preact to Chrome",
5-
"version": "4",
5+
"version": "4.0.0",
66
"devtools_page": "panel/empty-panel.html",
77
"content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'",
88
"permissions": ["file:///*", "http://*/*", "https://*/*", "storage"],

src/shells/edge/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"manifest_version": 2,
33
"name": "Preact Developer Tools",
44
"description": "Adds debugging tools for Preact to Microsoft Edge",
5-
"version": "1.4.4",
5+
"version": "4.0.0",
66
"devtools_page": "panel/empty-panel.html",
77
"content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'",
88
"permissions": ["file:///*", "http://*/*", "https://*/*", "storage"],

src/shells/firefox/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"manifest_version": 2,
33
"name": "Preact Developer Tools",
44
"description": "Adds debugging tools for Preact to Firefox",
5-
"version": "1.4.4",
5+
"version": "4.0.0",
66
"devtools_page": "panel/empty-panel.html",
77
"content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'",
88
"permissions": ["file:///*", "http://*/*", "https://*/*", "storage"],

tools/release.js

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
const assert = require("assert");
2+
const fs = require("fs");
3+
const path = require("path");
4+
const child_process = require("child_process");
5+
6+
let version = "";
7+
function updateVersion(json, kind) {
8+
let [, major, minor, patch, rest] = json.version.match(
9+
/^(\d+)\.(\d+)\.(\d+)(.*)$/,
10+
);
11+
12+
switch (kind) {
13+
case "major":
14+
major = Number(major) + 1;
15+
break;
16+
case "minor":
17+
minor = Number(minor) + 1;
18+
break;
19+
case "patch":
20+
patch = Number(patch) + 1;
21+
break;
22+
}
23+
24+
json.version = `${major}.${minor}.${patch}${rest}`;
25+
version = json.version;
26+
}
27+
28+
function format(file) {
29+
child_process.execSync(`./node_modules/.bin/prettier --write ${file}`);
30+
}
31+
32+
const shellPath = path.join(__dirname, "..", "src", "shells");
33+
function updateManifest(name, kind) {
34+
assert(/edge|chrome|firefox/.test(name), "Unknown browser");
35+
36+
const file = path.join(shellPath, name, "manifest.json");
37+
const json = JSON.parse(fs.readFileSync(file, "utf-8"));
38+
updateVersion(json, kind);
39+
40+
fs.writeFileSync(file, JSON.stringify(json, null, "\t"), "utf-8");
41+
format(file);
42+
}
43+
44+
function updatePkgJson(kind) {
45+
const file = path.join(__dirname, "..", "package.json");
46+
const json = JSON.parse(fs.readFileSync(file, "utf-8"));
47+
updateVersion(json, kind);
48+
49+
fs.writeFileSync(file, JSON.stringify(json, null, "\t"), "utf-8");
50+
format(file);
51+
}
52+
53+
const [kind] = process.argv.slice(2);
54+
55+
assert(/major|minor|patch/.test(kind), "Unknown version increase");
56+
57+
const r = child_process.execSync("git status --porcelain");
58+
assert(r.toString() === "", `Working directory is dirty^`);
59+
60+
updateManifest("edge", kind);
61+
updateManifest("chrome", kind);
62+
updateManifest("firefox", kind);
63+
updatePkgJson(kind);
64+
65+
child_process.execSync(`git add package.json src/`);
66+
child_process.execSync(`git commit -m "Release ${version}"`);
67+
child_process.execSync(`git tag "v${version}"`);

0 commit comments

Comments
 (0)