Skip to content
Snippets Groups Projects
Select Git revision
  • 6085847a6463a4bb39bbd324d5bc347856f8c4d0
  • master default protected
2 results

.gitlab-ci.yml

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    .gitlab-ci.yml 2.69 KiB
    default:
      image: dbogatov/docker-sources:node--14.4-alpine3.12
      tags:
        - docker
    
    stages:
      - build
      - test
      - security
      - release
    
    build:
      stage: build
      script:
        - npm install
        - npm run build
      artifacts:
        paths:
          - node_modules
          - dist
        expire_in: 1 hour
    
    lint:
      stage: test
      dependencies:
        - build
      script:
        - npm run lint
      allow_failure: true
    
    test:
      stage: test
      dependencies:
        - build
      script:
        - 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
      dependencies:
        - build
      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
        - sed -i "s#\"$PACKAGE\"#\"@dbogatov/$PACKAGE\"#g" package.json