docs: documentation improvements

**Refactor and clarify the documentation in `README.md`**
- Add Highlights
- Add a Table of contents
- Clarify the way semantic-release works
- Clarify relationship with the CI environments
- Describe local install for Node projects (with a `package.json`) and global install for non-JavaScript projects
- Explain CI general configuration (environment variables and a run after all jobs are successful)
- Clarify configuration (via config file or CLI arguments)
- Clarify plugin roles and configuration
- Add doc for shareable configuration
- Add recipes
- Add resources (Videos, articles, tutorials)
- Add a Support section
- Add a Team section

**Add the following FAQs**
- How can I use a npm build script that requires the `package.json`’s version ?
- Can I use Semantic-release with Yarn?
- Can I use Semantic-release to publish non-JavaScript packages?
- Can I use Semantic-release with any CI service?
- Can I use Semantic-release with any GitLab?
- Can I use Semantic-release with any Git hosted environment?
- Can I skip the release to the npm registry?
- Can I use .npmrc options?
- How can I set the access level of the published npm package?
- Can I use Semantic-release to publish a package on Artifactory?
- Can I set the initial release version of my package to 0.0.1?
- Why does semantic-release require Node version >= 8?

**Clarify Nove 8 requirement and solutions**
- Add Node version requirement explanation and solutions
- [X] Display a link to the documentation when running on Node < 8 version

