Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changelog generation #41

Merged
merged 3 commits into from
Aug 19, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,12 @@ $ 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`
9. Publish a release to Github releases (if `GH_TOKEN` is available)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it is not, will it fail silently?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No it will tell you with a log message

10. Publish to npm

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

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would preview be more intuitive?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not preview, this is the first time the changelog is generated.


```bash
$ aegir-relase --first
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/relase/release

```

You can skip all changelog generation and the github release by passing
in `--no-changelog`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍


## Other Notes

There is a badge.
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"babel-preset-es2015": "^6.9.0",
"brfs": "^1.4.3",
"chalk": "^1.1.3",
"conventional-github-releaser": "^1.1.3",
"coveralls": "^2.11.12",
"eslint": "^3.2.0",
"eslint-config-standard": "^5.3.5",
Expand All @@ -39,6 +40,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 +91,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())
}
19 changes: 19 additions & 0 deletions tasks/release/changelog.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
'use strict'

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

module.exports = (gulp, done) => {
if ($.util.env.changelog === false) {
$.util.log('Skipping changelog generation')
return 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())
}
28 changes: 28 additions & 0 deletions tasks/release/github.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
'use strict'

const $ = require('gulp-load-plugins')()
const conventionalGithubReleaser = require('conventional-github-releaser')

module.exports = (gulp, done) => {
if ($.util.env.changelog === false) {
$.util.log('Skipping github release')
return done()
}

const token = process.env.GH_TOKEN || $.util.env.token

if (!token) {
$.util.log($.util.colors.yellow(`
Skipping Github release as you are missing an oauth token.
You can supply one by either using $GH_TOKEN or --token.
`))
return done()
}

conventionalGithubReleaser({
type: 'oauth',
token
}, {
preset: 'angular'
}, done)
}
3 changes: 3 additions & 0 deletions tasks/release/post-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ module.exports = (gulp, done) => {
runSequence.use(gulp)(
'release:contributors',
'release:bump',
'release:changelog',
'release:commit',
'release:push',
'release:github',
'release:publish',
done
)
Expand Down