Skip to content

Commit cdeb4f4

Browse files
authored
feat: versioning automatically (#2883)
* feat: versioning automatically * chore: remove redundant log
1 parent feadbd8 commit cdeb4f4

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@
8484
"promise-retry": "^1.1.1",
8585
"requireg": "^0.2.2",
8686
"resq": "^1.10.0",
87-
"semver": "^6.2.0",
8887
"sprintf-js": "^1.1.1"
8988
},
9089
"devDependencies": {
@@ -127,6 +126,7 @@
127126
"qrcode-terminal": "^0.12.0",
128127
"rosie": "^1.6.0",
129128
"runok": "^0.9.2",
129+
"semver": "^6.3.0",
130130
"sinon": "^9.2.2",
131131
"sinon-chai": "^3.5.0",
132132
"testcafe": "^1.9.4",

runok.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,26 @@ title: ${name}
390390
console.log('-- RELEASED --');
391391
},
392392

393+
async versioning() {
394+
const semver = require('semver');
395+
396+
if (fs.existsSync('./package.json')) {
397+
const packageFile = require('./package.json');
398+
const currentVersion = packageFile.version;
399+
let type = process.argv[3];
400+
if (!['major', 'minor', 'patch'].includes(type)) {
401+
type = 'patch';
402+
}
403+
404+
const newVersion = semver.inc(packageFile.version, type);
405+
packageFile.version = newVersion;
406+
fs.writeFileSync('./package.json', JSON.stringify(packageFile, null, 2));
407+
console.log('Version updated', currentVersion, '=>', newVersion);
408+
409+
console.log('Creating and switching to release branch...');
410+
await exec(`git checkout -b release-${newVersion}`);
411+
}
412+
},
393413
};
394414

395415
async function processChangelog() {

0 commit comments

Comments
 (0)