**Add recipes**
- Travis
- GitLab CI
- Travis with build stages - To be done in #573
- CircleCI workflows - To be done in #573
This commit is contained in:
Pierre Vanduynslager
2018-01-05 16:05:30 -05:00
parent f4d9ebeef7
commit ed89361d7c
17 changed files with 853 additions and 220 deletions
+7
View File
@@ -0,0 +1,7 @@
# semantic-release documentation
- [Plugins](plugins.md#semantic-release-plugins) - List of semantic-release plugins
- [Shareable configurations](shareable-configurations.md#semantic-release-shareable-configurations) - List of semantic-release shareable configs
- [Developer Guide](developer-guide/README.md#semantic-release-developer-guide) - The essentials of writing a semantic-release plugin or shareable config
- [Recipes](recipes/README.md#semantic-release-recipes) - Community written recipes for common semantic-release use-cases
- [Troubleshooting](troubleshooting.md#troubleshooting-semantic-release) - Community written troubleshooting guide to help with common semantic-release issues
+1
View File
@@ -0,0 +1 @@
# semantic-release Developer Guide
+1
View File
@@ -0,0 +1 @@
# semantic-release plugin development
@@ -0,0 +1 @@
# semantic-release shareable config development
+52
View File
@@ -0,0 +1,52 @@
# Node version requirement
semantic-release is written using the latest [ECMAScript 2017](https://www.ecma-international.org/publications/standards/Ecma-262.htm) features, without transpilation which requires **requires Node version 8 or higher**.
semantic-release is meant to be used in a CI environment as a development support tool, not as a production dependency. Therefore the only constraint is to run the `semantic-release` in a CI environment providing Node 8 or higher.
See our [Node Support Policy](../README.md#node-support-policy) for our long-term promise regarding Node version support.
## Recommended solution
### Run at least one CI job with Node >= 8
The recommended approach is to run the `semantic-release` command from a CI job running on Node 8 or higher. This can either be a job used by your project to test on Node 8 or a dedicated job for the release steps.
See [CI configuration](../README.md#ci-configuration) and [CI configuration recipes](recipes/README.md#ci-configurations) for more details.
## Alternative solutions
### Use `npx`
[`npx`](https://github.com/zkat/npx) is a CLI to execute npm binaries. It is bundled with [npm](https://www.npmjs.com/package/npm) >= 5.4, or can be installed via `npm install -g npx`.
`npx` can be used to download the [Node 8 package published on npm](https://www.npmjs.com/package/node) and use it to execute the `semantic-release` command.
If you are using a [local](../README.md#local-installation) semantic-release installation:
```bash
$ npm install -g npx && npx -p node@8 -c "npm run semantic-release"
```
If you are using a [global](../README.md#global-installation) semantic-release installation:
```bash
# For global semantic-release install
$ npm install -g semantic-release npx && npx -p node@8 -c "semantic-release"
```
### Use `nvm`
If your CI environment provides [nvm](https://github.com/creationix/nvm) you can use it to switch to Node 8 before running the `semantic-release` command.
If you are using a [local](../README.md#local-installation) semantic-release installation:
```bash
$ nvm install 8 && npm run semantic-release
```
If you are using a [global](../README.md#global-installation) semantic-release installation:
```bash
$ nvm install 8 && npm install -g semantic-release && semantic-release
```
+37
View File
@@ -0,0 +1,37 @@
# semantic-release plugins
## Default plugins
- [@semantic-release/github](https://github.com/semantic-release/github)
- [verifyConditions](https://github.com/semantic-release/github#verifyconditions): Verify the presence and the validity of the GitHub authentication and release configuration
- [publish](https://github.com/semantic-release/github#publish): Publish a [GitHub release](https://help.github.com/articles/about-releases)
- [@semantic-release/npm](https://github.com/semantic-release/npm)
- [verifyConditions](https://github.com/semantic-release/npm#verifyconditions): Verify the presence and the validity of the npm authentication and release configuration
- [getLastRelease](https://github.com/semantic-release/npm#getlastrelease): Determine the last release of the package on the npm registry
- [publish](https://github.com/semantic-release/npm#publish): Publish the package on the npm registry
## Official plugins
- [@semantic-release/gitlab](https://github.com/semantic-release/gitlab)
- [verifyConditions](https://github.com/semantic-release/gitlab#verifyconditions): Verify the presence and the validity of the GitLab authentication and release configuration
- [publish](https://github.com/semantic-release/gitlab#publish): Publish a [GitLab release](https://docs.gitlab.com/ce/workflow/releases.html)
- [@semantic-release/git](https://github.com/semantic-release/git)
- [verifyConditions](https://github.com/semantic-release/git#verifyconditions): Verify the presence and the validity of the Git authentication and release configuration
- [getLastRelease](https://github.com/semantic-release/git#getlastrelease): Determine the last release via Git tags on the repository
- [publish](https://github.com/semantic-release/git#publish): Push a release commit and tag, including configurable files
- [@semantic-release/changelog](https://github.com/semantic-release/changelog)
- [verifyConditions](https://github.com/semantic-release/changelog#verifyconditions): Verify the presence and the validity of the configuration
- [publish](https://github.com/semantic-release/changelog#publish): Create or update the changelog file in the local project repository
- [@semantic-release/exec](https://github.com/semantic-release/exec)
- [verifyConditions](https://github.com/semantic-release/exec#verifyconditions): Execute a shell command to verify if the release should happen
- [getLastRelease](https://github.com/semantic-release/exec#getlastrelease): Execute a shell command to determine the last release
- [analyzeCommits](https://github.com/semantic-release/exec#analyzecommits): Execute a shell command to determine the type of release
- [verifyRelease](https://github.com/semantic-release/exec#verifyrelease): Execute a shell command to verifying a release that was determined before and is about to be published.
- [generateNotes](https://github.com/semantic-release/exec#analyzecommits): Execute a shell command to generate the release note
- [publish](https://github.com/semantic-release/exec#publish): Execute a shell command to publish the release.
## Community plugins
+9
View File
@@ -0,0 +1,9 @@
# semantic-release recipes
## CI configurations
- [CircleCI 2.0 workflows](circleci-workflows.md)
- [Travis CI](travis.md)
- [Travis CI with build stages](travis-build-stages.md)
- [GitLab CI](gitlab-ci.md)
## Package managers and languages
+1
View File
@@ -0,0 +1 @@
# CircleCI 2.0 workflows
+71
View File
@@ -0,0 +1,71 @@
# Using semantic-release with [GitLab CI](https://about.gitlab.com/features/gitlab-ci-cd)
## Environment variables
The [Authentication](../../README.md#authentication) environment variables can be configured with [Secret variables](https://docs.gitlab.com/ce/ci/variables/README.html#secret-variables).
## Node project configuration
GitLab CI supports [Pipelines](https://docs.gitlab.com/ee/ci/pipelines.html) allowing to test on multiple Node versions and publishing a release only when all test pass.
**Note**: The publish pipeline must run a [Node >= 8 version](../../README.md#why-does-semantic-release-require-node-version--8).
### `.gitlab-ci.yml` configuration for Node projects
This example is a minimal configuration for semantic-release with a build running Node 4, 6 and 8 on Linux. See [GitLab CI - Configuration of your jobs with .gitlab-ci.yml](https://docs.gitlab.com/ee/ci/yaml/README.html) for additional configuration options.
**Note**: The`semantic-release` execution command varies depending if you are using a [local](../../README.md#local-installation) or [global](../../README.md#global-installation) semantic-release installation.
```yaml
# The release pipeline will run only if all jobs in the test pipeline are successful
stages:
- test
- release
before_script:
- npm install
node:4:
image: node:4
stage: test
script:
- npm test
node:6:
image: node:6
stage: test
script:
- npm test
node:8:
image: node:8
stage: test
script:
- npm test
publish:
image: node:8
stage: release
script:
# Only for a local semantic-release installation
- npm run semantic-release
# Only for a global semantic-release installation
- npm install semantic-release
- semantic-release
```
### `package.json` configuration
A `package.json` is required only for [local semantic-release installations](../../README.md#local-installation).
```json
{
"devDependencies": {
"semantic-release": "^12.0.0"
},
"scripts": {
"semantic-release": "semantic-release"
}
}
```
+1
View File
@@ -0,0 +1 @@
# Using semantic-release with [Travis CI build stages](https://docs.travis-ci.com/user/build-stages)
+151
View File
@@ -0,0 +1,151 @@
# Using semantic-release with [Travis CI](https://travis-ci.org)
## Environment variables
The [Authentication](../../README.md#authentication) environment variables can be configured in [Travis Repository Settings](https://docs.travis-ci.com/user/environment-variables/#defining-variables-in-repository-Settings) or with the [travis env set CLI](https://github.com/travis-ci/travis.rb#env).
Alternatively, the default `NPM_TOKEN` and `GH_TOKEN` can be easily [setup with semantic-release-cli](../../README.md#automatic-setup-with-semantic-release-cli).
## Single Node job configuration
For projects that require to be tested only with a single [Node version](https://docs.travis-ci.com/user/getting-started/#Selecting-a-different-programming-language) on [one Operating System](https://docs.travis-ci.com/user/getting-started/#Selecting-infrastructure-(optional)).
**Note**: [Node 8 is the minimal version required](../../README.md#why-does-semantic-release-require-node-version--8).
### `.travis.yml` configuration for single Node job
This example is a minimal configuration for semantic-release with a build running Node 8 on Linux. See [Travis - Customizing the Build](https://docs.travis-ci.com/user/customizing-the-build) for additional configuration options.
It's recommended to run the `semantic-release` command in the [Travis `script` step](https://docs.travis-ci.com/user/customizing-the-build/#The-Build-Lifecycle) so if an error happen the build will fail and Travis will send a notification.
**Note**: The`semantic-release` execution command varies depending if you are using a [local](../../README.md#local-installation) or [global](../../README.md#global-installation) semantic-release installation.
```yaml
language: node_js
node_js: 8
script:
# Run tests
- npm run test
# Only for a local semantic-release installation
- npm run semantic-release
# Only for a global semantic-release installation
- npm install -g semantic-release
- semantic-release
```
### `package.json` configuration for single Node job
A `package.json` is required only for [local semantic-release installations](../../README.md#local-installation).
```json
{
"devDependencies": {
"semantic-release": "^11.0.0"
},
"scripts": {
"semantic-release": "semantic-release"
}
}
```
## Multiple Node jobs configuration
For projects that require to be tested with multiple [Node versions](https://docs.travis-ci.com/user/languages/javascript-with-nodejs/#Specifying-Node.js-versions) and/or on multiple [Operating Systems](https://docs.travis-ci.com/user/multi-os).
**Note**: At least one job must run a [Node >= 8 version](../../README.md#why-does-semantic-release-require-node-version--8).
### `.travis.yml` configuration for multiple Node jobs
This example is a minimal configuration for semantic-release with a build running Node 4, 6 and 8 on Linux and OSX. See [Travis - Customizing the Build](https://docs.travis-ci.com/user/customizing-the-build) for additional configuration options.
This example uses [`travis-deploy-once`](https://github.com/semantic-release/travis-deploy-once) in order to command [Run `semantic-release` only after all tests succeeded](../../README.md#run-semantic-release-only-after-all-tests-succeeded). Alternatively you can use [Travis CI Build Stages recipe](travis-build-stages.md).
It's recommended to run the `semantic-release` command in the [Travis `script` step](https://docs.travis-ci.com/user/customizing-the-build/#The-Build-Lifecycle) so if an error happen the build will fail and Travis will send a notification.
**Note**: The`semantic-release` execution command varies depending if you are using a [local](../../README.md#local-installation) or [global](../../README.md#global-installation) semantic-release installation.
```yaml
language: node_js
node_js:
- 8
- 6
- 4
os:
- linux
- osx
script:
# Run tests
- npm run test
# Only for a local semantic-release installation
- npm run travis-deploy-once "npm run semantic-release"
# Only for a global semantic-release installation
- npm install -g travis-deploy-once semantic-release
- travis-deploy-once "semantic-release"
```
**Note**: See the `travis-deploy-once` [`pro`](https://github.com/semantic-release/travis-deploy-once#-p---pro) and [`travis-url`](https://github.com/semantic-release/travis-deploy-once#-u---travis-url) options for using with [Travis Pro](https://docs.travis-ci.com/user/travis-pro) and [Travis Enterprise](https://enterprise.travis-ci.com).
### `package.json` configuration for multiple Node jobs
A `package.json` is required only for [local semantic-release installations](../../README.md#local-installation).
```json
{
"devDependencies": {
"semantic-release": "^12.0.0",
"travis-deploy-once": "^4.0.0"
},
"scripts": {
"semantic-release": "semantic-release",
"travis-deploy-once": "travis-deploy-once"
}
}
```
## Non-JavaScript projects configuration
For projects that require to be tested with one or multiple version of a Non-JavaScript [language](https://docs.travis-ci.com/user/languages), optionally on multiple [Operating Systems](https://docs.travis-ci.com/user/multi-os).
This recipe cover the Travis specifics only. See [Non JavaScript projects recipe](../../README.md#can-i-use-semantic-release-to-publish-non-javascript-packages) for more information on the semantic-release configuration.
### `.travis.yml` configuration for non-JavaScript projects
This example is a minimal configuration for semantic-release with a build running [Go 1.6 and 1.7](https://docs.travis-ci.com/user/languages/go) on Linux and OSX. See [Travis - Customizing the Build](https://docs.travis-ci.com/user/customizing-the-build) for additional configuration options.
This example uses [`travis-deploy-once`](https://github.com/semantic-release/travis-deploy-once) in order to [run `semantic-release` only after all tests succeeded](../../README.md#run-semantic-release-only-after-all-tests-succeeded). Alternatively you can use [Travis CI Build Stages recipe](travis-build-stages.md).
It's recommended to run the `semantic-release` command in the [Travis `script` step](https://docs.travis-ci.com/user/customizing-the-build/#The-Build-Lifecycle) so if an error happen the build will fail and Travis will send a notification.
```yaml
language: go
go:
- 1.6
- 1.7
os:
- linux
- osx
script:
# Run tests
- go test -v ./...
# Use nvm to install and use the Node LTS version (nvm is installed on Travis images)
- nvm install lts/*
# Install travis-deploy-once and semantic-release
- npm install -g travis-deploy-once semantic-release
# Run semantic-release only on job, after all other are successful
- travis-deploy-once "semantic-release"
```
**Note**: See the `travis-deploy-once` [`pro`](https://github.com/semantic-release/travis-deploy-once#-p---pro) and [`travis-url`](https://github.com/semantic-release/travis-deploy-once#-u---travis-url) options for using with [Travis Pro](https://docs.travis-ci.com/user/travis-pro) and [Travis Enterprise](https://enterprise.travis-ci.com).
+7
View File
@@ -0,0 +1,7 @@
# semantic-release shareable configurations
## Official configurations
- [@semantic-release/apm-config](https://github.com/semantic-release/apm-config) - :atom: semantic-release shareable config for releasing atom packages
- [@semantic-release/gitlab-config](https://github.com/semantic-release/gitlab-config) - :fox_face: semantic-release shareable config for GitLab
## Community configurations
+34
View File
@@ -0,0 +1,34 @@
# Troubleshooting semantic-release
### ENOTINHISTORY Commit not in history
```
semantic-release ERR! commits The commit the last release of this package was derived from is not in the direct history of the "master" branch.
semantic-release ERR! commits This means semantic-release can not extract the commits between now and then.
semantic-release ERR! commits This is usually caused by force pushing, releasing from an unrelated branch, or using an already existing package name.
semantic-release ERR! commits You can recover from this error by publishing manually or restoring the commit "123".
semantic-release ERR! pre Failed to determine new version.
semantic-release ERR! pre ENOTINHISTORY Commit not in history
```
To restore semantic-release, follow these steps:
```
git pull
git reset --hard origin/master
npm version x.y.z # check your current version and set this based on semver rules manually
# if you have a PR workflow, create a new branch, otherwise commit to master
git checkout -B chore/release
git commit -am 'chore: release'
git push
# merge (not squash-merge) on github (this is important before running git push). This is only required when you work with branches
git checkout master
# definitely required
git pull
git push --tags
npm publish
```