- a very fast and intuitive continuous integration service, to unit test and publish new versions of my modules automatically using semantic-release service.
Here is step by step guide how to do this
- Semantic-release setup
- CircleCI setup
- Tell semantic-release to use condition-circle plugin
- Update 1: CircleCI works by default
You need to install the command line tool first
npm install -g semantic-release-cli
Now from your project, run it in setup mode. Answer questions, like NPM username, GitHub authentication, etc. At the last question "What CI are you using?" pick option "Other (print tokens)". You will see something like this
$ semantic-release-cli setup ? Is the GitHub repository private? No ? What is your npm registry? http://registry.npmjs.org/ ? What is your npm username? bahmutov ? What is your npm email? [email protected] ? What is your GitHub username? bahmutov ? What is your GitHub two-factor authentication code? 739958 ? What CI are you using? Other (prints tokens) ---------------------------------------------- GH_TOKEN=84b15... NPM_TOKEN=457d4b8... ----------------------------------------------
Note: the setup step removes the version property from your package.json. To avoid constant NPM warnings, I follow Kent C. Dodds' advice and add back a placeholder property
Add your project to CircleCI (typical series of steps, just like any other CI). Then open the "Project Settings" and select tab "Environment variables". Usually the direct url for this tab is something like
Add 2 new environment variables - the tokens you got in the previous step.
circle.ymlfile to your project with
post testcommand to run the
semantic-releaseNPM script. See directions in the next step.
Tell semantic-release to use condition-circle plugin
By default, semantic-release uses condition-travis
module to verify that it is running on Travis CI before publishing to NPM.
We need to use a different
plugin to check CircleCI
environment instead. Luckily, I wrote
condition-circle you can use ;)
It is very simple to setup, just follow the directions in condition-circle
Update 1: CircleCI works by default
Today CircleCI should work with semantic release straight out of the box. The only note is that semantic release skips a deploy from a pull request build. The CI is determined using package env-ci from the environment variables. Thus you need to "trick" the release job to not know it is running from a pull request job on Circle via environment variables.
Error message you usually see on CircleCI when releasing from a pull request:
This run was triggered by a pull request and therefore a new version won't be published
Fix by setting the environment variables
# allow CircleCI to release beta versions