Skip to content

Commit

Permalink
Separate tasks and add comments/logs
Browse files Browse the repository at this point in the history
  • Loading branch information
eKoopmans committed Nov 25, 2017
1 parent 3a00a19 commit 5642aee
Showing 1 changed file with 33 additions and 15 deletions.
48 changes: 33 additions & 15 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,37 +27,55 @@ function getVersion() {
// Merge the specified branch back into master and develop.
function mergeBranch(branch) {
var mergeCmd = 'git merge --no-ff --no-edit ' + branch;

console.log('Merging release into master.')
return exec('git checkout master && ' + mergeCmd).then(function() {
console.log('Merging release into develop.')
return exec('git checkout develop && ' + mergeCmd);
});
}

/* ----- TASKS ----- */

// Bump version using NPM (only affects package*.json, doesn't commit).
gulp.task('bump-version', function() {
console.log('Bumping version number.');
return exec('npm --no-git-tag-version version ' + args.newversion);
});

// Stage a release (bump version and create a 'release/[version]' branch).
gulp.task('stage-release', function() {
var cmd = 'npm --no-git-tag-version version ' + args.newversion;
return exec(cmd).then(function() {
var version = getVersion();
var branch = 'release/' + version;
gulp.task('stage-release', ['bump-version'], function() {
var version = getVersion();
var branch = 'release/' + version;
var cmd = 'git checkout -b ' + branch + ' && git add -A';
cmd += ' && git commit -m "Prepare release ' + version + '"';

var cmd = 'git checkout -b ' + branch + ' && git add -A';
cmd += ' && git commit -m "Prepare release ' + version + '"';
return exec(cmd);
});
console.log('Creating release branch and committing changes.');
return exec(cmd);
});

// Tag and merge the latest release into master/develop.
gulp.task('release', function() {
gulp.task('finalize-release', function() {
var version = getVersion();
var branch = 'release/' + version;

var cmd = 'git checkout ' + branch + ' && npm run build';
cmd += ' && git add -A && git commit -m "Build ' + version + '"';
cmd += ' && git tag -a ' + version + ' -m "' + version + ' ' + args.tagmessage + '"';

console.log('Running build process in release branch.');
return exec(cmd).then(function() {
return mergeBranch(branch);
console.log('Adding all changes and performing final commit.');
return exec('git add -A && git commit --allow-empty -m "Build ' + version + '"');
}).then(function() {
console.log('Tagging with provided tag message.');
return exec('git tag -a ' + version + ' -m "' + version + ' ' + args.tagmessage + '"');
});
});

// Tag and merge the latest release into master/develop.
gulp.task('release', ['finalize-release'], function() {
var version = getVersion();
var branch = 'release/' + version;

return mergeBranch(branch).then(function() {
console.log('Deleting release branch.');
return exec('git branch -d ' + branch);
});
});

0 comments on commit 5642aee

Please sign in to comment.