Using semantic-release with Travis CI
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.
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 creates a release
build stage that runs semantic-release
only after all test jobs are successful.
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.
Advanced configuration: Running the tests in the script
step of the release
stage is not necessary as the previous stage(s) already ran them. To increase speed, the script
step of the release
stage can be overwritten to skip the tests. Note that other commands such as build or compilation might still be required.
language: node_js
node_js:
- 8
- 6
jobs:
include:
# Define the release stage that runs semantic-release
- stage: release
node_js: lts/*
# Advanced: optionally overwrite your default `script` step to skip the tests
# script: skip
deploy:
provider: script
skip_cleanup: true
script:
- npx semantic-release
A package.json
is required only for local semantic-release installation.
{
"devDependencies": {
"semantic-release": "^15.0.0"
}
}
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.
This example is a minimal configuration for semantic-release with a build running Go 1.6 and 1.7. See Travis - Customizing the Build for additional configuration options.
This example creates a release
build stage that runs semantic-release
only after all test jobs are successful.
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.
Advanced configuration: Running the tests in the script
step of the release
stage is not necessary as the previous stage(s) already ran them. To increase speed, the script
step of the release
stage can be overwritten to skip the tests. Note that other commands such as build or compilation might still be required.
language: go
go:
- 1.6
- 1.7
jobs:
include:
# Define the release stage that runs semantic-release
- stage: release
# Advanced: optionally overwrite your default `script` step to skip the tests
# script:
# - make
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/*
- npx semantic-release
on:
all_branches: true