compressiontool
Version:
generic module to handle different types of compression
59 lines (56 loc) • 2.65 kB
YAML
# You can override the included template(s) by including variable overrides
# SAST customization: https://docs.gitlab.com/ee/user/application_security/sast/#customizing-the-sast-settings
# Secret Detection customization: https://docs.gitlab.com/ee/user/application_security/secret_detection/#customizing-settings
# Dependency Scanning customization: https://docs.gitlab.com/ee/user/application_security/dependency_scanning/#customizing-the-dependency-scanning-settings
# Container Scanning customization: https://docs.gitlab.com/ee/user/application_security/container_scanning/#customizing-the-container-scanning-settings
# Note that environment variables can be set in several places
# See https://docs.gitlab.com/ee/ci/variables/#cicd-variable-precedence
stages:
- test
- deploy
sast:
stage: test
##publish:
##stage: deploy
## environment:
## name: npm
variables:
NPM_USER: "peter.prib"
NPM_REPRO: "//registry.npmjs.org/"
publish:
image: node:latest
stage: deploy
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH || $CI_COMMIT_REF_NAME =~ /^v\d+\.\d+\.\d+.*$/
changes:
- package.json
script:
# If no .npmrc is included in the repo, generate a temporary one that is configured to publish to GitLab's NPM registry
- |
if [[ ! -f .npmrc ]]; then
echo "No .npmrc found! Creating one now."
echo "${NPM_REPRO}:_authToken=${NPM_TOKEN}" > .npmrc
cat .npmrc
npm config set //registry.npmjs.org/:_authToken ${NPM_TOKEN}
npm config set registry https:${NPM_REPRO}
npm config set prefer-online true
npm config set email=peterprib@gmail.com
npm config set -- '${NPM_REPRO}:_authToken' "${NPM_TOKEN}"
fi
# Extract a few values from package.json
- NPM_PACKAGE_NAME="${NPM_USER}:"
- NPM_PACKAGE_NAME+=$(node -p "require('./package.json').name")
- NPM_PACKAGE_VERSION=$(node -p "require('./package.json').version")
# Compare the version in package.json to all published versions.
# If the package.json version has not yet been published, run `npm publish`.
- |
if [[ $(npm view "${NPM_PACKAGE_NAME}" versions) != *"'${NPM_PACKAGE_VERSION}'"* ]]; then
echo "new version or new package"
npm publish --verbose
echo "Successfully published version ${NPM_PACKAGE_VERSION} of ${NPM_PACKAGE_NAME} to GitLab's NPM registry: ${CI_PROJECT_URL}/-/packages"
else
echo "Version ${NPM_PACKAGE_VERSION} of ${NPM_PACKAGE_NAME} has already been published, so no new version has been published."
fi
include:
- template: Security/SAST.gitlab-ci.yml
##- template: npm.gitlab-ci.yml