Skip to content

Commit

Permalink
core: add release tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
mjeanroy committed Nov 25, 2016
1 parent 9fcb00a commit 6df8e78
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
39 changes: 39 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,17 @@
* SOFTWARE.
*/

const fs = require('fs');
const path = require('path');
const gulp = require('gulp');
const jasmine = require('gulp-jasmine');
const babel = require('gulp-babel');
const del = require('del');
const eslint = require('gulp-eslint');
const gutil = require('gulp-util');
const git = require('gulp-git');
const bump = require('gulp-bump');
const runSequence = require('run-sequence');

const root = path.join(__dirname);
const config = {
Expand Down Expand Up @@ -67,3 +72,37 @@ gulp.task('lint', () => {
.pipe(eslint.format())
.pipe(eslint.failAfterError());
});

gulp.task('commit:pre', () => {
const dist = path.join(__dirname, 'dist');
const packageJson = path.join(__dirname, 'package.json');
return gulp.src([packageJson, dist])
.pipe(git.add({args: '-f'}))
.pipe(git.commit('release: release version'));
});

gulp.task('commit:post', () => {
const dist = path.join(__dirname, 'dist');
return gulp.src(dist)
.pipe(git.rm({args: '-r'}))
.pipe(git.commit('release: prepare next release'));
});

gulp.task('tag', (done) => {
const pkg = fs.readFileSync(path.join(__dirname, 'package.json'), 'utf8');
const version = JSON.parse(pkg).version;
git.tag(`v${version}`, `release: tag version ${version}`, done);
});

['major', 'minor', 'patch'].forEach((level) => {
gulp.task(`bump:${level}`, () => {
return gulp.src(path.join(__dirname, 'package.json'))
.pipe(bump({type: level})
.on('error', gutil.log))
.pipe(gulp.dest(__dirname));
});

gulp.task('release:' + level, ['build'], () => {
return runSequence(`bump:${level}`, 'commit:pre', 'tag', 'commit:post');
});
});
10 changes: 9 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
"lint": "gulp lint",
"clean": "gulp clean",
"build": "gulp build",
"test": "gulp test"
"test": "gulp test",
"release": "gulp release:minor",
"release:patch": "gulp release:patch",
"release:minor": "gulp release:minor",
"release:major": "gulp release:major"
},
"keywords": [
"rollup",
Expand All @@ -28,9 +32,13 @@
"eslint-config-google": "0.7.0",
"gulp": "3.9.1",
"gulp-babel": "6.1.2",
"gulp-bump": "2.5.1",
"gulp-eslint": "3.0.1",
"gulp-git": "1.12.0",
"gulp-jasmine": "2.4.2",
"gulp-util": "3.0.7",
"jasmine-core": "2.5.2",
"run-sequence": "1.2.2",
"tmp": "0.0.31"
}
}

0 comments on commit 6df8e78

Please sign in to comment.