Skip to content

Commit f9d1baf

Browse files
author
contra
committed
Merge pull request gulpjs#1195 from stevemao/changelog
add generating changelog in the workflow
2 parents e3efb4d + 77205ac commit f9d1baf

File tree

1 file changed

+30
-7
lines changed

1 file changed

+30
-7
lines changed

docs/recipes/bump-version-and-create-git-tag.md

+30-7
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,42 @@
11
# Bump version number and create new Git tag
22

33
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.
65

76
``` javascript
87

98
var gulp = require('gulp');
109
var runSequence = require('run-sequence');
10+
var conventionalChangelog = require('conventional-changelog');
11+
var conventionalGithubReleaser = require('conventional-github-releaser');
1112
var bump = require('gulp-bump');
1213
var gutil = require('gulp-util');
1314
var git = require('gulp-git');
1415
var fs = require('fs');
1516

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+
1636
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.
2040
return gulp.src(['./bower.json', './package.json'])
2141
.pipe(bump({type: "patch"}).on('error', gutil.log))
2242
.pipe(gulp.dest('./'));
@@ -39,19 +59,22 @@ gulp.task('create-new-tag', function (cb) {
3959
}
4060
git.push('origin', 'master', {args: '--tags'}, cb);
4161
});
42-
62+
4363
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
4566
return JSON.parse(fs.readFileSync('./package.json', 'utf8')).version;
4667
};
4768
});
4869

4970
gulp.task('release', function (callback) {
5071
runSequence(
5172
'bump-version',
73+
'changelog',
5274
'commit-changes',
5375
'push-changes',
5476
'create-new-tag',
77+
'github-release',
5578
function (error) {
5679
if (error) {
5780
console.log(error.message);

0 commit comments

Comments
 (0)