include: - template: Security/Dependency-Scanning.gitlab-ci.yml - template: Security/SAST.gitlab-ci.yml - template: Security/Secret-Detection.gitlab-ci.yml - template: Security/License-Scanning.gitlab-ci.yml - project: 'dependabot-gitlab/dependabot-standalone' file: '.gitlab-ci.yml' variables: SAST_EXCLUDED_PATHS: 'spec, test, tests, tmp, lib, node_modules' .nodestuff: &nodestuff image: ${CI_DEP_PREFIX}node:lts-alpine cache: key: files: - package-lock.json paths: - node_modules install: stage: build script: - npm install - npm pack artifacts: paths: - ./lib/*.js - ./*.tgz <<: *nodestuff test: stage: test needs: - install script: - npm run test -- --reporter mocha-junit-reporter coverage: '/All files[^|]*\|[^|]*\s+([\d\.]+)/' artifacts: reports: junit: test-results.xml coverage_report: coverage_format: cobertura path: coverage/cobertura-coverage.xml <<: *nodestuff .pubCheck: &pubCheck # Compare the versions in git and in node to verify that they are the same - | NODE_VERSION=$(node -e "r=require('./package.json');console.log(r.version);") GIT_VERSION=$(echo $CI_COMMIT_TAG | sed 's/^v//') if [ "$NODE_VERSION" == "$GIT_VERSION" ]; then echo "Versions match. Continuing." else echo "Error, versions do not match." exit 3 fi - echo "CI_SHORT_VERSION=$NODE_VERSION" > dotenv publish: <<: *nodestuff stage: deploy needs: - install - test rules: - if: $CI_COMMIT_TAG before_script: *pubCheck script: - echo "//registry.npmjs.org/:_authToken=$VAR_NPM_AUTHTOKEN" > ~/.npmrc - npm publish || echo "This failed but thats okay." environment: name: npmjs url: https://www.npmjs.com/package/$CI_PROJECT_NAME artifacts: reports: dotenv: './dotenv' publish_gitlab: <<: *nodestuff stage: deploy needs: - install - test rules: - if: $CI_COMMIT_TAG before_script: *pubCheck script: - | echo "@${CI_PROJECT_ROOT_NAMESPACE}:registry=${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/npm/" > ~/.npmrc echo "${CI_API_V4_URL#https?}/projects/${CI_PROJECT_ID}/packages/npm/:_authToken=\${CI_JOB_TOKEN}" >> ~/.npmrc - | sed -i "s/\(^ \"name\": \)\"\($CI_PROJECT_NAME\)\"/\1\"@$CI_PROJECT_ROOT_NAMESPACE\/\2\"/" package.json - npm publish environment: name: gitlab-npm url: $CI_PROJECT_URL/-/packages?type=npm&orderBy=name&sort=desc&search[]= release: stage: deploy image: registry.gitlab.com/gitlab-org/release-cli:latest needs: - publish rules: - if: $CI_COMMIT_TAG script: - echo "Creating the release at $CI_COMMIT_TAG" release: name: "mock-local-storage $CI_COMMIT_TAG" tag_name: $CI_COMMIT_TAG ref: $CI_COMMIT_TAG description: "Automated release for mock-local-storage at $CI_COMMIT_TAG" milestones: - $CI_COMMIT_TAG assets: links: - name: mock-local-storage@$CI_COMMIT_TAG url: https://www.npmjs.com/package/$CI_PROJECT_NAME/v/$CI_SHORT_VERSION