-
Notifications
You must be signed in to change notification settings - Fork 23
/
.gitlab-ci.yml
145 lines (132 loc) · 3.22 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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
image: ubuntu:bionic
.before_npm: &before_npm
- apt-get update -yqq
- apt-get install -yqq build-essential curl default-jdk
- curl -sL https://deb.nodesource.com/setup_10.x | bash -
- apt-get install -yqq nodejs
- npm --version
- npm install --unsafe-perm=true
.before_git: &before_git
- apt-get update -yqq
- apt-get install -yqq git openssh-client
- git --version
- git config --global user.email "${GITLAB_USER_EMAIL}"
- git config --global user.name "${GITLAB_USER_NAME}"
- git remote set-url origin --push "git@${CI_SERVER_HOST}:${CI_PROJECT_PATH}"
- git remote -v
- eval $(ssh-agent -s)
- chmod 700 "${CI_DEPLOY_KEY}"
- ssh-add "${CI_DEPLOY_KEY}"
- mkdir -p ~/.ssh
- echo -e "Host ${CI_SERVER_HOST}\n\tStrictHostKeyChecking no" >>
~/.ssh/config
- chmod 700 ~/.ssh
.script_checkout_branch: &script_checkout_branch
- git checkout ${CI_COMMIT_BRANCH}
- git reset --hard ${CI_COMMIT_SHA}
.script_merge_master: &script_merge_master
- git merge origin/master
- git push origin HEAD:master
- git push --tags
.script_npm_publish: &script_npm_publish
- npm config set //registry.npmjs.org/:_authToken ${NPM_TOKEN}
- npm publish
stages:
- test
- promotion
- version
- backmerge
include:
- template: Code-Quality.gitlab-ci.yml
- template: Dependency-Scanning.gitlab-ci.yml
- template: License-Scanning.gitlab-ci.yml
test:
stage: test
before_script:
- *before_npm
script:
- npm run lint:pkg
- npm run unit
artifacts:
paths:
- npm-debug.log
expire_in: 1 month
promote_patch:
stage: promotion
when: manual
only:
refs:
- develop
variables:
- $CI_COMMIT_MESSAGE !~ /\[ci\]/
environment: patch
before_script:
- *before_npm
- *before_git
script:
- *script_checkout_branch
- *script_merge_master
promote_minor:
stage: promotion
when: manual
only:
refs:
- develop
variables:
- $CI_COMMIT_MESSAGE !~ /\[ci\]/
environment: minor
before_script:
- *before_npm
- *before_git
script:
- *script_checkout_branch
- npm version minor --unsafe-perm=true -m "Minor version %s"
- *script_merge_master
- *script_npm_publish
promote_major:
stage: promotion
when: manual
only:
refs:
- develop
variables:
- $CI_COMMIT_MESSAGE !~ /\[ci\]/
environment: major
before_script:
- *before_npm
- *before_git
script:
- *script_checkout_branch
- npm version major --unsafe-perm=true -m "Major version %s"
- *script_merge_master
- *script_npm_publish
patch:
stage: version
only:
refs:
- master
variables:
- $CI_COMMIT_MESSAGE !~ /\[ci\]/
allow_failure: true
before_script:
- *before_npm
- *before_git
script:
- npm version patch --unsafe-perm=true -m "[ci] Patch version %s"
- git push origin HEAD:${CI_COMMIT_BRANCH}
- git push --tags
- *script_npm_publish
backmerge:
stage: backmerge
only:
refs:
- master
variables:
- $CI_COMMIT_MESSAGE =~ /\[ci\]/
before_script:
- *before_git
script:
- git checkout develop
- git pull origin develop
- git merge origin/${CI_COMMIT_BRANCH} --no-ff -m "[ci] Backmerge ${CI_COMMIT_BRANCH} -> develop"
- git push origin develop