Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump - add support for bumponly flag #20

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions bin/mcfly-semantic-release.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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!`));
Expand Down
10 changes: 6 additions & 4 deletions lib/gitHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down