-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathrelease.js
52 lines (39 loc) · 1.5 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
50
51
52
const fs = require('fs')
const MANIFEST_LOCATION = './app/manifest.json';
const manifest = require(MANIFEST_LOCATION);
const oldVersion = manifest.version;
console.log('Releasing "Disable Google Search Text Highlights"!');
console.log(`Old version was ${oldVersion}`);
let [major, minor, patch] = oldVersion.split('.').map(i => parseInt(i));
if (process.argv.includes('--major')) {
console.log('Major release');
major++;
minor = 0;
patch = 0
} else if (process.argv.includes('--patch')) {
console.log('Patch release');
patch++;
} else {
console.log('Minor release');
patch = 0;
minor++;
}
const newVersion = `${major}.${minor}.${patch}`;
console.log(`New version is ${newVersion}`);
console.log('Rewriting manifest file...');
const data = fs.readFileSync(MANIFEST_LOCATION, 'utf8');
const newContents = data.replace(/"version": "\d+.\d+.\d+"/, `"version": "${newVersion}"`);
fs.writeFileSync(MANIFEST_LOCATION, newContents, 'utf8');
console.log('Success!');
console.log('');
console.log('Use the following command to get the list of changes');
console.log(`git log HEAD...${oldVersion} --pretty=format:"%s"`);
console.log('');
console.log('Use the following command to commit the new release:');
console.log(`git add .; git commit -m "v. ${newVersion}"`);
console.log('');
console.log('Use the following command to create a for the release:');
console.log(`git tag ${newVersion} -a`);
console.log('');
console.log('Use the following command to push the changes:');
console.log('git push --follow-tags');