gulp-tag-version
Tag git repository with current package version (gulp plugin).
It will read the version
attribute (by default, override with key
option) from the JSON stream (probably your package.json
or bower.json
), prefixes it with "v"
(override with prefix
option) and tags the repository (effectively issues the git tag <tagname>
command) with such created tagname (e.g. v1.2.3
).
Simple example gulpfile
var gulp = require('gulp'),
tagVersion = require('gulp-tag-version');
gulp.task('tag', function() {
return gulp.src(['./package.json']).pipe(tagVersion());
});
Advanced example gulpfile (with bumping and commiting)
var gulp = require('gulp'),
git = require('gulp-git'),
bump = require('gulp-bump'),
filter = require('gulp-filter'),
tagVersion = require('gulp-tag-version');
function inc(importance) {
return gulp.src(['./package.json', './bower.json'])
.pipe(bump({type: importance}))
.pipe(gulp.dest('./'))
.pipe(git.commit('bumps package version'))
.pipe(filter('package.json'))
.pipe(tagVersion());
}
gulp.task('patch', function() { return inc('patch'); })
gulp.task('feature', function() { return inc('minor'); })
gulp.task('release', function() { return inc('major'); })
- If you need any special tagging options to be passed down to
git.tag
, just add it to the tagVersion
options. For example:
gulp.task('bump_submodule', function(){
return gulp.src('./bower.json', { cwd: './dist' })
.pipe(bump({type: 'patch'}))
.pipe(gulp.dest('./',{ cwd: './dist' }))
.pipe(git.commit('bumps package version',{cwd: './dist'}))
.pipe(filter('bower.json'))
.pipe(tagVersion({cwd: './dist'}));
});
- If you don't want the version number to be read from the input stream, use the
version
parameter:
return gulp.src ...
...
.pipe(tagVersion({version: '1.2.3'}));
Thanks :beer:
- to guys and gals from Fractal for Gulp itself, obviously
- to Steve Lacy (http://slacy.me) for creating
gulp-bump
and gulp-git
used here - The main file structure is based on
gulp-bump
a bit as well (this is my first plugin :)) - To @pacemkr for the first pull request I ever got (supporting empty prefix)
- To @lapanoid for passing
opts
down to git.tag
- To @brianmhunt for suggesting the
version
parameter - To @adambuczynski for option to customize tag label
- To @mjeanroy for a gulp-util obsoletion update