Skip to content

Commit

Permalink
feat: Add release tasks to gulp
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikGartner committed Dec 26, 2015
1 parent 05563a8 commit 027968c
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ const browserify = require('browserify');
const runSequence = require('run-sequence');
const source = require('vinyl-source-stream');
const rollup = require( 'rollup' );
const argv = require('minimist')(process.argv.slice(2));
const fs = require('fs');

// Gather the library data from `package.json`
const manifest = require('./package.json');
Expand Down Expand Up @@ -181,5 +183,55 @@ gulp.task('test-browser', ['build-in-sequence'], function() {
return gulp.watch(otherWatchFiles, ['build-in-sequence']);
});

gulp.task('bump', function() {
return gulp.src('./package.json')
.pipe($.bump({key: 'version', type: argv.bump}))
.pipe(gulp.dest('./'));
});

gulp.task('changelog', function () {
return gulp.src('./CHANGELOG.md')
.pipe($.conventionalChangelog({
preset: 'angular',
}))
.pipe(gulp.dest('./'));
});

gulp.task('tag-release', function (cb) {
var version = getPackageJsonVersion();
$.git.tag(version, 'Created Tag for version: ' + version, function (error) {
if (error) {
return cb(error);
}
});
function getPackageJsonVersion () {
// We parse the json file instead of using require because require caches
// multiple calls so the version number won't be updated
return JSON.parse(fs.readFileSync('./package.json', 'utf8')).version;
}
});

gulp.task('commit-changes', function () {
return gulp.src(['./package.json', './CHANGELOG.md'])
.pipe($.git.add())
.pipe($.git.commit('chore: Bump version number'));
});

gulp.task('prepare-release', function (callback) {
runSequence(
'bump',
'changelog',
'commit-changes',
'tag-release',
function (error) {
if (error) {
console.log(error.message);
} else {
console.log('Updated release state!');
}
callback(error);
});
});

// An alias of test
gulp.task('default', ['test']);

0 comments on commit 027968c

Please sign in to comment.