Compare commits
@@ -68,9 +68,9 @@ Here is an example of the release type that will be done based on a commit messa
|
||||
|
||||
### Triggering a release
|
||||
|
||||
When pushing new commits to the release branch (i.e. `master`) with `git push` or by merging a pull request or merging from another branch, a CI build is triggered and runs the `semantic-release` command to make a release if there are relevant codebase changes since the last release.
|
||||
For each new commits added to the release branch (i.e. `master`) with `git push` or by merging a pull request or merging from another branch, a CI build is triggered and runs the `semantic-release` command to make a release if there are codebase changes since the last release that affect the package functionalities.
|
||||
|
||||
By default a release will be done for each push to the release branch that contains relevant code changes. If you need more control over the timing of releases you have a couple of options:
|
||||
If you need more control over the timing of releases you have a couple of options:
|
||||
- Publish releases on a distribution channel (for example npm’s [dist-tags](https://docs.npmjs.com/cli/dist-tag)). This way you can keep control over what your users end up using by default, and you can decide when to make an automatically released version available to the stable channel, and promote it.
|
||||
- Develop on a `dev` branch and merge it to the release branch (i.e. `master`) once you are ready to publish. **semantic-release** will run only on pushes to the release branch.
|
||||
|
||||
@@ -83,11 +83,11 @@ After running the tests the command `semantic-release` will execute the followin
|
||||
| Verify Conditions | Verify all the conditions to proceed with the release with the [verify conditions plugins](docs/usage/plugins.md#verifyconditions-plugin). |
|
||||
| Get last release | Obtain the commit corresponding to the last release by analyzing [Git tags](https://git-scm.com/book/en/v2/Git-Basics-Tagging). |
|
||||
| Analyze commits | Determine the type of release with the [analyze commits plugin](docs/usage/plugins.md#analyzecommits-plugin) based on the commits added since the last release. |
|
||||
| Verify release | Verify the release conformity with the [verify release plugins](docs/usage/plugins.md#verifyrelease-plugin). |
|
||||
| Verify release | Verify the release conformity with the [verify release plugins](docs/usage/plugins.md#verifyrelease-plugin). |
|
||||
| Generate notes | Generate release notes with the [generate notes plugin](docs/usage/plugins.md#generatenotes-plugin) for the commits added since the last release. |
|
||||
| Create Git tag | Create a Git tag corresponding to the new release version |
|
||||
| Prepare | Prepare the release with the [prepare plugins](docs/usage/plugins.md#prepare-plugin). |
|
||||
| Publish | Publish the release with the [publish plugins](docs/usage/plugins.md#publish-plugin). |
|
||||
| Prepare | Prepare the release with the [prepare plugins](docs/usage/plugins.md#prepare-plugin). |
|
||||
| Publish | Publish the release with the [publish plugins](docs/usage/plugins.md#publish-plugin). |
|
||||
| Notify | Notify of new releases or errors with the [success](docs/usage/plugins.md#success-plugin) and [fail](docs/usage/plugins.md#fail-plugin) plugins. |
|
||||
|
||||
## Documentation
|
||||
|
||||
+20
-1
@@ -3,11 +3,15 @@
|
||||
// Bad news: We have to write plain ES5 in this file
|
||||
// Good news: It's the only file of the entire project
|
||||
|
||||
/* eslint-disable no-var */
|
||||
/* eslint-disable no-var, promise/prefer-await-to-then, prefer-destructuring */
|
||||
|
||||
var semver = require('semver');
|
||||
var execa = require('execa');
|
||||
var findVersions = require('find-versions');
|
||||
var pkg = require('../package.json');
|
||||
|
||||
var MIN_GIT_VERSION = '2.0.0';
|
||||
|
||||
if (!semver.satisfies(process.version, pkg.engines.node)) {
|
||||
console.error(
|
||||
`[semantic-release]: node version ${pkg.engines.node} is required. Found ${process.version}.
|
||||
@@ -17,6 +21,21 @@ See https://github.com/semantic-release/semantic-release/blob/caribou/docs/suppo
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
execa
|
||||
.stdout('git', ['--version'])
|
||||
.then(stdout => {
|
||||
var gitVersion = findVersions(stdout)[0];
|
||||
if (semver.lt(gitVersion, MIN_GIT_VERSION)) {
|
||||
console.error(`[semantic-release]: Git version ${MIN_GIT_VERSION} is required. Found ${gitVersion}.`);
|
||||
process.exit(1);
|
||||
}
|
||||
})
|
||||
.catch(err => {
|
||||
console.error(`[semantic-release]: Git version ${MIN_GIT_VERSION} is required. No git binary found.`);
|
||||
console.error(err);
|
||||
process.exit(1);
|
||||
});
|
||||
|
||||
// Node 8+ from this point on
|
||||
require('../cli')().catch(() => {
|
||||
process.exitCode = 1;
|
||||
|
||||
@@ -37,9 +37,13 @@
|
||||
|
||||
[Open a Pull Request](https://github.com/semantic-release/semantic-release/blob/caribou/CONTRIBUTING.md#submitting-a-pull-request) to add your plugin to the list.
|
||||
|
||||
- [semantic-release-docker](https://github.com/felixfbecker/semantic-release-docker) Set of semantic-release plugins for publishing a docker image to Docker Hub (tested on semantic-release **^11.0.0**)
|
||||
- [semantic-release-docker](https://github.com/felixfbecker/semantic-release-docker) Set of semantic-release plugins for publishing a docker image to Docker Hub
|
||||
- [verifyConditions](https://github.com/felixfbecker/semantic-release-docker#verifyconditions) Verify that all needed configuration is present and login to the Docker registry.
|
||||
- [publish](https://github.com/felixfbecker/semantic-release-docker#publish) Tag the image specified by `name` with the new version, push it to Docker Hub and update the latest tag.
|
||||
- [semantic-release-vsce](https://github.com/raix/semantic-release-vsce) Set of semantic-release plugins for publishing Visual Studio Code extensions to the marketplace
|
||||
- **verifyConditions** Verify the presence and the validity of the vsce authentication and release configuration
|
||||
- **prepare** Create a `.vsix` for distribution
|
||||
- **publish** Publish the package to the Visual Studio Code marketplace
|
||||
- [semantic-release-verify-deps](https://github.com/piercus/semantic-release-verify-deps)
|
||||
- [verifyConditions](https://github.com/piercus/semantic-release-verify-deps) Check the dependencies format against a regexp before a release
|
||||
- [semantic-release-chrome](https://github.com/GabrielDuarteM/semantic-release-chrome) Set of semantic-release plugins for publishing a Chrome extension release.
|
||||
|
||||
+18
-1
@@ -164,6 +164,21 @@ You can trigger a release by pushing to your Git repository. You deliberately ca
|
||||
|
||||
Yes, every commits that contains `[skip release]` or `[release skip]` in their message will be excluded from the commit analysis and won't participate in the release type determination.
|
||||
|
||||
## How can I change the type of commits that trigger a release?
|
||||
|
||||
By default **semantic-release** uses the [Angular Commit Message Conventions](https://github.com/angular/angular.js/blob/master/DEVELOPERS.md#-git-commit-guidelines) and triggers releases based on the following rules:
|
||||
|
||||
| Commit | Release type |
|
||||
|-----------------------------|----------------------------|
|
||||
| Commit with breaking change | ~~Major~~ Breaking release |
|
||||
| Commit with type `feat` | ~~Minor~~ Feature release |
|
||||
| Commit with type `fix` | Patch release |
|
||||
| Commit with type `perf` | Patch release |
|
||||
|
||||
See the [`@semantic-release/npm`](https://github.com/semantic-release/npm#npm-configuration) plugin documentation for more details.
|
||||
|
||||
This is fully customizable with the [`@semantic-release/commit-analyzer`](https://github.com/semantic-release/commit-analyzer) plugin's [`release-rules` option](https://github.com/semantic-release/commit-analyzer#release-rules).
|
||||
|
||||
## Is it *really* a good idea to release on every push?
|
||||
|
||||
It is indeed a great idea because it *forces* you to follow best practices. If you don’t feel comfortable releasing every feature or fix on your `master` you might not treat your `master` branch as intended.
|
||||
@@ -174,6 +189,8 @@ From [Understanding the GitHub Flow](https://guides.github.com/introduction/flow
|
||||
|
||||
If you need more control over the timing of releases, see [Triggering a release](../../README.md#triggering-a-release) for different options.
|
||||
|
||||
**Note**: Only the codebase changes altering the published package will trigger a release (for example new features, bug fixes or performance improvements would trigger a release while refactoring or changing code style would not). See [How can I change the type of commits that trigger a release?](#how-can-i-change-the-type-of-commits-that-trigger-a-release) for more details.
|
||||
|
||||
## Can I set the initial release version of my package to `0.0.1`?
|
||||
|
||||
This is not supported by **semantic-release** as it's not considered a good practice, mostly because [Semantic Versioning](https://semver.org) rules applies differently to major version zero.
|
||||
@@ -194,7 +211,7 @@ In addition the [verify conditions step](../../README.md#release-steps) verifies
|
||||
|
||||
See [Node version requirement](../support/node-version.md#node-version-requirement) for more details and solutions.
|
||||
|
||||
# What is npx?
|
||||
## What is npx?
|
||||
|
||||
[`npx`](https://www.npmjs.com/package/npx) – short for "npm exec" – is a CLI to find and execute npm binaries within the local `node_modules` folder or in the $PATH. If a binary can't be located npx will download the required package and execute it from its cache location.
|
||||
The tool is bundled with [npm](https://www.npmjs.com/package/npm) >= 5.2, or can be installed via `npm install -g npx`.
|
||||
|
||||
@@ -44,3 +44,13 @@ npm ERR! You do not have permission to publish "<package-name>". Are you logged
|
||||
This message is a little unclear, and might not have anything to with your `NPM_TOKEN` or authentication method. It might instead be related to the package name itself. If there is already a package with the same name as yours or, there is a very close match, it could trigger this error.
|
||||
|
||||
Best way to be sure, is to search [npmjs.org](https://www.npmjs.com/)) using your package name. If there is a name conflict, rename your package in your `package.json`
|
||||
|
||||
## Squashed commits are ignored by **semantic-release**
|
||||
|
||||
**semantic-release** parses commits according to a [commit message convention](https://github.com/semantic-release/semantic-release#commit-message-format) to figure out how they affect the codebase. Commits that doesn't follow the project's commit message convention are simply ignored.
|
||||
|
||||
When [squashing commits](https://git-scm.com/book/en/v2/Git-Tools-Rewriting-History#_squashing) most Git tools will by default generate a new commit message with a summary of the squashed commits. This commit message will most likely not be compliant with the project's commit message convention and therefore will be ignored by **semantic-release**.
|
||||
|
||||
When squashing commits make sure to rewrite the resulting commit message to be compliant with the project's commit message convention.
|
||||
|
||||
**Note**: if the resulting squashed commit would encompasses multiple changes (for example multiple unrelated features or fixes) then it's probably not a good idea to squash those commits together. A commit should contain exactly one self-contained functional change and a functional change should be contained in exactly one commit. See [atomic commits](https://en.wikipedia.org/wiki/Atomic_commit).
|
||||
|
||||
@@ -6,7 +6,7 @@ In order to customize **semantic-release**’s behavior, [options](#options) and
|
||||
- A `release` key in the project's `package.json` file
|
||||
- CLI arguments
|
||||
|
||||
The following two examples are the same.
|
||||
The following three examples are the same.
|
||||
|
||||
Via CLI argument:
|
||||
|
||||
@@ -17,7 +17,20 @@ $ semantic-release --branch next
|
||||
Via `release` key in the project's `package.json` file:
|
||||
|
||||
```json
|
||||
"release": {
|
||||
{
|
||||
"release": {
|
||||
"branch": "next"
|
||||
}
|
||||
}
|
||||
```
|
||||
```bash
|
||||
$ semantic-release
|
||||
```
|
||||
|
||||
Via `.releaserc` file:
|
||||
|
||||
```json
|
||||
{
|
||||
"branch": "next"
|
||||
}
|
||||
```
|
||||
@@ -29,6 +42,17 @@ $ semantic-release
|
||||
|
||||
**Note**: Plugin options cannot be defined via CLI arguments and must be defined in the configuration file.
|
||||
|
||||
**Note**: When configuring via `package.json`, the configuration must be under the `release` property. However, when using a `.releaserc` or a `release.config.js` file, the configuration must be set without a `release` property.
|
||||
|
||||
## Environment variables
|
||||
|
||||
| Variable | Description | Default |
|
||||
|-----------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------|
|
||||
| `GIT_AUTHOR_NAME` | The author name associated with the [Git release tag](https://git-scm.com/book/en/v2/Git-Basics-Tagging). See [Git environment variables](https://git-scm.com/book/en/v2/Git-Internals-Environment-Variables#_committing). | @semantic-release-bot. |
|
||||
| `GIT_AUTHOR_EMAIL` | The author email associated with the [Git release tag](https://git-scm.com/book/en/v2/Git-Basics-Tagging). See [Git environment variables](https://git-scm.com/book/en/v2/Git-Internals-Environment-Variables#_committing). | @semantic-release-bot email address. |
|
||||
| `GIT_COMMITTER_NAME` | The committer name associated with the [Git release tag](https://git-scm.com/book/en/v2/Git-Basics-Tagging). See [Git environment variables](https://git-scm.com/book/en/v2/Git-Internals-Environment-Variables#_committing). | @semantic-release-bot. |
|
||||
| `GIT_COMMITTER_EMAIL` | The committer email associated with the [Git release tag](https://git-scm.com/book/en/v2/Git-Basics-Tagging). See [Git environment variables](https://git-scm.com/book/en/v2/Git-Internals-Environment-Variables#_committing). | @semantic-release-bot email address. |
|
||||
|
||||
## Options
|
||||
|
||||
### extends
|
||||
|
||||
@@ -91,7 +91,7 @@ For example:
|
||||
With this configuration:
|
||||
- the `custom-plugin` npm module will be used to [analyze commits](#analyzecommits-plugin)
|
||||
- the `./build/my-plugin.js` script will be used to [generate release notes](#generatenotes-plugin)
|
||||
- the [`@semantic-release/exec`](https://github.com/semantic-release/exec), [`@semantic-release/npm`](https://github.com/semantic-release/npm) and [`@semantic-release/exec`](https://github.com/semantic-release/exec) plugins will be used to [verify conditions](#verifyconditions-plugin)
|
||||
- the [`@semantic-release/exec`](https://github.com/semantic-release/exec), [`@semantic-release/npm`](https://github.com/semantic-release/npm) and [`@semantic-release/github`](https://github.com/semantic-release/github) plugins will be used to [verify conditions](#verifyconditions-plugin)
|
||||
- the [`@semantic-release/exec`](https://github.com/semantic-release/exec) plugin will be used to [verify the release](#verifyrelease-plugin)
|
||||
- the `cmd` option will be set to `verify-conditions.sh` only for the [`@semantic-release/exec`](https://github.com/semantic-release/exec) plugin used to [verify conditions](#verifyconditions-plugin)
|
||||
- the `cmd` option will be set to `verify-release.sh` only for the [`@semantic-release/exec`](https://github.com/semantic-release/exec) plugin used to [verify the release](#verifyrelease-plugin)
|
||||
|
||||
@@ -15,6 +15,7 @@ const getGitAuthUrl = require('./lib/get-git-auth-url');
|
||||
const logger = require('./lib/logger');
|
||||
const {unshallow, verifyAuth, isBranchUpToDate, gitHead: getGitHead, tag, push} = require('./lib/git');
|
||||
const getError = require('./lib/get-error');
|
||||
const {COMMIT_NAME, COMMIT_EMAIL} = require('./lib/definitions/constants');
|
||||
|
||||
marked.setOptions({renderer: new TerminalRenderer()});
|
||||
|
||||
@@ -25,9 +26,16 @@ async function run(options, plugins) {
|
||||
logger.log('This run was not triggered in a known CI environment, running in dry-run mode.');
|
||||
options.dryRun = true;
|
||||
} else {
|
||||
// When running on CI, prevent the `git` CLI to prompt for username/password. See #703.
|
||||
process.env.GIT_ASKPASS = 'echo';
|
||||
process.env.GIT_TERMINAL_PROMPT = 0;
|
||||
// When running on CI, set the commits author and commiter info and prevent the `git` CLI to prompt for username/password. See #703.
|
||||
process.env = {
|
||||
GIT_AUTHOR_NAME: COMMIT_NAME,
|
||||
GIT_AUTHOR_EMAIL: COMMIT_EMAIL,
|
||||
GIT_COMMITTER_NAME: COMMIT_NAME,
|
||||
GIT_COMMITTER_EMAIL: COMMIT_EMAIL,
|
||||
...process.env,
|
||||
GIT_ASKPASS: 'echo',
|
||||
GIT_TERMINAL_PROMPT: 0,
|
||||
};
|
||||
}
|
||||
|
||||
if (isCi && isPr && !options.noCi) {
|
||||
@@ -48,17 +56,16 @@ async function run(options, plugins) {
|
||||
|
||||
options.repositoryUrl = await getGitAuthUrl(options);
|
||||
|
||||
if (!(await isBranchUpToDate(options.branch))) {
|
||||
logger.log(
|
||||
"The local branch %s is behind the remote one, therefore a new version won't be published.",
|
||||
options.branch
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
await verifyAuth(options.repositoryUrl, options.branch);
|
||||
} catch (err) {
|
||||
if (!(await isBranchUpToDate(options.repositoryUrl, options.branch))) {
|
||||
logger.log(
|
||||
"The local branch %s is behind the remote one, therefore a new version won't be published.",
|
||||
options.branch
|
||||
);
|
||||
return false;
|
||||
}
|
||||
logger.error(`The command "${err.cmd}" failed with the error message %s.`, err.stderr);
|
||||
throw getError('EGITNOPERMISSION', {options});
|
||||
}
|
||||
@@ -170,7 +177,7 @@ async function callFail(plugins, options, error) {
|
||||
|
||||
module.exports = async opts => {
|
||||
logger.log(`Running %s version %s`, pkg.name, pkg.version);
|
||||
const unhook = hookStd({silent: false}, hideSensitive);
|
||||
const {unhook} = hookStd({silent: false}, hideSensitive);
|
||||
try {
|
||||
const config = await getConfig(opts, logger);
|
||||
const {plugins, options} = config;
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
const RELEASE_TYPE = ['major', 'premajor', 'minor', 'preminor', 'patch', 'prepatch', 'prerelease'];
|
||||
|
||||
const FIRST_RELEASE = '1.0.0';
|
||||
|
||||
const COMMIT_NAME = 'semantic-release-bot';
|
||||
|
||||
const COMMIT_EMAIL = 'semantic-release-bot@martynus.net';
|
||||
|
||||
module.exports = {RELEASE_TYPE, FIRST_RELEASE, COMMIT_NAME, COMMIT_EMAIL};
|
||||
@@ -2,7 +2,7 @@ const url = require('url');
|
||||
const {inspect} = require('util');
|
||||
const {toLower, isString} = require('lodash');
|
||||
const pkg = require('../../package.json');
|
||||
const RELEASE_TYPE = require('./release-types');
|
||||
const {RELEASE_TYPE} = require('./constants');
|
||||
|
||||
const homepage = url.format({...url.parse(pkg.homepage), ...{hash: null}});
|
||||
const stringify = obj => (isString(obj) ? obj : inspect(obj, {breakLength: Infinity, depth: 2, maxArrayLength: 5}));
|
||||
@@ -31,11 +31,13 @@ Please make sure to add the \`repositoryUrl\` to the [semantic-release configura
|
||||
message: 'The push permission to the Git repository is required.',
|
||||
details: `**semantic-release** cannot push the version tag to the branch \`${
|
||||
options.branch
|
||||
}\` on remote Git repository.
|
||||
}\` on remote Git repository with URL \`${options.repositoryUrl}\`.
|
||||
|
||||
Please refer to the [authentication configuration documentation](${linkify(
|
||||
'docs/usage/ci-configuration.md#authentication'
|
||||
)}) to configure the Git credentials on your CI environment.`,
|
||||
)}) to configure the Git credentials on your CI environment and make sure the [repositoryUrl](${linkify(
|
||||
'docs/usage/configuration.md#repositoryurl'
|
||||
)}) is configured with a [valid Git URL](https://git-scm.com/book/en/v2/Git-on-the-Server-The-Protocols).`,
|
||||
}),
|
||||
EINVALIDTAGFORMAT: ({tagFormat}) => ({
|
||||
message: 'Invalid `tagFormat` option.',
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const {isString, isFunction, isArray, isPlainObject} = require('lodash');
|
||||
const RELEASE_TYPE = require('./release-types');
|
||||
const {RELEASE_TYPE} = require('./constants');
|
||||
|
||||
const validatePluginConfig = conf => isString(conf) || isString(conf.path) || isFunction(conf);
|
||||
|
||||
@@ -45,7 +45,7 @@ module.exports = {
|
||||
publish: {
|
||||
default: ['@semantic-release/npm', '@semantic-release/github'],
|
||||
config: {
|
||||
validator: conf => Boolean(conf) && (isArray(conf) ? conf : [conf]).every(conf => validatePluginConfig(conf)),
|
||||
validator: conf => !conf || (isArray(conf) ? conf : [conf]).every(conf => validatePluginConfig(conf)),
|
||||
},
|
||||
output: {
|
||||
validator: output => !output || isPlainObject(output),
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
module.exports = ['major', 'premajor', 'minor', 'preminor', 'patch', 'prepatch', 'prerelease'];
|
||||
@@ -1,4 +1,5 @@
|
||||
const semver = require('semver');
|
||||
const {FIRST_RELEASE} = require('./definitions/constants');
|
||||
|
||||
module.exports = (type, lastRelease, logger) => {
|
||||
let version;
|
||||
@@ -6,7 +7,7 @@ module.exports = (type, lastRelease, logger) => {
|
||||
version = semver.inc(lastRelease.version, type);
|
||||
logger.log('The next release version is %s', version);
|
||||
} else {
|
||||
version = '1.0.0';
|
||||
version = FIRST_RELEASE;
|
||||
logger.log('There is no previous release, the next release version is %s', version);
|
||||
}
|
||||
|
||||
|
||||
+11
-4
@@ -69,7 +69,7 @@ async function gitHead() {
|
||||
*/
|
||||
async function repoUrl() {
|
||||
try {
|
||||
return await execa.stdout('git', ['remote', 'get-url', 'origin']);
|
||||
return await execa.stdout('git', ['config', '--get', 'remote.origin.url']);
|
||||
} catch (err) {
|
||||
debug(err);
|
||||
}
|
||||
@@ -141,12 +141,19 @@ async function verifyTagName(tagName) {
|
||||
/**
|
||||
* Verify the local branch is up to date with the remote one.
|
||||
*
|
||||
* @param {String} repositoryUrl The remote repository URL.
|
||||
* @param {String} branch The repository branch for which to verify status.
|
||||
*
|
||||
* @return {Boolean} `true` is the HEAD of the current local branch is the same as the HEAD of the remote branch, `false` otherwise.
|
||||
* @return {Boolean} `true` is the HEAD of the current local branch is the same as the HEAD of the remote branch, falsy otherwise.
|
||||
*/
|
||||
async function isBranchUpToDate(branch) {
|
||||
return isRefInHistory(await execa.stdout('git', ['rev-parse', `${branch}@{u}`]));
|
||||
async function isBranchUpToDate(repositoryUrl, branch) {
|
||||
try {
|
||||
return await isRefInHistory(
|
||||
(await execa.stdout('git', ['ls-remote', '--heads', repositoryUrl, branch])).match(/^(\w+)?/)[1]
|
||||
);
|
||||
} catch (err) {
|
||||
debug(err);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
||||
@@ -15,9 +15,9 @@ module.exports = (pluginType, pluginsPath, globalOpts, pluginOpts, logger) => {
|
||||
|
||||
if (!isFunction(pluginOpts)) {
|
||||
if (pluginsPath[path]) {
|
||||
logger.log('Load plugin %s from %s in shareable config %s', pluginType, path, pluginsPath[path]);
|
||||
logger.log('Load plugin "%s" from %s in shareable config %s', pluginType, path, pluginsPath[path]);
|
||||
} else {
|
||||
logger.log('Load plugin %s from %s', pluginType, path);
|
||||
logger.log('Load plugin "%s" from %s', pluginType, path);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+9
-8
@@ -30,17 +30,18 @@
|
||||
"debug": "^3.1.0",
|
||||
"env-ci": "^2.0.0",
|
||||
"execa": "^0.10.0",
|
||||
"find-versions": "^2.0.0",
|
||||
"get-stream": "^3.0.0",
|
||||
"git-log-parser": "^1.2.0",
|
||||
"git-url-parse": "^9.0.0",
|
||||
"hook-std": "^0.4.0",
|
||||
"hook-std": "^1.0.1",
|
||||
"hosted-git-info": "^2.6.0",
|
||||
"lodash": "^4.17.4",
|
||||
"marked": "^0.3.9",
|
||||
"marked-terminal": "^2.0.0",
|
||||
"p-locate": "^2.0.0",
|
||||
"marked": "^0.4.0",
|
||||
"marked-terminal": "^3.0.0",
|
||||
"p-locate": "^3.0.0",
|
||||
"p-reduce": "^1.0.0",
|
||||
"read-pkg-up": "^3.0.0",
|
||||
"read-pkg-up": "^4.0.0",
|
||||
"resolve-from": "^4.0.0",
|
||||
"semver": "^5.4.1",
|
||||
"yargs": "^11.0.0"
|
||||
@@ -51,7 +52,7 @@
|
||||
"codecov": "^3.0.0",
|
||||
"commitizen": "^2.9.6",
|
||||
"cz-conventional-changelog": "^2.0.0",
|
||||
"delay": "^2.0.0",
|
||||
"delay": "^3.0.0",
|
||||
"dockerode": "^2.5.2",
|
||||
"file-url": "^2.0.2",
|
||||
"fs-extra": "^6.0.0",
|
||||
@@ -59,10 +60,10 @@
|
||||
"js-yaml": "^3.10.0",
|
||||
"mockserver-client": "^5.1.1",
|
||||
"nock": "^9.0.2",
|
||||
"nyc": "^11.2.1",
|
||||
"nyc": "^12.0.1",
|
||||
"p-retry": "^2.0.0",
|
||||
"proxyquire": "^2.0.0",
|
||||
"sinon": "^5.0.1",
|
||||
"sinon": "^6.0.0",
|
||||
"tempy": "^0.2.1",
|
||||
"xo": "^0.21.0"
|
||||
},
|
||||
|
||||
@@ -60,9 +60,9 @@ test('The "prepare" plugin, if defined, must be a single or an array of plugins
|
||||
test('The "publish" plugin is mandatory, and must be a single or an array of plugins definition', t => {
|
||||
t.false(plugins.publish.config.validator({}));
|
||||
t.false(plugins.publish.config.validator({path: null}));
|
||||
t.false(plugins.publish.config.validator());
|
||||
|
||||
t.true(plugins.publish.config.validator({path: 'plugin-path.js'}));
|
||||
t.true(plugins.publish.config.validator());
|
||||
t.true(plugins.publish.config.validator('plugin-path.js'));
|
||||
t.true(plugins.publish.config.validator(() => {}));
|
||||
t.true(plugins.publish.config.validator([{path: 'plugin-path.js'}, 'plugin-path.js', () => {}]));
|
||||
|
||||
+12
-9
@@ -24,7 +24,6 @@ import {
|
||||
gitCommitTag,
|
||||
gitRemoteTagHead,
|
||||
push as pushUtil,
|
||||
reset,
|
||||
} from './helpers/git-utils';
|
||||
|
||||
// Save the current working diretory
|
||||
@@ -189,31 +188,35 @@ test.serial('Throws error if obtaining the tags fails', async t => {
|
||||
});
|
||||
|
||||
test.serial('Return "true" if repository is up to date', async t => {
|
||||
await gitRepo(true);
|
||||
const repositoryUrl = await gitRepo(true);
|
||||
await gitCommits(['First']);
|
||||
await pushUtil();
|
||||
|
||||
t.true(await isBranchUpToDate('master'));
|
||||
t.true(await isBranchUpToDate(repositoryUrl, 'master'));
|
||||
});
|
||||
|
||||
test.serial('Return falsy if repository is not up to date', async t => {
|
||||
await gitRepo(true);
|
||||
const repositoryUrl = await gitRepo(true);
|
||||
const repoDir = process.cwd();
|
||||
await gitCommits(['First']);
|
||||
await gitCommits(['Second']);
|
||||
await pushUtil();
|
||||
|
||||
t.true(await isBranchUpToDate('master'));
|
||||
t.true(await isBranchUpToDate(repositoryUrl, 'master'));
|
||||
|
||||
await reset();
|
||||
await gitShallowClone(repositoryUrl);
|
||||
await gitCommits(['Third']);
|
||||
await pushUtil();
|
||||
process.chdir(repoDir);
|
||||
|
||||
t.falsy(await isBranchUpToDate('master'));
|
||||
t.falsy(await isBranchUpToDate(repositoryUrl, 'master'));
|
||||
});
|
||||
|
||||
test.serial('Return "true" if local repository is ahead', async t => {
|
||||
await gitRepo(true);
|
||||
const repositoryUrl = await gitRepo(true);
|
||||
await gitCommits(['First']);
|
||||
await pushUtil();
|
||||
await gitCommits(['Second']);
|
||||
|
||||
t.true(await isBranchUpToDate('master'));
|
||||
t.true(await isBranchUpToDate(repositoryUrl, 'master'));
|
||||
});
|
||||
|
||||
@@ -212,12 +212,3 @@ export async function gitCommitTag(gitHead) {
|
||||
export async function push(repositoryUrl = 'origin', branch = 'master') {
|
||||
await execa('git', ['push', '--tags', repositoryUrl, `HEAD:${branch}`]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset repository to a commit.
|
||||
*
|
||||
* @param {String} [commit='HEAD~1'] Commit reference to reset the repo to.
|
||||
*/
|
||||
export async function reset(commit = 'HEAD~1') {
|
||||
await execa('git', ['reset', commit]);
|
||||
}
|
||||
|
||||
+12
-2
@@ -5,6 +5,7 @@ import clearModule from 'clear-module';
|
||||
import AggregateError from 'aggregate-error';
|
||||
import SemanticReleaseError from '@semantic-release/error';
|
||||
import DEFINITIONS from '../lib/definitions/plugins';
|
||||
import {COMMIT_NAME, COMMIT_EMAIL} from '../lib/definitions/constants';
|
||||
import {
|
||||
gitHead as getGitHead,
|
||||
gitTagHead,
|
||||
@@ -14,7 +15,6 @@ import {
|
||||
gitRemoteTagHead,
|
||||
push,
|
||||
gitShallowClone,
|
||||
reset,
|
||||
} from './helpers/git-utils';
|
||||
|
||||
// Save the current process.env
|
||||
@@ -157,6 +157,12 @@ test.serial('Plugins are called with expected values', async t => {
|
||||
// Verify the tag has been created on the local and remote repo and reference the gitHead
|
||||
t.is(await gitTagHead(nextRelease.gitTag), nextRelease.gitHead);
|
||||
t.is(await gitRemoteTagHead(repositoryUrl, nextRelease.gitTag), nextRelease.gitHead);
|
||||
|
||||
// Verify the author/commiter name and email hve been set
|
||||
t.is(process.env.GIT_AUTHOR_NAME, COMMIT_NAME);
|
||||
t.is(process.env.GIT_AUTHOR_EMAIL, COMMIT_EMAIL);
|
||||
t.is(process.env.GIT_COMMITTER_NAME, COMMIT_NAME);
|
||||
t.is(process.env.GIT_COMMITTER_EMAIL, COMMIT_EMAIL);
|
||||
});
|
||||
|
||||
test.serial('Use custom tag format', async t => {
|
||||
@@ -638,11 +644,15 @@ test.serial('Returns falsy value if triggered by a PR', async t => {
|
||||
test.serial('Returns falsy value if triggered on an outdated clone', async t => {
|
||||
// Create a git repository, set the current working directory at the root of the repo
|
||||
const repositoryUrl = await gitRepo(true);
|
||||
const repoDir = process.cwd();
|
||||
// Add commits to the master branch
|
||||
await gitCommits(['First']);
|
||||
await gitCommits(['Second']);
|
||||
await push();
|
||||
await reset();
|
||||
await gitShallowClone(repositoryUrl);
|
||||
await gitCommits(['Third']);
|
||||
await push();
|
||||
process.chdir(repoDir);
|
||||
|
||||
const semanticRelease = proxyquire('..', {
|
||||
'./lib/logger': t.context.logger,
|
||||
|
||||
@@ -2,7 +2,7 @@ import test from 'ava';
|
||||
import {writeJson, readJson} from 'fs-extra';
|
||||
import {stub} from 'sinon';
|
||||
import execa from 'execa';
|
||||
import {gitHead as getGitHead, gitTagHead, gitRepo, gitCommits, gitRemoteTagHead} from './helpers/git-utils';
|
||||
import {gitHead as getGitHead, gitTagHead, gitRepo, gitCommits, gitRemoteTagHead, push} from './helpers/git-utils';
|
||||
import gitbox from './helpers/gitbox';
|
||||
import mockServer from './helpers/mockserver';
|
||||
import npmRegistry from './helpers/npm-registry';
|
||||
@@ -609,6 +609,7 @@ test.serial('Exit with 1 if missing permission to push to the remote repository'
|
||||
/* Initial release */
|
||||
t.log('Commit a feature');
|
||||
await gitCommits(['feat: Initial commit']);
|
||||
await push();
|
||||
t.log('$ semantic-release');
|
||||
const {stdout, code} = await execa(
|
||||
cli,
|
||||
|
||||
@@ -14,7 +14,7 @@ test('Normalize and load plugin from string', t => {
|
||||
|
||||
t.is(plugin.pluginName, './test/fixtures/plugin-noop');
|
||||
t.is(typeof plugin, 'function');
|
||||
t.deepEqual(t.context.log.args[0], ['Load plugin %s from %s', 'verifyConditions', './test/fixtures/plugin-noop']);
|
||||
t.deepEqual(t.context.log.args[0], ['Load plugin "%s" from %s', 'verifyConditions', './test/fixtures/plugin-noop']);
|
||||
});
|
||||
|
||||
test('Normalize and load plugin from object', t => {
|
||||
@@ -22,7 +22,7 @@ test('Normalize and load plugin from object', t => {
|
||||
|
||||
t.is(plugin.pluginName, './test/fixtures/plugin-noop');
|
||||
t.is(typeof plugin, 'function');
|
||||
t.deepEqual(t.context.log.args[0], ['Load plugin %s from %s', 'publish', './test/fixtures/plugin-noop']);
|
||||
t.deepEqual(t.context.log.args[0], ['Load plugin "%s" from %s', 'publish', './test/fixtures/plugin-noop']);
|
||||
});
|
||||
|
||||
test('Normalize and load plugin from a base file path', t => {
|
||||
@@ -37,7 +37,7 @@ test('Normalize and load plugin from a base file path', t => {
|
||||
t.is(plugin.pluginName, './plugin-noop');
|
||||
t.is(typeof plugin, 'function');
|
||||
t.deepEqual(t.context.log.args[0], [
|
||||
'Load plugin %s from %s in shareable config %s',
|
||||
'Load plugin "%s" from %s in shareable config %s',
|
||||
'verifyConditions',
|
||||
'./plugin-noop',
|
||||
'./test/fixtures',
|
||||
@@ -85,7 +85,7 @@ test('Normalize and load plugin that retuns multiple functions', t => {
|
||||
const plugin = normalize('verifyConditions', {}, {}, './test/fixtures/multi-plugin', t.context.logger);
|
||||
|
||||
t.is(typeof plugin, 'function');
|
||||
t.deepEqual(t.context.log.args[0], ['Load plugin %s from %s', 'verifyConditions', './test/fixtures/multi-plugin']);
|
||||
t.deepEqual(t.context.log.args[0], ['Load plugin "%s" from %s', 'verifyConditions', './test/fixtures/multi-plugin']);
|
||||
});
|
||||
|
||||
test('Wrap "analyzeCommits" plugin in a function that validate the output of the plugin', async t => {
|
||||
|
||||
Reference in New Issue
Block a user