Travi CI can publish your modules in NPM's public or private registry. This is a much better option than doing it from your local machine. I do it with some of my open source projects, this way I don't have to worry about distributing the latest version of a library after updating the code.
Travis has this process documented in their website, but I find some steps are not quite clear. Hopefully this instructions will make it more understandable.
First thing you need is a npm account with publish permissions in the public npm registry (or your organisation's private one). Once your credentials are set you need to add them to
.npmrc, the npm configuration file in your home directory with
$ npm adduser Username: mserranom Password: Email: (this IS public) email@example.com $
Assuming your project already has a configured
.travis.yml descriptor (follow this guide otherwise) you need to include an encrypted version of the npm authentication key in order to allow Travis to publish the module on your behalf:
$ cat ~/.npmrc /registry.npmjs.org/:_authToken=XXXXXX-XXX-XXXX-XXXX-XXXXXXXXXX
Use Travis CLI to update the
.travis.yml descriptor. You'll be prompted to introduce the value of
$ cd project_repo # folder containing .travis.yml $ travis encrypt --add deploy.api_key Reading from stdin, press Ctrl+D when done XXXXXX-XXX-XXXX-XXXX-XXXXXXXXXX
In order to execute the
encrypt command you have to be in the folder where
.travis.yml is located. Once you introduce your authentication key, press Ctrl+D, don't enter spaces or new lines. The .travis.yml descriptor should be updated with the new public key.
language: node_js sudo: false node_js: - '0.12' deploy: provider: npm skip_cleanup: true email: firstname.lastname@example.org api_key: secure: FX+e8xv+oiKfaX7V6aIoD04sy3SsTpDGtc ...