Skip to content

Instantly share code, notes, and snippets.

@s-lyn
Created January 31, 2020 05:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save s-lyn/072d7084637b6f8e5741ddc3ba819a21 to your computer and use it in GitHub Desktop.
Save s-lyn/072d7084637b6f8e5741ddc3ba819a21 to your computer and use it in GitHub Desktop.
Continuous Deployment example to npm using GitLab CI

Got from here

1. Create .gitlab-ci.yml:

image: node:alpine

before_script:
  - npm install

cache:
  paths:
    - node_modules/

stages:
  - test
  - deploy

test:
  stage: test
  script:
    - npm test

publish:
  stage: deploy
  only:
    - tags
    - triggers
  script:
    - echo '//registry.npmjs.org/:_authToken=${NPM_TOKEN}'>.npmrc
    - npm publish

2. Add NPM token to Gitlab CI variable NPM_TOKEN

3. To create new version run:

npm version patch
git push --follow-tags
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment