6.8 KiB
Using semantic-release with Travis CI
Environment variables
The Authentication environment variables can be configured in Travis Repository Settings or with the travis env set CLI.
Alternatively, the default NPM_TOKEN
and GH_TOKEN
can be easily setup with semantic-release-cli.
Single Node job configuration
For projects that require to be tested only with a single Node version on one Operating System.
Note: Node 8 is the minimal version required.
.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 for additional configuration options.
It's recommended to run the semantic-release
command in the Travis deploy
step so if an error occurs the build will fail and Travis will send a notification.
Note: It's not recommended to run the semantic-release
command in the Travis script
step as each script in this step will be executed regardless of the outcome of the previous one. See travis-ci/travis-ci#1066.
language: node_js
node_js: 8
deploy:
provider: script
skip_cleanup: true
script:
- npx semantic-release
package.json
configuration for single Node job
A package.json
is required only for local semantic-release installation.
{
"devDependencies": {
"semantic-release": "^11.0.0"
}
}
Multiple Node jobs configuration
For projects that require to be tested with multiple Node versions and/or on multiple Operating Systems.
Note: At least one job must run a Node >= 8 version.
.travis.yml
configuration for multiple Node jobs
This example is a minimal configuration for semantic-release with a build running Node 6 and 8. See Travis - Customizing the Build for additional configuration options.
This example uses travis-deploy-once
in order to Run semantic-release
only after all tests succeeded. Alternatively you can use Travis CI Build Stages recipe.
It's recommended to run the semantic-release
command in the Travis deploy
step so if an error occurs the build will fail and Travis will send a notification.
Note: It's not recommended to run the semantic-release
command in the Travis script
step as each script in this step will be executed regardless of the outcome of the previous one. See travis-ci/travis-ci#1066.
language: node_js
node_js:
- 8
- 6
deploy:
provider: script
skip_cleanup: true
script:
- npx travis-deploy-once "npx semantic-release"
Note: See the travis-deploy-once
pro
and travis-url
options for using with Travis Pro and Travis Enterprise.
package.json
configuration for multiple Node jobs
A package.json
is required only for local semantic-release installation.
{
"devDependencies": {
"semantic-release": "^15.0.0",
"travis-deploy-once": "^5.0.0"
}
}
Non-JavaScript projects configuration
For projects that require to be tested with one or multiple version of a Non-JavaScript language, optionally on multiple Operating Systems.
This recipe cover the Travis specifics only. See Non JavaScript projects recipe 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 on Linux and OSX. See Travis - Customizing the Build for additional configuration options.
This example uses travis-deploy-once
in order to run semantic-release
only after all tests succeeded. Alternatively you can use Travis CI Build Stages recipe.
It's recommended to run the semantic-release
command in the Travis deploy
step so if an error occurs the build will fail and Travis will send a notification.
Note: It's not recommended to run the semantic-release
command in the Travis script
step as each script in this step will be executed regardless of the outcome of the previous one. See travis-ci/travis-ci#1066.
language: go
go:
- 1.6
- 1.7
os:
- linux
- osx
deploy:
provider: script
skip_cleanup: true
script:
# Use nvm to install and use the Node LTS version (nvm is installed on all Travis images)
- nvm install lts/*
# Run semantic-release only on one job, after all other are successful
- npx travis-deploy-once "npx semantic-release"
Note: See the travis-deploy-once
pro
and travis-url
options for using with Travis Pro and Travis Enterprise.