Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7ba1cb956f | ||
|
|
1f70215ffe | ||
|
|
245f918201 | ||
|
|
f0f53f207b | ||
|
|
41c90124f6 | ||
|
|
44db677c4a | ||
|
|
127cb673bd | ||
|
|
a5dabed534 | ||
|
|
be9bb40dd2 | ||
|
|
4821aff69e | ||
|
|
773ecf693f | ||
|
|
f2dd66f614 |
@@ -1,5 +1,6 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- iojs-v2
|
||||
- iojs-v1
|
||||
- '0.10'
|
||||
- '0.12'
|
||||
|
||||
@@ -44,7 +44,7 @@ Note: The default release notes are a [changelog](https://github.com/ajoslin/con
|
||||
|
||||
Note: This is tied to GitHub, feel free to send PRs for other services.
|
||||
|
||||
Note: `semantic-release` works around a limitation in `npm`'s `prepublish` step. Once a version is published it prints an error that you can *safely ignore* [npm/npm#7118](https://github.com/npm/npm/issues/7118).
|
||||
Note: `semantic-release` works around a limitation in `npm`'s `prepublish` step. Once a version is published it prints a "Could not pack" error that you can *safely ignore* [npm/npm#7118](https://github.com/npm/npm/issues/7118).
|
||||
|
||||
## How you can set it up
|
||||
|
||||
@@ -101,6 +101,9 @@ cache:
|
||||
- node_modules
|
||||
notifications:
|
||||
email: false
|
||||
# See https://github.com/boennemann/semantic-release/issues/18
|
||||
before_deploy:
|
||||
- npm config set spin false --global
|
||||
env:
|
||||
# Get your token here: https://github.com/settings/tokens/new
|
||||
# Grant the token repo/public_repo scope (all others can be deselected)
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ var efh = require('./error').efh
|
||||
module.exports = function (from, cb) {
|
||||
var range = (from ? from + '..' : '') + 'HEAD'
|
||||
exec(
|
||||
'git log -E --format=%H==SPLIT==%s==END== ' + range,
|
||||
'git log -E --format=%H==SPLIT==%B==END== ' + range,
|
||||
efh(cb)(function (stdout) {
|
||||
cb(null, String(stdout).split('==END==\n')
|
||||
|
||||
|
||||
+2
-1
@@ -5,7 +5,8 @@ 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 encodedPkgName = pkgName.replace(/\//g, '%2F')
|
||||
request(process.env.npm_config_registry + encodedPkgName, efh(cb)(function (response, body) {
|
||||
var res = {
|
||||
version: null,
|
||||
gitHead: null,
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
"semver": "^4.3.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"cracks": "^2.0.1",
|
||||
"github-release-fake-server": "^1.3.0",
|
||||
"lodash.defaults": "^3.0.0",
|
||||
"nano-uid": "^0.2.0",
|
||||
@@ -59,5 +60,8 @@
|
||||
"test:style": "standard",
|
||||
"test:integration": "node tests | tap-spec",
|
||||
"test": "./bin/test"
|
||||
},
|
||||
"release": {
|
||||
"verification": "cracks"
|
||||
}
|
||||
}
|
||||
|
||||
+37
-3
@@ -20,10 +20,44 @@ module.exports = function (options, plugins, cb) {
|
||||
var type = analyzer(commits)
|
||||
|
||||
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)
|
||||
if (res.version) {
|
||||
pkg.version = semver.inc(res.version, type)
|
||||
} else {
|
||||
type = 'major'
|
||||
pkg.version = '1.0.0'
|
||||
}
|
||||
|
||||
var writePkg = function () {
|
||||
if (!options.debug) fs.writeFileSync(path, JSON.stringify(pkg, null, 2) + '\n')
|
||||
cb(null, pkg.version)
|
||||
}
|
||||
|
||||
if (!plugins.verification) return writePkg()
|
||||
|
||||
var opts = {}
|
||||
|
||||
if (typeof plugins.verification === 'string') {
|
||||
opts.name = plugins.verification
|
||||
}
|
||||
if (typeof plugins.verification === 'object') {
|
||||
opts = plugins.verification
|
||||
}
|
||||
|
||||
opts.type = type
|
||||
opts.commits = commits
|
||||
opts.version = res.version
|
||||
opts.nextVersion = pkg.version
|
||||
|
||||
var verification = require(opts.name)
|
||||
|
||||
console.log('Running verification hook...')
|
||||
|
||||
verification(opts, function (error, ok) {
|
||||
if (!error && ok) return writePkg()
|
||||
console.log('Verification failed' + (error ? ': ' + error : ''))
|
||||
process.exit(1)
|
||||
})
|
||||
}))
|
||||
}))
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ var test = require('tape')
|
||||
var createModule = require('./lib/create-module')
|
||||
|
||||
require('./scenarios/custom-analyzer')(test, createModule)
|
||||
require('./scenarios/custom-verification')(test, createModule)
|
||||
require('./scenarios/ignore')(test, createModule)
|
||||
require('./scenarios/prepublish')(test, createModule)
|
||||
require('./scenarios/postpublish')(test, createModule)
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
'use strict'
|
||||
|
||||
module.exports = function (opts, cb) {
|
||||
cb(null, !(opts.commits.length % 2))
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
'use strict'
|
||||
|
||||
var path = require('path')
|
||||
|
||||
var efh = require('error-first-handler')
|
||||
var nixt = require('nixt')
|
||||
|
||||
module.exports = function (test, createModule) {
|
||||
createModule({
|
||||
release: {
|
||||
verification: path.join(__dirname, '../lib/custom-verification')
|
||||
}
|
||||
}, efh()(function (name, cwd) {
|
||||
test('custom-verification', function (t) {
|
||||
t.test('even commit count', function (t) {
|
||||
t.plan(1)
|
||||
nixt()
|
||||
.cwd(cwd)
|
||||
.env('CI', true)
|
||||
.env('npm_config_registry', 'http://127.0.0.1:4873/')
|
||||
.exec('git commit --allow-empty -m "feat: commit"')
|
||||
.run('npm run prepublish')
|
||||
.code(0)
|
||||
.end(function (err) {
|
||||
t.error(err, 'nixt')
|
||||
})
|
||||
})
|
||||
|
||||
t.test('odd commit count', function (t) {
|
||||
t.plan(1)
|
||||
nixt()
|
||||
.cwd(cwd)
|
||||
.env('CI', true)
|
||||
.env('npm_config_registry', 'http://127.0.0.1:4873/')
|
||||
.exec('git commit --allow-empty -m "feat: commit"')
|
||||
.run('npm run prepublish')
|
||||
.code(1)
|
||||
.stdout(/Verification failed/)
|
||||
.end(function (err) {
|
||||
t.error(err, 'nixt')
|
||||
})
|
||||
})
|
||||
})
|
||||
}))
|
||||
}
|
||||
Reference in New Issue
Block a user