-
Notifications
You must be signed in to change notification settings - Fork 109
/
.bump.js
56 lines (43 loc) · 1.34 KB
/
.bump.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
'use strict';
var path = require('path'),
fs = require('fs'),
semver = require('semver'),
exec = require('child_process').execSync,
args = require('yargs').argv;
var pkg = require('./package.json'),
ruby = fs.readFileSync('./lib/singularitygs.rb').toString();
var rubyString,
date = new Date().toISOString();
var version = pkg.version;
if (exec('git status --porcelain').toString() !== '') {
console.error('Working dirty. Please commit before trying again');
process.exit(1);
}
version = {
major: semver.major(version),
minor: semver.minor(version),
patch: semver.patch(version)
};
if (args.major) {
version = `${version.major + 1}.0.0`;
}
else if (args.minor) {
version = `${version.major}.${version.minor + 1}.0`;
}
else if (args.patch) {
version = `${version.major}.${version.minor}.${version.patch + 1}`;
}
else {
version = `${version.major}.${version.minor}.${version.patch}`;
}
date = date.substring(0, date.indexOf('T'));
rubyString = `module SingularityGS
VERSION = "${version}"
DATE = "${date}"
end`;
ruby = ruby.substring(0, ruby.indexOf('module SingularityGS')) + rubyString;
pkg.version = version;
fs.writeFileSync('./lib/singularitygs.rb', ruby + '\n');
fs.writeFileSync('./package.json', JSON.stringify(pkg, null, 2) + '\n');
exec(`git commit -am "Release v${version}"`);
exec(`git tag v${version}`);