Skip to content

Commit

Permalink
feat(release): add changelog generation
Browse files Browse the repository at this point in the history
  • Loading branch information
dignifiedquire committed Aug 4, 2016
1 parent 7afb16a commit 44896e4
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 14 deletions.
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,10 @@ $ gulp build
2. Run tests
3. Build everything
4. Bump the version in `package.json`
5. Commit the version change
6. Create a git tag
7. Run `git push` to `upstream/master`
5. Generate a changelog based on the git log
6. Commit the version change & `CHANGELOG.md`
7. Create a git tag
8. Run `git push` to `upstream/master`

```bash
# Major release
Expand All @@ -151,6 +152,12 @@ $ aegir-release --env node
$ gulp release --env node
```

You can generate a changelog for all versions by using `--first`

```bash
$ aegir-relase --first
```

## Other Notes

There is a badge.
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"gulp": "^3.9.1",
"gulp-babel": "^6.1.2",
"gulp-bump": "^2.2.0",
"gulp-conventional-changelog": "^1.1.0",
"gulp-eslint": "^3.0.1",
"gulp-filter": "^4.0.0",
"gulp-git": "^1.10.0",
Expand Down Expand Up @@ -89,4 +90,4 @@
"dignifiedquire <[email protected]>",
"greenkeeperio-bot <[email protected]>"
]
}
}
5 changes: 5 additions & 0 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

const runSequence = require('run-sequence')
const $ = require('gulp-load-plugins')()
const fs = require('fs')

// Workaround gulp not exiting if there are some
// resources not freed
Expand Down Expand Up @@ -34,3 +35,7 @@ exports.fail = (msg) => {
$.util.log($.util.colors.red(msg))
process.exit(1)
}

exports.getVersion = () => {
return JSON.parse(fs.readFileSync('./package.json', 'utf8')).version
}
13 changes: 3 additions & 10 deletions tasks/release/bump.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

const $ = require('gulp-load-plugins')()
const semver = require('semver')
const fs = require('fs')
const _ = require('lodash')

const getVersion = require('../../src/utils').getVersion

function getType () {
if (_.includes($.util.env._, 'major')) return 'major'
if (_.includes($.util.env._, 'minor')) return 'minor'
Expand All @@ -13,21 +14,13 @@ function getType () {
return 'patch'
}

function getCurrentVersion () {
return JSON.parse(fs.readFileSync('./package.json', 'utf8')).version
}

module.exports = (gulp, done) => {
const type = getType()
const newVersion = semver.inc(getCurrentVersion(), type)
const newVersion = semver.inc(getVersion(), type)

$.util.log('Releasing %s', newVersion)

return gulp.src('./package.json')
.pipe($.bump({version: newVersion}))
.pipe(gulp.dest('./'))
.pipe($.git.add())
.pipe($.git.commit(`chore: release version v${newVersion}`, {args: '-n'}))
.pipe($.filter('package.json'))
.pipe($.tagVersion())
}
14 changes: 14 additions & 0 deletions tasks/release/changelog.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
'use strict'

const $ = require('gulp-load-plugins')()

module.exports = (gulp, done) => {
const releaseCount = $.util.env.first ? 0 : 1

return gulp.src('CHANGELOG.md')
.pipe($.conventionalChangelog({
preset: 'angular',
releaseCount
}))
.pipe(gulp.dest('./'))
}
15 changes: 15 additions & 0 deletions tasks/release/commit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
'use strict'

const $ = require('gulp-load-plugins')()

const getVersion = require('../../src/utils').getVersion

module.exports = (gulp, done) => {
const newVersion = getVersion()

return gulp.src(['package.json', 'CHANGELOG.md'])
.pipe($.git.add())
.pipe($.git.commit(`chore: release version v${newVersion}`, {args: '-n'}))
.pipe($.filter('package.json'))
.pipe($.tagVersion())
}
2 changes: 2 additions & 0 deletions tasks/release/post-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ module.exports = (gulp, done) => {
runSequence.use(gulp)(
'release:contributors',
'release:bump',
'release:changelog',
'release:commit',
'release:push',
'release:publish',
done
Expand Down

0 comments on commit 44896e4

Please sign in to comment.