All Projects → bahmutov → ci-publish

bahmutov / ci-publish

Licence: other
Poor man's semantic release utility. Let the CI do the `npm publish` step after the build passes

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to ci-publish

Automatic Release
Automates the release process for GitHub projects.
Stars: ✭ 46 (+53.33%)
Mutual labels:  ci, publish
Semantic Release
📦🚀 Fully automated version management and package publishing
Stars: ✭ 14,364 (+47780%)
Mutual labels:  semantic-release, publish
Git Release
Publish a GitHub Release 📦 with Assets 📁 and Changelog 📄
Stars: ✭ 77 (+156.67%)
Mutual labels:  ci, publish
Aliyungradleconfig
自用的安卓开源项目工程模板。阿里云远程仓库加速,发布到maven仓库、上传到jcenter,代码混淆、资源混淆,持续集成(CI),多渠道自动打包。在天朝使用jcenter、mavenCentral及google三个远程仓库,Gradle Sync太慢?一招教你配置阿里云镜像源。init.d/init.gradle
Stars: ✭ 37 (+23.33%)
Mutual labels:  ci, publish
exec
🐚 semantic-release plugin to execute custom shell commands
Stars: ✭ 94 (+213.33%)
Mutual labels:  semantic-release, publish
action-junit-report
Reports junit test results as GitHub Pull Request Check
Stars: ✭ 103 (+243.33%)
Mutual labels:  ci
duci
The simple ci server
Stars: ✭ 73 (+143.33%)
Mutual labels:  ci
simple-commit-message
Simple commit message wizard and validator; works with commitizen and pre-git
Stars: ✭ 21 (-30%)
Mutual labels:  semantic-release
cookiecutter-cpp-project
A cookiecutter for a C++ Project with lots of configuration options
Stars: ✭ 25 (-16.67%)
Mutual labels:  ci
drevops
💧 + 🐳 + ✓✓✓ + 🤖 + ❤️ Build, Test, Deploy scripts for Drupal using Docker and CI/CD
Stars: ✭ 55 (+83.33%)
Mutual labels:  ci
prettier-check
Check that all files match prettier code style.
Stars: ✭ 54 (+80%)
Mutual labels:  ci
docker-coala-base
coala base docker image
Stars: ✭ 20 (-33.33%)
Mutual labels:  ci
cra-template-unicorn
🦄 The full template of create-react-app with typescript, redux-toolkit, react-redux, react-router for Single Page Application!
Stars: ✭ 56 (+86.67%)
Mutual labels:  semantic-release
go-semantic-release
automatic release
Stars: ✭ 34 (+13.33%)
Mutual labels:  semantic-release
breakcheck
Backwards compatibility linter for Go.
Stars: ✭ 66 (+120%)
Mutual labels:  ci
swarmci
Swarm CI - Docker Swarm-based CI system or enhancement to existing systems.
Stars: ✭ 48 (+60%)
Mutual labels:  ci
laravel-realworld-example-app
Exemplary RealWorld backend API built with Laravel PHP framework.
Stars: ✭ 34 (+13.33%)
Mutual labels:  ci
netlify-plugin-cache
⚡ Generic plugin for caching any files and/or folders between Netlify builds
Stars: ✭ 19 (-36.67%)
Mutual labels:  ci
ngx-deploy-docker
Deploy your Angular Application to a Docker registry directly from the Angular CLI! 🚀
Stars: ✭ 14 (-53.33%)
Mutual labels:  publish
release-helper
🤖 A GitHub Action that help you publish release.
Stars: ✭ 27 (-10%)
Mutual labels:  ci

ci-publish

Poor man's semantic release utility. Let the CI do the npm publish step after the build passes

NPM

Build status

Goal

Allow any CI to publish your module after tests pass, using your account to login.

Q: Why not use semantic-release?

A: Because it needs a lot of tweaking to setup on CircleCI or Gitlab

Q: But your package only does the "release" part without the "semantic" version upgrade?

A: Yeah :( I am sorry

Example: this own repo, see .travis.yml file

How to use

  • Add as a dependency to your project npm install --save-dev ci-publish

  • Login into your project's NPM registry

npm login --registry <registry url>
npm login --registry http://registry.npmjs.org
  • Copy the token

The login step added a line to your ~/.npmrc file looking something like this

//registry.npmjs.org/:_authToken=00000000-0000-0000-0000-000000000000

Grab the auth token value 00000000-0000-0000-0000-000000000000 (older NPM proxies or registries like sinopia might have an older different token string format)

  • Set the token as CI environment variable

Go to your CI project settings and add a new variable NPM_TOKEN with the value you have just copied

  • Add script command (optional)

Create a script command to run the publish, in your package.json

{
    "scripts": {
        "ci-publish": "ci-publish"
    }
}

Now you can run the ci-publish logic from shell using npm run ci-publish command

You can avoid adding a script command if you use explicit command in your CI files, like $(npm bin)/ci-publish

  • Add a command to run on your CI after the tests pass.

Travis CI

Add after_success section to your .travis.yml file

after_success:
    - npm run ci-publish || true

Every time you want to publish your module to the registry after the tests pass, just increment the package version and push the code. The CI will pass the tests and will try to run ci-publish. This will add the auth token to the CI's "user" profile, allowing it to publish under your authority. If the package has a new version, it will be published. If you have not incremented the version number, this step fail, but we do not fail the build step by using || true

warning: The publish will fail if there are multiple Travis jobs trying to publish at the same time, which happens if you test on multiple NodeJS versions. Maybe use a different CI engine for the publish?

Gitlab

Add a new deploy job to your .gitlab-ci.yml file. For example

before_script:
  - npm install
stages:
  - test
  - deploy
npm_test:
  stage: test
  script:
    - npm test
release:
  stage: deploy
  script:
    - echo Running release
    - npm run ci-publish || true

Gitlab can run multiple test jobs in parallel and then a single release job.

Typical output

For example, when successfully publishing this module, Travis produced this output

$ npm run ci-publish || true
> [email protected] ci-publish /home/travis/build/bahmutov/ci-publish
> node bin/ci-publish.js
//registry.npmjs.org/:_authToken=${NPM_TOKEN}
saved /home/travis/.npmrc
$ npm publish || true
* [email protected]

Extra resources

  • If you need to debug NPM commands, just enable verbose NPM logging
npm_config_loglevel=verbose $(npm bin)/ci-publish

Small print

Author: Gleb Bahmutov © 2015

License: MIT - do anything with the code, but don't blame me if it does not work.

Spread the word: tweet, star on github, etc.

Support: if you find any problems with this module, email / tweet / open issue on Github

MIT License

Copyright (c) 2015 Gleb Bahmutov

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].