Skip to content
Snippets Groups Projects
.gitlab-ci.yml 1.15 KiB
Newer Older
Fabio Busatto's avatar
Fabio Busatto committed
# This file is a template, and might need editing before it works on your project.
# Official framework image. Look for the different tagged releases at:
# https://hub.docker.com/r/library/node/tags/
image: node:latest

Fred Chasen's avatar
Fred Chasen committed
stages:
  - test
  - deploy
  - publish

Fabio Busatto's avatar
Fabio Busatto committed
# This folder is cached between builds
# http://docs.gitlab.com/ce/ci/yaml/README.html#cache
cache:
  paths:
  - node_modules/

test:
  stage: test
  script:
    - npm install
    - npm test

pack:
  stage: deploy
  script:
    - npm install
    - npm pack
  artifacts:
    paths:
    - ./*.tgz

# This job requires to setup GitLab the following way:
# 1. On https://www.npmjs.com/settings/tokens/create
#     create a new read/write token (the logged in user must have write access for the `pagedjs` package)
# 2. On https://gitlab.pagedmedia.org/tools/pagedjs/-/settings/ci_cd#js-cicd-variables-settings
#     add a new variable named `NPM_TOKEN`, and toggle on _Protected_ and _Masked_
npm-publish:
  stage: publish
  before_script:
    - 'echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc'
    - npm install
    - npm publish --public --dry-run
  script:
    - npm publish --public
  only:
    - tags