diff --git a/build/changelog.js b/build/changelog.js new file mode 100644 index 0000000..ff1836c --- /dev/null +++ b/build/changelog.js @@ -0,0 +1,35 @@ +var gulp = require('gulp'), + util = require('gulp-util'), + cat = require('gulp-cat'), + git = require('gulp-git'), + replace = require('gulp-replace'), + path = require('path'); + +var repo = require('../package.json').repository.url; + +gulp.task('changelog', function(done) { + git.exec({ args: 'log --oneline --decorate' }, function(err, stdout) { + if(err) return done(err); + return done(null, gulp.src('CHANGELOG.md') + .pipe(replace(/.|\n/g, '')) + .pipe(replace(/$/, stdout)) + .pipe(replace(/#(\d+)/, '[#$1](' + repo + '/issues/$1)')) + .pipe(replace(/([a-f0-9]{7}) \(HEAD[^)]*\) (.+)/g, function(_, sha, comment) { + return '\n## [Working Changes](' + repo + ')' + + '\n- [' + sha + '](' + repo + '/commit/' + sha + ') ' + comment; + })) + .pipe(replace(/([a-f0-9]{7}) \(tag: ([^\s),]*)[^)]*\) (.+)/g, function(_, sha, tag, comment) { + var niceTag = tag; + if(tag.indexOf('v') !== 0) niceTag = 'v' + tag; + return '\n## [' + niceTag + '](' + repo + '/tree/' + tag + ')' + + '\n- [' + sha + '](' + repo + '/commit/' + sha + ') ' + comment; + })) + .pipe(replace(/([a-f0-9]{7}) (.+)/g, '- [$1](' + repo + '/commit/$1) $2')) + .pipe(gulp.dest('.'))); + }); +}); + +gulp.task('changelog-commit', function () { + return gulp.src('.') + .pipe(git.commit('Updated CHANGELOG')); +}); \ No newline at end of file diff --git a/build/version.js b/build/version.js index 5857283..96f24bf 100644 --- a/build/version.js +++ b/build/version.js @@ -36,20 +36,22 @@ gulp.task('version-push', function (cb) { gulp.task('version-tag', function (cb) { var version = getPackageJsonVersion(); - git.tag('v' + version, 'Version ' + version, function (error) { - if (error) { - return cb(error); - } - git.push('origin', 'master', { args: '--tags' }, cb); - }); + git.tag('v' + version, 'Version ' + version, cb); +}); + +gulp.task('version-push-tags', function (cb) { + git.push('origin', 'master', { args: '--tags' }, cb); }); gulp.task('version', function (callback) { runSequence( 'version-bump', 'version-commit', - 'version-push', 'version-tag', + 'changelog', + 'changelog-commit', + 'version-push', + 'version-push-tags', function (error) { if (error) { console.log(error.message);