UNPKG

5.1 kBMarkdownView Raw
1# Using semantic-release with [Travis CI](https://travis-ci.org)
2
3## Environment variables
4
5The [Authentication](../usage/ci-configuration.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).
6
7Alternatively, the default `NPM_TOKEN` and `GH_TOKEN` can be easily [setup with semantic-release-cli](../usage/getting-started.md#getting-started).
8
9## Node.js projects configuration
10
11### `.travis.yml` configuration for multiple Node.js jobs
12
13This example is a minimal configuration for **semantic-release** with a build running Node 6 and 8. See [Travis - Customizing the Build](https://docs.travis-ci.com/user/customizing-the-build) for additional configuration options.
14
15This example creates a `release` [build stage](https://docs.travis-ci.com/user/build-stages) that [runs `semantic-release` only after all test jobs are successful](../usage/ci-configuration.md#run-semantic-release-only-after-all-tests-succeeded).
16
17It's recommended to run the `semantic-release` command in the [Travis `deploy` step](https://docs.travis-ci.com/user/customizing-the-build/#The-Build-Lifecycle) so if an error occurs the build will fail and Travis will send a notification.
18
19**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](https://github.com/travis-ci/travis-ci/issues/1066).
20
21**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.
22
23```yaml
24language: node_js
25
26node_js:
27 - 8
28 - 6
29
30jobs:
31 include:
32 # Define the release stage that runs semantic-release
33 - stage: release
34 node_js: lts/*
35 # Advanced: optionally overwrite your default `script` step to skip the tests
36 # script: skip
37 deploy:
38 provider: script
39 skip_cleanup: true
40 script:
41 - npx semantic-release
42```
43
44### `package.json` configuration for multiple Node jobs
45
46A `package.json` is required only for [local](../usage/installation.md#local-installation) **semantic-release** installation.
47
48```json
49{
50 "devDependencies": {
51 "semantic-release": "^15.0.0"
52 }
53}
54```
55
56## Non-Node.js projects configuration
57
58For 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).
59
60This recipe cover the Travis specifics only. See [Non JavaScript projects recipe](../support/FAQ.md#can-i-use-semantic-release-to-publish-non-javascript-packages) for more information on the **semantic-release** configuration.
61
62### `.travis.yml` configuration for non-JavaScript projects
63
64This 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). See [Travis - Customizing the Build](https://docs.travis-ci.com/user/customizing-the-build) for additional configuration options.
65
66This example creates a `release` [build stage](https://docs.travis-ci.com/user/build-stages) that [runs `semantic-release` only after all test jobs are successful](../usage/ci-configuration.md#run-semantic-release-only-after-all-tests-succeeded).
67
68It's recommended to run the `semantic-release` command in the [Travis `deploy` step](https://docs.travis-ci.com/user/customizing-the-build/#The-Build-Lifecycle) so if an error occurs the build will fail and Travis will send a notification.
69
70**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](https://github.com/travis-ci/travis-ci/issues/1066).
71
72**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.
73
74```yaml
75language: go
76
77go:
78 - 1.6
79 - 1.7
80
81jobs:
82 include:
83 # Define the release stage that runs semantic-release
84 - stage: release
85 # Advanced: optionally overwrite your default `script` step to skip the tests
86 # script:
87 # - make
88 deploy:
89 provider: script
90 skip_cleanup: true
91 script:
92 # Use nvm to install and use the Node LTS version (nvm is installed on all Travis images)
93 - nvm install lts/*
94 - npx semantic-release
95 on:
96 all_branches: true
97```