1 | # @semantic-release/condition-travis
|
2 |
|
3 | [semantic-release](https://github.com/semantic-release/semantic-release) plugin to check [Travis CI](https://travis-ci.org/) environment before publishing.
|
4 |
|
5 | [![Travis](https://img.shields.io/travis/semantic-release/condition-travis.svg)](https://travis-ci.org/semantic-release/condition-travis)
|
6 | [![Codecov](https://img.shields.io/codecov/c/github/semantic-release/condition-travis.svg)](https://codecov.io/gh/semantic-release/condition-travis)
|
7 | [![Greenkeeper badge](https://badges.greenkeeper.io/semantic-release/condition-travis.svg)](https://greenkeeper.io/)
|
8 |
|
9 | Verify that `semantic-release` is running:
|
10 | - on Travis CI
|
11 | - on the right git branch and not on a PR build
|
12 | - only after all other Travis jobs are successful (using [travis-deploy-once](https://github.com/semantic-release/travis-deploy-once))
|
13 |
|
14 | ### Options
|
15 |
|
16 | | Option | Description | Default |
|
17 | | --------------------- | -------------------------------------------------------------------- | ------------------------------------------------------ |
|
18 | | `githubToken` | **Required.** The Github token used to authenticate with Travis API. | `process.env.GH_TOKEN` or `process.env.GITHUB_TOKEN` |
|
19 | | `githubUrl` | The GitHub Enterprise endpoint. | `process.env.GH_URL` or `process.env.GITHUB_URL` |
|
20 | | `githubApiPathPrefix` | The GitHub Enterprise API prefix. | `process.env.GH_PREFIX` or `process.env.GITHUB_PREFIX` |
|
21 |
|
22 | ## Configuration
|
23 |
|
24 | The plugin is used by default by [semantic-release](https://github.com/semantic-release/semantic-release) so no specific configuration is requiered if `githubToken`, `githubUrl` and `githubApiPathPrefix` are set via environment variable.
|
25 |
|
26 | ## Travis configuration
|
27 |
|
28 | `semantic-release` require Node node version >= 8, so at least one Travis job as to run on Node 8 (or greater).
|
29 |
|
30 | ### With one job
|
31 |
|
32 | No specific configuration is required. `semantic-release` will run on the only Travis job.
|
33 |
|
34 | ```yml
|
35 | language: node_js
|
36 | node_js:
|
37 | - 8
|
38 |
|
39 | after_success:
|
40 | - npm run semantic-release
|
41 | ```
|
42 |
|
43 | ### With multiple jobs on different Node versions and OS
|
44 |
|
45 | If there is multiple Node version and OS configured, [travis-deploy-once](https://github.com/semantic-release/travis-deploy-once) will guarantee that `semantic-release` is executed on the highest Node version, after all other jobs are successful, without any additionnal configurations.
|
46 |
|
47 | ```yml
|
48 | language: node_js
|
49 | node_js:
|
50 | - 8
|
51 | - 6
|
52 | - 4
|
53 | os:
|
54 | - linux
|
55 | - osx
|
56 |
|
57 | after_success:
|
58 | - npm run semantic-release
|
59 | ```
|
60 |
|
61 | In this example Travis will run 6 jobs (Node 8/Linux, Node 8/ OSX, Node 6/Linux etc...) and `semantic-release` will be executed on Node 8 on Linux, only after the 5 other jobs are successful.
|
62 |
|
63 | ### Using Travis Build stages
|
64 |
|
65 | Travis support [Build Stages](https://docs.travis-ci.com/user/build-stages/) for more complex workflows. It's possible to use `semantic-release` with Build Stages by configuring the environment variable `BUILD_LEADER_ID` to defined which job will run `semantic-release`.
|
66 |
|
67 | **The build stage configuration has to guarantee that the job configured with `BUILD_LEADER_ID` will run only after all other jobs are successful.**
|
68 |
|
69 | ```yml
|
70 | language: node_js
|
71 | node_js:
|
72 | - 8
|
73 | - 6
|
74 | - 4
|
75 | os:
|
76 | - linux
|
77 | - osx
|
78 | env:
|
79 | - BUILD_LEADER_ID=7
|
80 | jobs:
|
81 | include:
|
82 | - stage: release
|
83 | node_js: 8
|
84 | os: linux
|
85 | after_success:
|
86 | - npm run semantic-release
|
87 | ```
|
88 |
|
89 | In this example Travis will run 6 jobs in the default stage (Node 4, 6 and 8 on Linux and OSX) and if those 6 jobs are successful the release stage will run the 7th job (on Node 8 / Linux) that will execute `semantic-release`.
|
90 | The environment variable `BUILD_LEADER_ID` is set to `7` as `semantic-release` should run on the 7th job.
|