59 Commits

Author SHA1 Message Date
Pierre Vanduynslager
d4c7605f68 fix: Use default plugin if the path property is missing from a single plugin configuration 2017-11-22 19:47:09 -05:00
Pierre Vanduynslager
facdadaddb ci: Lint with XO 2017-11-21 20:55:47 -05:00
Pierre Vanduynslager
d548edcf37 feat: Extract npm and github publish to plugins
- Add a new plugin type: `publish`
- Add support for multi-plugin. A plugin module can now return an object with a property for each plugin type
- Uses by default [npm](https://github.com/semantic-release/npm) and [github](https://github.com/semantic-release/github) in addition of Travis for the verify condition plugin
- Uses by default [npm](https://github.com/semantic-release/npm) and [github](https://github.com/semantic-release/github) for the publish plugin
- `gitTag` if one can be found is passed to `generateNotes` for both `lastRelease` and `nextRelease`
- `semantic-release` now verifies the plugin configuration (in the `release` property of `package.json`) and throws an error if it's invalid
- `semantic-release` now verifies each plugin output and will throw an error if a plugin returns an unexpected value.

BREAKING CHANGE: `githubToken`, `githubUrl` and `githubApiPathPrefix` have to be set at the [github](https://github.com/semantic-release/github) plugin level. They can be set via `GH_TOKEN`, `GH_URL` and `GH_PREFIX` environment variables.

BREAKING CHANGE: the `npm` parameter is not passed to any plugin anymore. Each plugin have to read `.npmrc` if they needs to (with https://github.com/kevva/npm-conf for example).
2017-11-21 16:41:04 -05:00
Pierre Vanduynslager
991a7b5f97 refactor: Simplify file tree 2017-11-21 16:41:04 -05:00
Pierre Vanduynslager
17a600672f style: Update style for Prettier 1.8.0 2017-11-07 00:34:16 -05:00
Pierre Vanduynslager
d0180c4348 feat: Additional commit information
Add `author`, `commiter`, `gitTags` and `committerDate` to the commit object passed to plugin
2017-10-29 20:01:16 -07:00
Pierre Vanduynslager
c90765e10d fix: Include Error properties in logs 2017-10-29 14:37:05 -07:00
Pierre Vanduynslager
ad2e1d76b7 test: Fix typos: only in tests and useless console.log() 2017-10-29 14:37:05 -07:00
Pierre Vanduynslager
65d344bae8 fix: Check SemanticReleaseError by error.semanticRelease property 2017-10-29 14:37:05 -07:00
Pierre-Denis Vanduynslager
e2a8a5cd32 feat: Refactor CLI to run with one command, improve logs, modularize, add tests
- Run with one command and do not rely on error exit codes to stop the process when a release is not necessary
- Break `index.js` in smaller modules in order to improve testability and simplify the code
- Add several missing unit and integration tests to reach 100% coverage
- Integration tests now test end to end, including publishing to Github (with http://www.mock-server.com on Docker)
- Use `tj/commander.js` to print an help message, verify and parse CLI arguments
- Semantic-release can now be called via Javascript API: `require('semantic-release')(options)`
- Remove npmlog dependency and add more log messages
- Logger is now passed to plugins
- Add debug logs with `visionmedia/debug`. `debug` is enabled for both semantic-release and plugins with `--debug`
- Use `kevva/npm-conf` in place of the deprecated `npm/npmconf`
- Pass lastRelease, nextRelease and commits to generate-notes plugin
- In dry-run mode, print the release note instead of publishing it to Github as draft, and skip the CI verifications
- The dry-run mode does not require npm and Github TOKEN to be set anymore and can be run locally

BREAKING CHANGE: Semantic-Release must now be executed with `semantic-release` instead of `semantic-release pre && npm publish && semantic-release post`.
BREAKING CHANGE: The `semantic-release` command now returns with exit code 0 on expected exception (no release has to be done, running on a PR, gitHead not found, other CI job failed etc...). It only returns with 1 when there is an unexpected error (code error in a plugin, plugin not found, git command cannot be run etc..).
BREAKING CHANGE: Calling the `semantic-release` command with unexpected argument(s) now exit with 1 and print an help message.
BREAKING CHANGE: Semantic-Release does not rely on `npmlog` anymore and the log level cannot be configured. Debug logs can be activated with CLI option `--debug` or with environment variable `DEBUG=semantic-release:*`
BREAKING CHANGE: The CLI options `--debug` doesn't enable the dry-run mode anymore but activate the debugs. The dry run mode is now set with the CLI command `--dry-run` or `-d`.
2017-10-27 18:07:13 -07:00
Pierre-Denis Vanduynslager
b0bc49063b fix: handle errors when verifyConditions and verifyRelease are a pipeline 2017-10-18 14:00:20 -07:00
Pierre-Denis Vanduynslager
580ad9c3d2 feat: Allow to recover from ENOTINHISTORY with a tag and handle detached head repo
- Tag sha will now be used also if there is a gitHead in last release and it's not in the history
- Use `git merge-base` to determine if a commit is in history, allowing to use CI creating detached head repo
- Mention recovery solution by creating a version tag in `ENOTINHISTORY` and `ENOGITHEAD` error messages
- Do not mention branches containing missing commit in `ENOTINHISTORY` and `ENOGITHEAD` error messages as it's not available by default on most CI
2017-10-11 20:54:10 -07:00
Pierre-Denis Vanduynslager
8e9d9f77f3 fix: Always pass pluginConfig to plugins as a defined object 2017-10-06 10:28:37 -07:00
Pierre-Denis Vanduynslager
90417c6ffe fix: Exit with 1 if unexpected error happens 2017-10-06 00:30:08 -04:00
Pierre-Denis Vanduynslager
85dd69b3a2 feat: Retrieve version gitHead from git tags and unshallow the repo if necessary
Add several fixes and improvements in the identification of the last release gitHead:
- If there is no last release, unshallow the repo in order to retrieve all existing commits
- If git head is not present in last release, try to retrieve it from git tag with format ‘v\<version\>’ or ‘\<version\>’
- If the last release git head cannot be determined and  found in commit history, unshallow the repo and try again
- Throw a ENOGITHEAD error if the gitHead for the last release cannot be found in the npm metadata nor in the git tags, preventing to make release based on the all the commits in the repo as before
- Add integration test for the scenario with a packed repo from which `npm republish` fails to read the git head

Fix #447, Fix #393, Fix #280, Fix #276
2017-10-02 19:43:46 -04:00
Pierre-Denis Vanduynslager
abf92ad03d refactor: Use ES6, Test with AVA
- Use async/await instead of callbacks
- Use execa to run command line
- Use AVA for tests
- Add several assertions in the unit tests
- Add documentation (comments) in the tests
- Run tests with a real git repo instead of mocking child_process and add test helpers to create repos, commits and checkout
- Simplify test directory structure
- Simplify code readability (mostly with async/await)
- Use eslint for for linting, prettier for formatting
2017-09-30 13:30:41 -04:00
Kaito Udagawa
3f8559731f fix(post): Create a tag before makeing a release 2017-08-13 20:29:49 -07:00
Kaito Udagawa
f148a61339 fix(post): fix target_commitish to be the default branch
target_commitish in GitHub Releases has two different meanings:
* Target commit that a new associated tag will be created on
* Target branch to compute how many "commits to since this release"

target_commitish is usually the default branch (aka master), because the
distance between the release and the latest branch is the primary concern.

Before this change, target_commitish was left to be a hash and the
feature of GitHub Releases that shows how much time passed since the
release is ruined, because no tracking branch is given.

By this change, target_commitish is changed to be the default branch
given in the configuration (options.branch) via edit a release API after
the release and tag are created via crate a release API.
2017-08-13 20:29:49 -07:00
Gregor
5b3bdd226f chore: remove console.log 2017-08-13 12:10:36 -07:00
Christoph Witzko
462c51dc2a style: standard 2016-11-28 16:37:00 +01:00
Christoph Witzko
9a51b0271d chore: update github client 2016-11-28 16:36:53 +01:00
develar
35da08d074 test: fix "/bin/bash: NO_PROMPT=yes: command not found" 2016-11-28 16:14:43 +01:00
Ben Gummer
73138f8a8f fix: use spawn instead of exec for 'git log' to avoid maxBuffer err 2016-11-28 15:50:59 +01:00
Joscha Feth
a5cb9ea7f7 fix(gitlog): increase maxBuffer
This is needed for repositories with a lot of commits and/or a big changelog.

Closes #286
2016-09-01 14:35:34 +02:00
jrwebdev
2644badeec feat(post): Adds GitHub Enterprise support
Adds githubApiPathPrefix option for GitHub Enterprise APIs. Removes parse-github-repo-url check from
verify to support custom GitHub URLs

closes #146
2016-01-18 18:29:15 +13:00
Gleb Bahmutov
66454e7e46 feat(verify): added support for parsing hosted gitlab and other repo urls
Closes #114
2016-01-13 09:04:35 +01:00
Stephan Bönnemann
5cdc732b68 chore: remove babel, fix integration tests
This commit removes babel/es6 from all source and test files, because it was introducing a lot of overhead and only little gain.
This commit fixes and enables integration tests on Travis.
This commit fixes #153 and #151 along the way.

_Originally this commit should have only removed babel, but without working tests that's a bit too hairy._
_I only realized that half way into removing babel/es6, so things are all over the place now._

Closes #153, Closes #151
2015-12-31 15:11:54 +01:00
Stephan Bönnemann
26e2afc152 test: end tests properly 2015-09-26 20:22:11 +02:00
Stephan Bönnemann
927e930bb9 style(standard): fix ternaries 2015-09-26 12:45:11 +02:00
Stephan Bönnemann
a3f561d1d1 test(mocks): correctly fail git command when ref not in history 2015-09-16 09:51:26 +02:00
Stephan Bönnemann
451378117d fix(registry): be better at using the correct registry (relevant for npme)
Closes #53
2015-08-22 23:32:49 +02:00
Stephan Bönnemann
a16c36ed4d style: branch available in options not root of config 2015-08-22 19:49:09 +02:00
Stephan Bönnemann
5cc7da6035 fix(commits): add helpful error when lastRelease not in history
Closes #61, Closes #50
2015-08-22 19:31:29 +02:00
Stephan Bönnemann
700ec9d4ca feat(plugins): run verifications in series
With this new feature you can pass an array of plugin locations/names to
both "verifyConditions" and "verifyRelease" in your `package.json`'s "release"
field. This will run multiple verification plugins in series.
2015-08-22 14:52:01 +02:00
Ari Porad
7ceac76689 feat(plugins): add getLastRelease hook
The code to determine the last-release is now in its own repository: https://github.com/semantic-release/last-release-npm
One can overwrite that behavior by defining a "getLastRelease" plugin. This way
one can decouple semantic-release from npm, e.g. by implementing a git-tag
based version. This is already worked on: https://github.com/semantic-release/last-release-git-tag

Closes #56
2015-08-18 13:56:24 +02:00
Stephan Bönnemann
05490fe229 test(last-release): adapt registry-mock to how the registry actually behaves 2015-07-30 17:15:03 +01:00
Stephan Bönnemann
ddaec4f2bf test(integration): make em at least run locally 2015-07-19 16:21:40 +02:00
Stephan Bönnemann
d9eeb3fcae refactor: use one config object instead of passing arguments to plugins on their own
This commit does a lot but it's all connected and tries to make everything more extensible and future proof.

1. CLI arguments and options from the "package.json" are no longer treated as two different things. You can now pass options either way.

BREAKING CHANGE: cli arguments are now normalized to camelCase, so e.g. `options['github-url']` is now `options.githubUrl`

2. Plugins no longer receive config they need one by one, but in one huge object. This way it's easier to pass more info in the future w/o breaking existing plugins that rely on the position of the callback in the arguments array.

BREAKING CHANGE: Plugins now need to read their passed options from one huge config object.

Old:
```js
module.exports = function (pluginConfig, foo, bar, cb) {…}
```

New:
```js
// ES5
module.exports = function(pluginConfig, config, cb) {
  var foo = config.foo
  var bar = config.bar
  …
}

// ES6
module.exports = function (pluginConfig, {foo, bar}, cb) {…}
```
2015-07-19 15:34:30 +02:00
Stephan Bönnemann
ed05101a61 test(post): initial 2015-07-16 17:30:14 +02:00
Stephan Bönnemann
431babb42e fix(verify): ensure repo url in package.json is well formed 2015-07-16 14:07:52 +02:00
Stephan Bönnemann
6cf1711151 test(last-release): add custom dist-tag 2015-07-16 11:51:22 +02:00
Stephan Bönnemann
b1d9985ba3 test(plugins): test exported plugins 2015-07-14 21:13:36 +02:00
Stephan Bönnemann
af15fb4c61 fix(last-release): normalized registry url 2015-07-14 21:13:36 +02:00
Stephan Bönnemann
43c8df0bfe fix(plugins): require user plugins relative to the cwd 2015-07-13 12:03:05 +02:00
Stephan Bönnemann
150273c8fe fix(plugins): rename plugins 2015-07-13 11:53:32 +02:00
Stephan Bönnemann
c6f95e4870 test(pre): initial cli/integration suite 2015-07-09 02:10:39 +02:00
Stephan Bönnemann
6d84b66c05 test(test-module): creates integration test env on disk 2015-07-09 02:10:38 +02:00
Stephan Bönnemann
4d58af7145 test(base-scenario): creates nixt testing base 2015-07-09 02:10:38 +02:00
Stephan Bönnemann
32c1dcf75b test(registry): lib to start and stop an npm-registry-couchapp 2015-07-09 02:10:38 +02:00
Stephan Bönnemann
057e8e9759 feat(plugins): normalize plugins and have unified function signature 2015-06-18 16:48:28 -07:00