image: node:latest # Cache modules in between jobs cache: key: ${CI_COMMIT_REF_SLUG} paths: - node_modules/ stages: - test - deploy variables: PUBLISH_CMD: 'npm publish --registry=$NPM_PUBLISH_REGISTRY' before_script: - echo 'registry='$NPM_REGISTRY'/' > .npmrc - echo '_auth='$NPM_TOKEN >> .npmrc - echo 'always-auth=true' >> .npmrc - npm install test: stage: test script: - npm build - npm run test publish: stage: deploy only: - tags script: - npm run build - echo 'registry='$NPM_PUBLISH_REGISTRY > .npmrc - echo '_auth='$NPM_TOKEN >> .npmrc - echo 'always-auth=true' >> .npmrc - echo 'email=any@any.com' >> .npmrc - npm publish