Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cb1f80cb56 | ||
|
|
7c9ec41dd7 | ||
|
|
a1138a6a80 | ||
|
|
6172eb807c | ||
|
|
31ad23125a | ||
|
|
a8a07b7d51 |
@@ -34,3 +34,11 @@
|
||||
- [fail](https://github.com/semantic-release/exec#fail): Execute a shell command to notify of a failed release
|
||||
|
||||
## Community plugins
|
||||
|
||||
[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**)
|
||||
- [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-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
|
||||
|
||||
+31
-2
@@ -57,7 +57,36 @@ To publish a non-Node package (without a `package.json`) you would need to:
|
||||
- Set **semantic-release** [options](../usage/configuration.md#options) via [CLI arguments or rc file](../usage/configuration.md#configuration)
|
||||
- Make sure your CI job executing the `semantic-release` command has access to [Node >= 8](#why-does-semantic-release-require-node-version--83) to execute the `semantic-release` command
|
||||
|
||||
See the [CI configuration recipes](../usage/ci-configuration.md) for more details on specific CI environments.
|
||||
See the [CI configuration recipes](../recipes/README.md#ci-configurations) for more details on specific CI environments.
|
||||
|
||||
In addition you will need to configure the **semantic-release** [plugins](../usage/plugins.md#plugins) to:
|
||||
- Disable the [`@semantic-release/npm`](https://github.com/semantic-release/npm) plugin
|
||||
- Define plugins for the [verifyConditions](../usage/plugins.md#verifyconditions-plugin), [prepare](../usage/plugins.md#prepare-plugin) and [publish](../usage/plugins.md#publish-plugin) steps to release on your package registry. The [`@semantic-release/exec`](https://github.com/semantic-release/exec) plugin is recommended for situation where a release can be done with a shell command.
|
||||
|
||||
Here is a basic example to create [GitHub releases](https://help.github.com/articles/about-releases) and use shell command to publish:
|
||||
|
||||
```json
|
||||
{
|
||||
"verifyConditions": ["@semantic-release/github"],
|
||||
"prepare": [
|
||||
{
|
||||
"path": "@semantic-release/exec",
|
||||
"cmd": "set-version ${nextRelease.version}"
|
||||
}
|
||||
],
|
||||
"publish": [
|
||||
"@semantic-release/github",
|
||||
{
|
||||
"path": "@semantic-release/exec",
|
||||
"cmd": "publish-package"
|
||||
}
|
||||
],
|
||||
}
|
||||
```
|
||||
|
||||
**Note**: This is a theoretical example where the command `set-version` update the project version with the value passed as its first argument and `publish-package` publishes the package to a registry.
|
||||
|
||||
See the [package managers and languages recipes](../recipes/README.md#package-managers-and-languages) for more details on specific project types.
|
||||
|
||||
## Can I use semantic-release with any CI service?
|
||||
|
||||
@@ -65,7 +94,7 @@ Yes, **semantic-release** can be used with any CI service, as long as it provide
|
||||
- A way to set [authentication](../usage/ci-configuration.md#authentication) via environment variables
|
||||
- A way to guarantee that the `semantic-release` command is [executed only after all the tests of all the jobs in the CI build pass](../usage/ci-configuration.md#run-semantic-release-only-after-all-tests-succeeded)
|
||||
|
||||
See the [CI configuration recipes](../usage/ci-configuration.md) for more details on specific CI environments.
|
||||
See the [CI configuration recipes](../recipes/README.md#ci-configurations) for more details on specific CI environments.
|
||||
|
||||
## Can I run semantic-release on my local machine rather than on a CI server?
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ See [CI configuration recipes](../recipes/README.md#ci-configurations) for more
|
||||
|
||||
Alternatively the Git authentication can be set up via [SSH keys](../recipes/git-auth-ssh-keys.md).
|
||||
|
||||
Most **semantic-release** [plugins](plugins.md) require setting up authentication in order to publish to a package manager registry. The default [npm](https://github.com/semantic-release/npm#environment-variables) and [github](https://github.com/semantic-release/github#environment-variables) plugins require the following environment variables:
|
||||
Most **semantic-release** [plugins](plugins.md) require setting up authentication in order to publish to a package manager registry. The default [@semantic-release/npm](https://github.com/semantic-release/npm#environment-variables) and [@semantic-release/github](https://github.com/semantic-release/github#environment-variables) plugins require the following environment variables:
|
||||
|
||||
| Variable | Description |
|
||||
|-------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
|
||||
@@ -8,7 +8,7 @@ Each [release step](../../README.md#release-steps) is implemented within a plugi
|
||||
|
||||
Responsible for verifying conditions necessary to proceed with the release: configuration is correct, authentication token are valid, etc...
|
||||
|
||||
Default implementation: [npm](https://github.com/semantic-release/npm#verifyconditions) and [github](https://github.com/semantic-release/github#verifyconditions).
|
||||
Default implementation: [@semantic-release/npm](https://github.com/semantic-release/npm#verifyconditions) and [@semantic-release/github](https://github.com/semantic-release/github#verifyconditions).
|
||||
|
||||
### analyzeCommits plugin
|
||||
|
||||
@@ -34,25 +34,25 @@ Responsible for preparing the release, including:
|
||||
- Creating or updating files such as `package.json`, `CHANGELOG.md`, documentation or compiled assets.
|
||||
- Create and push commits
|
||||
|
||||
Default implementation: [npm](https://github.com/semantic-release/npm#prepare).
|
||||
Default implementation: [@semantic-release/npm](https://github.com/semantic-release/npm#prepare).
|
||||
|
||||
### publish plugin
|
||||
|
||||
Responsible for publishing the release.
|
||||
|
||||
Default implementation: [npm](https://github.com/semantic-release/npm#publish) and [github](https://github.com/semantic-release/github#publish).
|
||||
Default implementation: [@semantic-release/npm](https://github.com/semantic-release/npm#publish) and [@semantic-release/github](https://github.com/semantic-release/github#publish).
|
||||
|
||||
### success plugin
|
||||
|
||||
Responsible for notifying of a new release.
|
||||
|
||||
Default implementation: [github](https://github.com/semantic-release/github#success).
|
||||
Default implementation: [@semantic-release/github](https://github.com/semantic-release/github#success).
|
||||
|
||||
### fail plugin
|
||||
|
||||
Responsible for notifying of a failed release.
|
||||
|
||||
Default implementation: [github](https://github.com/semantic-release/github#fail).
|
||||
Default implementation: [@semantic-release/github](https://github.com/semantic-release/github#fail).
|
||||
|
||||
## Configuration
|
||||
|
||||
|
||||
@@ -40,13 +40,11 @@ module.exports = async ({repositoryUrl, branch}) => {
|
||||
const gitCredentials = ['GL_TOKEN', 'GITLAB_TOKEN'].includes(envVar)
|
||||
? `gitlab-ci-token:${process.env[envVar]}`
|
||||
: process.env[envVar];
|
||||
const {protocols} = gitUrlParse(repositoryUrl);
|
||||
const {protocols, ...parsed} = gitUrlParse(repositoryUrl);
|
||||
const protocol = protocols.includes('https') ? 'https' : protocols.includes('http') ? 'http' : 'https';
|
||||
|
||||
// If credentials are set via anvironment variables, convert the URL to http/https and add basic auth, otherwise return `repositoryUrl` as is
|
||||
return gitCredentials
|
||||
? format({...parse(`${gitUrlParse(repositoryUrl).toString(protocol)}.git`), ...{auth: gitCredentials}})
|
||||
: repositoryUrl;
|
||||
return gitCredentials ? {...parsed, ...{token: gitCredentials}}.toString(protocol) : repositoryUrl;
|
||||
}
|
||||
return repositoryUrl;
|
||||
};
|
||||
|
||||
@@ -28,7 +28,8 @@ module.exports = async (tagFormat, logger) => {
|
||||
// by replacing the `version` variable in the template by `(.+)`.
|
||||
// The `tagFormat` is compiled with space as the `version` as it's an invalid tag character,
|
||||
// so it's guaranteed to no be present in the `tagFormat`.
|
||||
const tagRegexp = escapeRegExp(template(tagFormat)({version: ' '})).replace(' ', '(.+)');
|
||||
const tagRegexp = `^${escapeRegExp(template(tagFormat)({version: ' '})).replace(' ', '(.+)')}`;
|
||||
|
||||
const tags = (await gitTags())
|
||||
.map(tag => ({gitTag: tag, version: (tag.match(tagRegexp) || new Array(2))[1]}))
|
||||
.filter(
|
||||
|
||||
+1
-1
@@ -32,7 +32,7 @@
|
||||
"execa": "^0.10.0",
|
||||
"get-stream": "^3.0.0",
|
||||
"git-log-parser": "^1.2.0",
|
||||
"git-url-parse": "^8.3.1",
|
||||
"git-url-parse": "^9.0.0",
|
||||
"hook-std": "^0.4.0",
|
||||
"hosted-git-info": "^2.6.0",
|
||||
"lodash": "^4.17.4",
|
||||
|
||||
@@ -37,6 +37,10 @@ test.serial(
|
||||
}
|
||||
);
|
||||
|
||||
test.serial('Do not add trailing ".git" if not present in the origian URL', async t => {
|
||||
t.is(await getAuthUrl({repositoryUrl: 'git@host.null:owner/repo'}), 'git@host.null:owner/repo');
|
||||
});
|
||||
|
||||
test.serial('Handle "https" URL with group and subgroup', async t => {
|
||||
t.is(
|
||||
await getAuthUrl({repositoryUrl: 'https://host.null/group/subgroup/owner/repo.git'}),
|
||||
|
||||
@@ -62,6 +62,19 @@ test.serial('Get the highest tag in the history of the current branch', async t
|
||||
t.deepEqual(result, {gitHead: commits[0].hash, gitTag: 'v2.0.0', version: '2.0.0'});
|
||||
});
|
||||
|
||||
test.serial('Match the tag name from the begining of the string', async t => {
|
||||
// Create a git repository, set the current working directory at the root of the repo
|
||||
await gitRepo();
|
||||
const commits = await gitCommits(['First']);
|
||||
await gitTagVersion('prefix/v1.0.0');
|
||||
await gitTagVersion('prefix/v2.0.0');
|
||||
await gitTagVersion('other-prefix/v3.0.0');
|
||||
|
||||
const result = await getLastRelease(`prefix/v\${version}`, t.context.logger);
|
||||
|
||||
t.deepEqual(result, {gitHead: commits[0].hash, gitTag: 'prefix/v2.0.0', version: '2.0.0'});
|
||||
});
|
||||
|
||||
test.serial('Return empty object if no valid tag is found', async t => {
|
||||
// Create a git repository, set the current working directory at the root of the repo
|
||||
await gitRepo();
|
||||
|
||||
Reference in New Issue
Block a user