-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
53 lines (47 loc) · 1.31 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
stages:
- version
- build
- publish
variables:
PACKAGE_REGISTRY_PROJECT_ID: 194 # because before_script doesn't have access to CICD custom variables
.config package registry:
before_script:
- npm config set -- //${CI_SERVER_HOST}/api/v4/projects/${PACKAGE_REGISTRY_PROJECT_ID}/packages/npm/:_authToken=${CI_JOB_TOKEN}
- npm config set @${CI_PROJECT_NAMESPACE}:registry=https://${CI_SERVER_HOST}/api/v4/projects/${PACKAGE_REGISTRY_PROJECT_ID}/packages/npm/
.only for tagged commit:
rules:
- if: "$CI_COMMIT_TAG && $CI_COMMIT_REF_PROTECTED"
when: on_success
- when: never
version package:
image: node:latest
stage: version
before_script:
- apt-get update -y
- apt-get install -y gettext jq
script:
- jq ".version = \"$CI_COMMIT_TAG\"" package.json > package_tmp.json && mv package_tmp.json package.json
artifacts:
paths:
- package.json
rules:
- !reference [.only for tagged commit, rules]
build npm dist:
image: node:latest
stage: build
extends: .config package registry
script:
- npm ci
- npm run build
artifacts:
paths:
- dist
expire_in: 1 day
publish npm package:
image: node:latest
stage: publish
extends: .config package registry
script:
- npm publish
rules:
- !reference [.only for tagged commit, rules]