feat: make semantic-release CI agnostic
- Remove `@semantic-release/condition-travis` from the default plugins - Verify the current branch in the core - Verify the build is not triggered by a PR in the core - Run in dry-run mode if not triggered on CI - Dry-run mode runs the `verifyConditions` plugins, allowing to detect configuration error locally - Return without error when no version has to be released due to no changes - Return without error if the build is triggered from a PR - Return without error if the current branch is not the configured branch - CLI return with exit code 1 if there is a `semanticReleaseError`, allowing to fail builds in case of config error, missing token etc... BREAKING CHANGE: `semantic-release` doesn't make sure it runs only on one Travis job anymore. The CI configuration has to be done such that `semantic-release` - runs only once per build - runs only after all tests are successful on every jobs of the build - runs on Node >=8 This can easily be done with [travis-deploy-once](https://github.com/semantic-release/travis-deploy-once). Migration Guide Modify your `.travis.yml` to use `travis-deploy-once`. Replace: ```yaml after_success: - npm run semantic-release ``` by: Replace ```yaml after_success: - npm install -g travis-deploy-once@4 - travis-deploy-once "npm run semantic-release" ```
This commit is contained in:
@@ -48,12 +48,10 @@ module.exports = async () => {
|
||||
await require('.')(pickBy(program.opts(), value => !isUndefined(value)));
|
||||
}
|
||||
} catch (err) {
|
||||
// If error is a SemanticReleaseError then it's an expected exception case (no release to be done, running on a PR etc..) and the cli will return with 0
|
||||
// Otherwise it's an unexpected error (configuration issue, code issue, plugin issue etc...) and the cli will return 1
|
||||
process.exitCode = 1;
|
||||
if (err.semanticRelease) {
|
||||
logger.log(`%s ${err.message}`, err.code);
|
||||
} else {
|
||||
process.exitCode = 1;
|
||||
logger.error('An error occurred while running semantic-release: %O', err);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user