Skip to content

Commit

Permalink
Merge pull request #26 from apowers313/master
Browse files Browse the repository at this point in the history
Revamping README.md
  • Loading branch information
boennemann committed Nov 26, 2015
2 parents 7d6bd30 + 31948e1 commit cdfb57b
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 41 deletions.
3 changes: 3 additions & 0 deletions .cz.json
@@ -0,0 +1,3 @@
{
"path": "node_modules/cz-conventional-changelog/"
}
93 changes: 52 additions & 41 deletions README.md
Expand Up @@ -5,7 +5,7 @@
[![NPM](https://nodei.co/npm/semantic-release-cli.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/semantic-release-cli/)
[![NPM](https://nodei.co/npm/semantic-release.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/semantic-release/)

## Automated [`semantic-release`](https://github.com/semantic-release/semantic-release) setup
## Install

```bash
npm install -g semantic-release-cli
Expand All @@ -16,46 +16,57 @@ semantic-release-cli setup

![dialogue](https://cloud.githubusercontent.com/assets/908178/8766357/f3eadaca-2e34-11e5-8ebb-d40b9ae613d7.png)

## Manual Setup

This is what you would have to if `semantic-release-cli` wouldn't exist:

### `package.json`

Delete the `version` field from your `package.json`. _Really_. It's safe to do, because machines will take care of it from now on.

Install `semantic-release` and save it as a `devDependency`.

```bash
# stable channel
npm install --save-dev semantic-release

# master channel
npm install --save-dev semantic-release@master
```

Create a `semantic-release` script in the [`scripts` field](https://docs.npmjs.com/files/package.json#scripts) of your `package.json`.

```json
{
"scripts": {
"semantic-release": "semantic-release pre && npm publish && semantic-release post"
}
}
```

Add a [`repository` field](https://docs.npmjs.com/files/package.json#repository) to the `package.json`.
You should do this anyway, but – as `semantic-release` depends on it – now you have to.

### CI Server

The idea is that your CI Server runs `npm run semantic-release` whenever a test run on your main branch succeeds. By default these conditions are verified assuming a [Travis CI](https://travis-ci.org/) environment. This isn't tied to a specific service though. Using the [`verifyConditions` plugin](#verifyconditions) you can easily configure your own CI Server.

The CI environment has to export `CI=true` in order for `semantic-release` to not automatically perform a dry run. Most CI services do this by default.

You need to export access tokens to the environment, so `semantic-release` can authenticate itself with GitHub and npm. [Get a token for GitHub on their website](https://github.com/settings/tokens/new), grant it the repo/public_repo scope, and export it as `GH_TOKEN`. The smoothest and securest way to do this on Travis CI is to use [their web interface](http://docs.travis-ci.com/user/environment-variables/#Defining-Variables-in-Repository-Settings).

Unfortunately there is no web interface for obtaining npm tokens yet, so you have to run `npm adduser` locally. Copy the token from your `~/.npmrc` file afterwards. Export it as `NPM_TOKEN`.
## Options

Usage:
semantic-release-cli setup [options]

Options:
-h --help Show this screen.
-v --version Show version.
--[no-]keychain Use keychain to get passwords [default: true].
--ask-for-passwords Ask for the passwords even if passwords are stored [default: false].
--tag=<String> npm tag to install [default: 'latest'].

## What it Does
__semantic-release-cli performs the following steps:__

1. Asks for the information it needs. You will need to provide it with:
* Whether your GitHub repository is public or private
* Which NPM registry you want to use (Default: https://registry.npmjs.org/)
* Your NPM username (unless passwords were previously saved to keychain)
* Your NPM email
* Your NPM password
* Your GitHub username
* Your GitHub password (unless passwords were previously saved to keychain)
* Which continuous integration system you want to use. (Options: Travis CI / Pro / Enterprise, or Other)
* Whether you want to test a single node.js version (e.g. - 0.12) or multiple node.js versions (e.g. - 0.10, 0.12, etc.)
1. Save your passwords to your local OS's keychain using [keytar](https://www.npmjs.com/package/keytar) for future use (unless `--no-keychain` was specified)
1. NPM Add User
* Runs `npm adduser` with the npm information provided to generate a `.npmrc`
* Parses the NPM token from the `.npmrc` for future use
1. Create GitHub Personal Token
* Logs into GitHub using the username and password provided
* Creates a [GitHub Personal Access Token](https://github.com/settings/tokens) and saves it for future use
1. Overwrite your .travis.yml file (if Travis CI was selected)
* `before_install: npm i -g npm@^2.0.0`: install NPM 2
* `before_script: curl -Lo travis_after_all.py https://git.io/vLSON`: install [travis-after-all](https://github.com/travis-ci/travis-ci/issues/929) script to enable running `semantic-release` after ALL build succeed
* `after_success: python travis_after_all.py` and `npm run semantic-release`: run `semantic-release` exactly once after all builds pass
* Set other sane defaults: `sudo: false`, `cache: directories: node_modules`, `notifications: email: false`, `before_script: npm prune`
1. Update your package.json
* Remove `version` field (you don't need it anymore -- `semantic-release` will set the version for you automatically)
* Add a `semantic-release` script: `"semantic-release": "semantic-release pre && npm publish && semantic-release post"`
* Add `semantic-release` as a `devDependency`
* Add or overwrite the [`repository` field](https://docs.npmjs.com/files/package.json#repository)
1. Login to Travis CI to configure the package
* Enable builds of your repo
* Add GH_TOKEN and NPM_TOKEN environment variables in the settings

## Other CI Servers

By default, `semantic-release-cli` supports the popular Travis CI server. If you select `Other` as your server during configuration, `semantic-release-cli` will print out the environment variables you need to set on your CI server. You will be responsible for adding these environment variables as well as configuring your CI server to run `npm run semantic-release` after all the builds pass.

Note that your CI server will also need to set the environment variable `CI=true` so that `semantic-release` will not perform a dry run. (Most CI services do this by default.) See the `semantic-release` documentation for more details.

## License

Expand Down
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -30,6 +30,7 @@
},
"devDependencies": {
"babel": "^5.5.8",
"cz-conventional-changelog": "^1.1.0",
"mkdirp": "^0.5.1",
"nyc": "^3.0.0",
"rimraf": "^2.4.2",
Expand Down

0 comments on commit cdfb57b

Please sign in to comment.