Select Git revision
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
This project is licensed under the MIT License.
Learn more
.gitlab-ci.yml 2.49 KiB
default:
image: dbogatov/docker-sources:node--14.4-alpine3.12
tags:
- docker
stages:
- test
- security
- release
lint:
stage: test
script:
- npm install
- npm run lint
allow_failure: true
test:
stage: test
script:
- npm install
- npm run coverage
coverage: '/All files[^|]*\|[^|]*\s+([\d\.]+)/'
artifacts:
expire_in: 1 hour
paths:
- coverage/
reports:
junit: test-results.xml
cobertura: coverage/cobertura-coverage.xml
release:
stage: release
script:
- |
cat <<EOT >> .npmrc
@dbogatov:registry=https://${CI_SERVER_HOST}/api/v4/packages/npm/
//${CI_SERVER_HOST}/api/v4/packages/npm/:_authToken=${CI_JOB_TOKEN}
//${CI_SERVER_HOST}/api/v4/projects/${CI_PROJECT_ID}/packages/npm/:_authToken=${CI_JOB_TOKEN}
EOT
- |
PACKAGE=$(cat package.json | grep name | head -1 | awk -F: '{ print $2 }' | sed 's/[",]//g' | tr -d '[[:space:]]')
- |
THIS_VERSION=$(cat package.json | grep version | head -1 | awk -F: '{ print $2 }' | sed 's/[",]//g' | tr -d '[[:space:]]')
- LATEST_VERSION=$(npm show $PACKAGE version)
- |
echo "This: $THIS_VERSION, latest: $LATEST_VERSION"
- |
if [ "$LATEST_VERSION" = "$THIS_VERSION" ]
then
echo "This version has already been published"
exit 0
fi
- npm install
- npm run build
- sed -i "s#\"$PACKAGE\"#\"@dbogatov/$PACKAGE\"#g" package.json
- npm publish
- |
cat <<EOT > .npmrc
//registry.npmjs.org/:_authToken=${NPM_TOKEN}
EOT
- sed -i "s#\"@dbogatov/$PACKAGE\"#\"$PACKAGE\"#g" package.json
- npm publish
rules:
- if: '$CI_COMMIT_REF_NAME == "master"'
when: on_success
allow_failure: true
code_navigation:
stage: release