-
Notifications
You must be signed in to change notification settings - Fork 19
/
.versionrc.js
29 lines (24 loc) · 950 Bytes
/
.versionrc.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
const versionFileUpdater = {
MAJOR_REGEX: /versionMajor = (\d+)/,
MINOR_REGEX: /versionMinor = (\d+)/,
PATCH_REGEX: /versionPatch = (\d+)/,
readVersion: function (contents) {
const major = this.MAJOR_REGEX.exec(contents)[1];
const minor = this.MINOR_REGEX.exec(contents)[1];
const patch = this.PATCH_REGEX.exec(contents)[1];
return `${major}.${minor}.${patch}`;
},
writeVersion: function (contents, version) {
const splitted = version.split('.');
const [major, minor, patch] = [splitted[0], splitted[1], splitted[2]];
return contents
.replace(this.MAJOR_REGEX, `versionMajor = ${major}`)
.replace(this.MINOR_REGEX, `versionMinor = ${minor}`)
.replace(this.PATCH_REGEX, `versionPatch = ${patch}`);
}
}
module.exports = {
bumpFiles: [
{ filename: './pkg/version/version.go', updater: versionFileUpdater },
],
}