-
Notifications
You must be signed in to change notification settings - Fork 100
/
gulpfile.js
38 lines (33 loc) · 945 Bytes
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
var spawn = require('child_process').spawn;
var git = require('gulp-git');
var gulp = require('gulp');
/**
* Release Tasks
*/
gulp.task('publish:tag', function (done) {
require('fs').readFile(__dirname + '/CHANGELOG.md', 'utf-8', function(err, changelogFile) {
if (err) {
throw err;
}
if (typeof changelogFile !== 'string') {
throw new Error('Please check the content of CHANGELOG.md');
}
var match = changelogFile.match(/((?:\d+\.)(?:\d+\.)(?:\d+))/i);
var pkg = match[0];
var v = 'v' + pkg;
var message = 'Release ' + v;
git.tag(v, message, function (err) {
if (err) throw err;
git.push('origin', v, function (err) {
if (err) throw err;
done();
});
});
});
});
gulp.task('publish:npm', function (done) {
require('child_process')
.spawn('npm', ['publish'], { stdio: 'inherit' })
.on('close', done);
});
gulp.task('release', ['publish:tag']);