Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f74f764a80 | ||
|
|
d5a8cb1935 | ||
|
|
f32a8e7d03 | ||
|
|
30fd1c19eb | ||
|
|
f192acc1ff | ||
|
|
4ccda66a39 | ||
|
|
c2d963be70 | ||
|
|
f8c4e495fd | ||
|
|
c3b59d6a06 | ||
|
|
53c0adb365 | ||
|
|
045c913342 | ||
|
|
5c12e718cb | ||
|
|
4e32c7dde0 | ||
|
|
6f891ed781 | ||
|
|
e43ff5573b | ||
|
|
19af8b7ef2 |
@@ -11,13 +11,15 @@
|
||||
|
||||
This is fully integrated with the `npm` lifecycle, so all you have to do is to setup your CI to `npm publish`.
|
||||
|
||||
The goal of this package is to remove humans from version numbers and releases. The [SemVer](http://semver.org/) spec clearly and unambiguously defines when to increase the major, minor or patch part and still we tend to think we're clever when we ignore this, because marketing or something.
|
||||
The goal of this package is to remove humans from version numbers and releases. The [SemVer](http://semver.org/) spec clearly and unambiguously defines when to increase the major, minor or patch part. Still we tend to ignore the rules, because we are emotionally attached to version numbers.
|
||||
|
||||

|
||||
|
||||
## How does this work?
|
||||
|
||||
Conventions, conventions, conventions. Instead of dumping [funny lols](http://whatthecommit.com/) into our commit messages, we can take some time to think about what we changed in the codebase and write it down. Following formalized conventions it this then possible to not only generate a meaningful changelog, but to determine the next semantic version to release. Currently the only supported style is the [AngularJS Commit Message Convention](https://docs.google.com/document/d/1QrDFcIiPjSLDn3EL15IJygNPiHORgU1_OOAqWjiDU5Y/edit) style, but feel free to formalize your own style, write a parser for it, and send a PR to this package.
|
||||
Conventions, conventions, conventions. Instead of dumping [lols](http://whatthecommit.com/) into our commit messages, we can take some time to think about what we changed in the codebase and write it down. Following formalized conventions it this then possible to not only generate a meaningful changelog, but to determine the next semantic version to release.
|
||||
|
||||
Note: Currently the only supported style is the [AngularJS Commit Message Convention](https://docs.google.com/document/d/1QrDFcIiPjSLDn3EL15IJygNPiHORgU1_OOAqWjiDU5Y/edit) style, but feel free to formalize your own style, write a parser for it, and send a PR to this package.
|
||||
|
||||
```
|
||||
<type>(<scope>): <subject>
|
||||
@@ -82,11 +84,13 @@ Note: `semantic-release` works around a limitation in `npm`'s `prepublish` step.
|
||||
|
||||
## How do I set this up?
|
||||
|
||||
First of all you need to install `semantic-release` and save it as a `devDependency`.
|
||||
|
||||
### Installation
|
||||
|
||||
First of all you need to install `semantic-release` and save it as a `devDependency`.
|
||||
|
||||
```bash
|
||||
npm install --save-dev semantic-release
|
||||
# Btw, if you're feeling lazy you can just type this – it's the same thing.
|
||||
npm i -D semantic-release
|
||||
```
|
||||
|
||||
@@ -135,6 +139,7 @@ notifications:
|
||||
email: false
|
||||
env:
|
||||
# Get your token here: https://github.com/settings/tokens/new
|
||||
# Grant the token repo/public_repo scope (all others can be deselected)
|
||||
# You should encrypt this:
|
||||
# `travis encrypt GH_TOKEN=<token> --add`
|
||||
global: GH_TOKEN=<github-access-token-with-acceess-to-your-repo>
|
||||
@@ -191,7 +196,7 @@ Note: pre-release flags are kind of an exeption here and a solution for them is
|
||||
|
||||
### How do I get back to good ol' `npm publish`?
|
||||
|
||||
`npm` offers the `--no-scripts` flag. Doing `npm publish --no-scripts` doesn't execute the `prepublish` and `postpublish` scripts.
|
||||
`npm` offers the `--ignore-scripts` flag. Doing `npm publish --ignore-scripts` doesn't execute the `prepublish` and `postpublish` scripts.
|
||||
|
||||
### Is it _really_ a good idea to release on every push?
|
||||
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
set -e
|
||||
|
||||
[ -d ".tmp" ] && ./bin/post-test
|
||||
|
||||
mkdir -p .tmp/modules
|
||||
|
||||
export DEBUG=ghrs:cli
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ var efh = require('error-first-handler')
|
||||
|
||||
module.exports = {
|
||||
efh: efh,
|
||||
standard: efh(function(err) {
|
||||
standard: efh(function (err) {
|
||||
console.log('Something went wrong:')
|
||||
if (typeof err === 'string') return console.log(err)
|
||||
if (err instanceof Error) return console.log(err.message)
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
'use strict'
|
||||
|
||||
var request = require('request')
|
||||
|
||||
var efh = require('./error').efh
|
||||
|
||||
module.exports = function (pkgName, cb) {
|
||||
request(process.env.npm_config_registry + pkgName, efh(cb)(function (response, body) {
|
||||
var res = {
|
||||
version: null,
|
||||
gitHead: null,
|
||||
pkg: null
|
||||
}
|
||||
|
||||
if (response.statusCode === 404 || !body) return cb(null, res)
|
||||
|
||||
var pkg = JSON.parse(body)
|
||||
|
||||
if (pkg.error && response.statusCode !== 404) return cb(pkg.error)
|
||||
|
||||
res.version = pkg['dist-tags'].latest
|
||||
res.gitHead = pkg.versions[res.version].gitHead
|
||||
res.pkg = pkg
|
||||
|
||||
cb(null, res)
|
||||
}))
|
||||
}
|
||||
+3
-5
@@ -4,10 +4,8 @@ var git = require('conventional-changelog/lib/git')
|
||||
|
||||
var efh = require('../error').efh
|
||||
|
||||
module.exports = function (cb) {
|
||||
git.latestTag(efh(cb)(function (from) {
|
||||
git.getCommits({from: from}, efh(cb)(function (commits) {
|
||||
cb(null, commits)
|
||||
}))
|
||||
module.exports = function (from, cb) {
|
||||
git.getCommits({from: from}, efh(cb)(function (commits) {
|
||||
cb(null, commits)
|
||||
}))
|
||||
}
|
||||
|
||||
+2
-2
@@ -4,8 +4,8 @@ var analyze = require('./analyze')
|
||||
var commits = require('./commits')
|
||||
var efh = require('../error').efh
|
||||
|
||||
module.exports = function (cb) {
|
||||
commits(efh(cb)(function (commits) {
|
||||
module.exports = function (gitHead, cb) {
|
||||
commits(gitHead, efh(cb)(function (commits) {
|
||||
cb(null, analyze(commits))
|
||||
}))
|
||||
}
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
'use strict'
|
||||
|
||||
var request = require('request')
|
||||
|
||||
var efh = require('./error').efh
|
||||
|
||||
module.exports = function (pkg, cb) {
|
||||
if (!pkg.name) return cb(new Error('Package must have a name'))
|
||||
|
||||
request(process.env.npm_config_registry + pkg.name, efh(cb)(function (response, body) {
|
||||
var pkg = JSON.parse(body)
|
||||
|
||||
if (response.statusCode === 404 || pkg.error) return cb(null, null, true)
|
||||
|
||||
cb(null, pkg['dist-tags'].latest)
|
||||
}))
|
||||
}
|
||||
+2
-1
@@ -11,6 +11,7 @@
|
||||
"abbrev": "^1.0.5",
|
||||
"conventional-changelog": "0.0.11",
|
||||
"error-first-handler": "^1.0.1",
|
||||
"git-head": "^1.2.1",
|
||||
"github": "^0.2.3",
|
||||
"github-url-from-git": "^1.4.0",
|
||||
"ini": "^1.3.2",
|
||||
@@ -25,7 +26,7 @@
|
||||
"nano-uid": "^0.2.0",
|
||||
"nixt": "^0.4.1",
|
||||
"sinopia": "^1.0.0",
|
||||
"standard": "^2.3.1",
|
||||
"standard": "^3.2.1",
|
||||
"tap-spec": "^2.2.0",
|
||||
"tape": "^3.5.0"
|
||||
},
|
||||
|
||||
+2
-2
@@ -1,10 +1,10 @@
|
||||
'use strict'
|
||||
|
||||
var exec = require('child_process').exec
|
||||
var readFile = require('fs').readFileSync
|
||||
var url = require('url')
|
||||
|
||||
var changelog = require('conventional-changelog')
|
||||
var gitHead = require('git-head')
|
||||
var GitHubApi = require('github')
|
||||
var parseSlug = require('parse-github-repo-url')
|
||||
var parseUrl = require('github-url-from-git')
|
||||
@@ -31,7 +31,7 @@ module.exports = function (options, cb) {
|
||||
repository: parseUrl(repository),
|
||||
file: false
|
||||
}, efh(cb)(function (log) {
|
||||
exec('git rev-parse HEAD', efh(cb)(function (hash) {
|
||||
gitHead(efh(cb)(function (hash) {
|
||||
var ghRepo = parseSlug(repository)
|
||||
var release = {
|
||||
owner: ghRepo[0],
|
||||
|
||||
+8
-8
@@ -5,17 +5,17 @@ var fs = require('fs')
|
||||
var semver = require('semver')
|
||||
|
||||
var type = require('../lib/type')
|
||||
var version = require('../lib/version')
|
||||
var npmInfo = require('../lib/npm-info')
|
||||
var efh = require('../lib/error').efh
|
||||
|
||||
module.exports = function (options, cb) {
|
||||
type(efh(cb)(function (type) {
|
||||
if (!type) return cb(null, null)
|
||||
|
||||
var path = './package.json'
|
||||
var pkg = JSON.parse(fs.readFileSync(path))
|
||||
version(pkg, efh(cb)(function (version, unpublished) {
|
||||
pkg.version = unpublished ? '1.0.0' : semver.inc(version, type)
|
||||
var path = './package.json'
|
||||
var pkg = JSON.parse(fs.readFileSync(path))
|
||||
if (!pkg.name) return cb(new Error('Package must have a name'))
|
||||
npmInfo(pkg.name, efh(cb)(function (res) {
|
||||
type(res.gitHead, efh(cb)(function (type) {
|
||||
if (!type) return cb(null, null)
|
||||
pkg.version = !res.version ? '1.0.0' : semver.inc(res.version, type)
|
||||
if (!options.debug) fs.writeFileSync(path, JSON.stringify(pkg, null, 2))
|
||||
|
||||
cb(null, pkg.version)
|
||||
|
||||
+1
-4
@@ -28,10 +28,7 @@ module.exports = function () {
|
||||
var config = ini.decode(fs.readFileSync('./.git/config') + '')
|
||||
var repo = config['remote "origin"'].url
|
||||
|
||||
if (repo) pkg.repository = {
|
||||
type: 'git',
|
||||
url: ghUrl(repo)
|
||||
}
|
||||
if (repo) pkg.repository = { type: 'git', url: ghUrl(repo) }
|
||||
}
|
||||
|
||||
// set up devDependency
|
||||
|
||||
@@ -23,7 +23,7 @@ module.exports = function (test, createModule) {
|
||||
.run(command)
|
||||
.code(0)
|
||||
.stdout(/> semantic-release pre\n$/m)
|
||||
.end(function(err) {
|
||||
.end(function (err) {
|
||||
t.is(pkg + '', fs.readFileSync(cwd + '/package.json') + '', 'package')
|
||||
t.error(err, 'nixt')
|
||||
})
|
||||
|
||||
@@ -25,19 +25,32 @@ module.exports = function (test, createModule) {
|
||||
}
|
||||
}, efh()(function (name, cwd) {
|
||||
test('postpublish', function (t) {
|
||||
t.test('publish new version to github releases', function (t) {
|
||||
t.plan(1)
|
||||
|
||||
nixt()
|
||||
var base = nixt()
|
||||
.cwd(cwd)
|
||||
.env('CI', true)
|
||||
.env('GH_URL', 'http://127.0.0.1:4343/')
|
||||
.env('GH_TOKEN', '***')
|
||||
.exec('git commit --allow-empty -m "feat(cool): the next big thing"')
|
||||
.run('npm run postpublish')
|
||||
.code(0)
|
||||
.stdout(/> semantic-release post\n\nGenerating changelog from.*\nParsed/m)
|
||||
.end(function(err) {
|
||||
|
||||
t.test('publish new version to github releases', function (t) {
|
||||
t.plan(1)
|
||||
|
||||
base.clone()
|
||||
.run('npm run postpublish')
|
||||
.end(function (err) {
|
||||
t.error(err, 'nixt')
|
||||
})
|
||||
})
|
||||
|
||||
t.test('publish new version (with detached HEAD) to github releases', function (t) {
|
||||
t.plan(1)
|
||||
|
||||
base.clone()
|
||||
.exec('git checkout `git rev-parse HEAD`')
|
||||
.run('npm run postpublish')
|
||||
.end(function (err) {
|
||||
t.error(err, 'nixt')
|
||||
})
|
||||
})
|
||||
@@ -49,7 +62,7 @@ module.exports = function (test, createModule) {
|
||||
t.error(err, 'github')
|
||||
t.is(res.tag_name, 'v2.0.0', 'version')
|
||||
t.is(res.author.login, 'user', 'user')
|
||||
t.ok(/\n\n\n#### Features\n\n\* \*\*cool:\*\* the next big thing/.test(res.body), 'body')
|
||||
t.ok(/\n\n\n#### Features\n\n\* \*\*cool:\*\*\n.*the next big thing/.test(res.body), 'body')
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -28,7 +28,7 @@ module.exports = function (test, createModule) {
|
||||
.run('npm run prepublish')
|
||||
.code(code)
|
||||
.stdout(/> semantic-release pre\n\nDetermining new version\n/m)
|
||||
.end(function(err) {
|
||||
.end(function (err) {
|
||||
t.error(err, 'nixt')
|
||||
|
||||
var pkg = JSON.parse(fs.readFileSync(cwd + '/package.json'))
|
||||
@@ -38,8 +38,8 @@ module.exports = function (test, createModule) {
|
||||
return t.error(null, 'no publish')
|
||||
}
|
||||
|
||||
exec('npm publish --ignore-scripts', {cwd: cwd}, function(err) {
|
||||
setTimeout(function() {
|
||||
exec('npm publish --ignore-scripts', {cwd: cwd}, function (err) {
|
||||
setTimeout(function () {
|
||||
t.error(err, 'publish')
|
||||
}, 300)
|
||||
})
|
||||
|
||||
@@ -27,7 +27,7 @@ module.exports = function (test, createModule) {
|
||||
.run(command)
|
||||
.code(1)
|
||||
.stdout(/Everything is alright/)
|
||||
.end(function(err) {
|
||||
.end(function (err) {
|
||||
t.error(err, 'nixt')
|
||||
})
|
||||
})
|
||||
|
||||
@@ -22,7 +22,7 @@ module.exports = function (test, createModule) {
|
||||
.exec('git remote add origin git@github.com:user/repo.git')
|
||||
.run('./node_modules/.bin/semantic-release setup')
|
||||
.code(0)
|
||||
.end(function(err) {
|
||||
.end(function (err) {
|
||||
t.error(err, 'nixt')
|
||||
|
||||
var pkg = JSON.parse(readFile(join(cwd, 'package.json')))
|
||||
|
||||
@@ -25,7 +25,7 @@ module.exports = function (test, createModule) {
|
||||
, 'm'
|
||||
))
|
||||
.code(1)
|
||||
.end(function(err) {
|
||||
.end(function (err) {
|
||||
t.error(err, 'nixt')
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user