1
1
# Bump version number and create new Git tag
2
2
3
3
If your project follows a semantic versioning, it may be a good idea to automatize the steps needed to do a release.
4
- Below you have a simple recipe that bumps the project version, commits the changes to git and creates a
5
- new tag.
4
+ Below you have a simple recipe that bumps the project version, commits the changes to git and creates a new tag.
6
5
7
6
``` javascript
8
7
9
8
var gulp = require (' gulp' );
10
9
var runSequence = require (' run-sequence' );
10
+ var conventionalChangelog = require (' conventional-changelog' );
11
+ var conventionalGithubReleaser = require (' conventional-github-releaser' );
11
12
var bump = require (' gulp-bump' );
12
13
var gutil = require (' gulp-util' );
13
14
var git = require (' gulp-git' );
14
15
var fs = require (' fs' );
15
16
17
+ gulp .task (' changelog' , function () {
18
+ return gulp .src (' CHANGELOG.md' , {
19
+ buffer: false
20
+ })
21
+ .pipe (conventionalChangelog ({
22
+ preset: ' angular' // Or to any other commit message convention you use.
23
+ }))
24
+ .pipe (gulp .dest (' ./' ));
25
+ });
26
+
27
+ gulp .task (' github-release' , function (done ) {
28
+ conventionalGithubReleaser ({
29
+ type: " oauth" ,
30
+ token: ' 0126af95c0e2d9b0a7c78738c4c00a860b04acc8'
31
+ }, {
32
+ preset: ' angular' // Or to any other commit message convention you use.
33
+ }, done);
34
+ });
35
+
16
36
gulp .task (' bump-version' , function () {
17
- // Note: I have hardcoded the version change type to 'patch' but it may be a good idea to use
18
- // minimist (https://www.npmjs.com/package/minimist) to determine with a command argument whether you are doing
19
- // a 'major', 'minor' or a 'patch' change.
37
+ // We hardcode the version change type to 'patch' but it may be a good idea to
38
+ // use minimist (https://www.npmjs.com/package/minimist) to determine with a
39
+ // command argument whether you are doing a 'major', 'minor' or a 'patch' change.
20
40
return gulp .src ([' ./bower.json' , ' ./package.json' ])
21
41
.pipe (bump ({type: " patch" }).on (' error' , gutil .log ))
22
42
.pipe (gulp .dest (' ./' ));
@@ -39,19 +59,22 @@ gulp.task('create-new-tag', function (cb) {
39
59
}
40
60
git .push (' origin' , ' master' , {args: ' --tags' }, cb);
41
61
});
42
-
62
+
43
63
function getPackageJsonVersion () {
44
- // We parse the json file instead of using require because require caches multiple calls so the version number won't be updated
64
+ // We parse the json file instead of using require because require caches
65
+ // multiple calls so the version number won't be updated
45
66
return JSON .parse (fs .readFileSync (' ./package.json' , ' utf8' )).version ;
46
67
};
47
68
});
48
69
49
70
gulp .task (' release' , function (callback ) {
50
71
runSequence (
51
72
' bump-version' ,
73
+ ' changelog' ,
52
74
' commit-changes' ,
53
75
' push-changes' ,
54
76
' create-new-tag' ,
77
+ ' github-release' ,
55
78
function (error ) {
56
79
if (error) {
57
80
console .log (error .message );
0 commit comments