diff --git a/bin/mcfly-semantic-release.js b/bin/mcfly-semantic-release.js index 47151b7..95de631 100755 --- a/bin/mcfly-semantic-release.js +++ b/bin/mcfly-semantic-release.js @@ -17,6 +17,7 @@ const args = require('yargs') .option('files', { type: 'array', desc: 'Files and files patterns to change' }) .option('production', { type: 'boolean', desc: 'Generate production commit message' }) .option('hotfix', { type: 'boolean', desc: 'Generate a hotfix release' }) + .option('bumponly', {type: 'boolean', desc: 'Bump package versions and commit without creating a release or pushing to github'}) .argv; var files; @@ -102,21 +103,23 @@ fileHelper.getFiles(args.files) }) .then((msg) => { console.log(chalk.yellow('Committing version...')); - return gitHelper.commitVersion(msg.nextVersion, args.production, files, args.hotfix) + return gitHelper.commitVersion(msg.nextVersion, args.production, files, args.hotfix, args.bumponly) .then(() => msg); }) .delay(1000) .then((msg) => { - console.log(chalk.yellow('Publishing version...')); - return retryHelper - .retry(function () { - return githubHelper.createRelease(msg); - }) - .catch(err => { - console.log(chalk.red('An error occurred when publishing the version')); - console.log('Your changelog is:\n', msg.changelogContent); - throw err; - }); + if (!args.bumponly) { + console.log(chalk.yellow('Publishing version...')); + return retryHelper + .retry(function () { + return githubHelper.createRelease(msg); + }) + .catch(err => { + console.log(chalk.red('An error occurred when publishing the version')); + console.log('Your changelog is:\n', msg.changelogContent); + throw err; + }); + } }) .then((res) => { console.log(chalk.green(`Release ${res.name} successfully published!`)); diff --git a/lib/gitHelper.js b/lib/gitHelper.js index ad4545a..7ac92c3 100644 --- a/lib/gitHelper.js +++ b/lib/gitHelper.js @@ -13,15 +13,17 @@ const getCurrentBranch = async function () { return branches.current; }; -const commitVersion = async function (version, production, files, hotfix = false) { +const commitVersion = async function (version, production, files, hotfix = false, bumponly = false) { const commitMessage = `chore(app): Version ${version} ${production ? ' production' : ''} `; try { const currentBranch = hotfix ? await getCurrentBranch() : 'master'; await git.add(files); await git.commit(commitMessage); - await git.addAnnotatedTag(version, 'v' + version); - await git.push('origin', currentBranch); - await git.pushTags('origin'); + if (!bumponly) { + await git.addAnnotatedTag(version, 'v' + version); + await git.push('origin', currentBranch); + await git.pushTags('origin'); + } } catch (e) { throw new Error(e); }