-
Notifications
You must be signed in to change notification settings - Fork 1
/
.gitlab-ci.yml
108 lines (97 loc) · 2.8 KB
/
.gitlab-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
default:
image: gitlab.virtualcitysystems.de:5050/vcsuite/devops/gitlabrunner/node:20-bullseye
variables:
GIT_CLONE_PATH: $CI_BUILDS_DIR/$CI_PROJECT_PATH_SLUG/$CI_COMMIT_REF_SLUG
stages:
- build
- test
- publish
- docs
.template: &job_definition
only:
- /^(feature-.*|hotfix-.*|main|release-.*)$/
tags:
- linux-2.0
build:
<<: *job_definition
script:
- npm set registry 'http://npmregistry:4873'
- npm ci
- npm run postinstall
stage: build
.after_build_template: &after_build_definition
<<: *job_definition
variables:
GIT_STRATEGY: none
lint:
<<: *after_build_definition
stage: test
only:
- /^(feature-.*|hotfix-.*|main|release-.*)$/
script:
- npm run lint
type-check:
<<: *after_build_definition
stage: test
only:
- /^(feature-.*|hotfix-.*|main|release-.*)$/
script:
- npm run type-check
audit:
<<: *after_build_definition
stage: test
only:
- /^(feature-.*|hotfix-.*|main|release-.*)$/
script:
- npm audit --production --audit-level=low --registry 'http://npmregistry:4873'
tests:
<<: *after_build_definition
stage: test
only:
- /^(feature-.*|hotfix-.*|main|release-.*)$/
script:
- npm run coverage:gitlab
coverage: '/^Statements\s*:\s*([^%]+)/'
artifacts:
reports:
junit: test-results.xml
publish:
<<: *after_build_definition
stage: publish
only:
variables:
- $PUBLISH
refs:
- /^(main|release-v.*)$/
script:
- LEVEL=$([ $CI_COMMIT_REF_NAME == "main" ] && echo "prerelease" || echo "patch")
- npm version $LEVEL -m "%s [skip-ci]"
- TAG=`git describe --abbrev=0`
- git push git@gitlab:vcsuite/npm/vcmap/core.git $TAG
- git push git@gitlab:vcsuite/npm/vcmap/core.git HEAD:$CI_COMMIT_REF_NAME
- npm config set '//registry.npmjs.org/:_authToken' "${NPM_TOKEN}"
- NPM_TAG=$([ $CI_COMMIT_REF_NAME == "main" ] && echo "dev" || echo "latest")
- npm publish --tag $NPM_TAG
before_script:
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- echo "$SSH_RUNNER_KEY" | tr -d '\r' > ~/.ssh/id_rsa
- chmod 600 ~/.ssh/id_rsa
- ssh-keyscan gitlab >> ~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts
- git config user.name "Gitlab Runner"
- git config user.email "gitlab-runner@vc.systems"
deployDocs:
<<: *after_build_definition
stage: docs
only:
variables:
- $PUBLISH
refs:
- /^(main|release-v.*)$/
script:
- npm run build-docs
- npm i -D @vcsuite/publishtox --registry http://npmregistry:4873
- VERSION=$(node -pe "const version = require('./package.json').version; /\d*\.\d*/.exec(version)[0]")
- echo "Uploading documentation to /lib/core/${VERSION}/docs"
- node_modules/.bin/publishToX sftp --prefix /map/virtualcitymap.de/lib/core/ hostingsftp.virtualcitypublisher.de --cores 4 -s ./docs -d "${VERSION}/docs/"