-
Notifications
You must be signed in to change notification settings - Fork 9
/
.gitlab-ci.yml
60 lines (55 loc) · 1.58 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
stages:
- prepare
- test
- build
- publish
default:
tags:
- docker
before_script:
- sed -i -- "s/\"0.0.0\"/\"$CI_COMMIT_TAG\"/g" package.json
- sed -i -- "s/\"cytomine-client\"/\"@${CI_PROJECT_ROOT_NAMESPACE}\/cytomine-client\"/g" package.json
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- .npm/
workflow:
rules:
- if: $CI_COMMIT_TAG != null && $CI_COMMIT_TAG =~ /^[~^]?([\dvx*]+(?:[-.](?:[\dx*]+|alpha|beta))*)$/
variables:
PUBLISH_PACKAGE: "true"
- if: $CI_COMMIT_TAG == null || $CI_COMMIT_REF_NAME !~ /^[~^]?([\dvx*]+(?:[-.](?:[\dx*]+|alpha|beta))*)*$/
variables:
PUBLISH_PACKAGE: "false"
- when: always
# TODO tests require a full cytomine instance to run, skip for now
# Jenkins tests used to run against a full cytomine but with with fixed versions of components so it was not ideal
# run-tests:
# stage: test
build-js-package:
image: node:14.16.1
stage: build
rules:
- if: $PUBLISH_PACKAGE == "true"
script:
- npm ci --cache .npm --prefer-offline
- npm run build
artifacts:
paths:
- dist/cytomine*
# TODO upload to npm public packaget registry
publish-js-package:
image: node:14.16.1
stage: publish
needs:
- job: build-js-package
artifacts: true
rules:
- if: $PUBLISH_PACKAGE == "true"
script:
- |
{
echo "@${CI_PROJECT_ROOT_NAMESPACE}:registry=${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/npm/"
echo "${CI_API_V4_URL#https?}/projects/${CI_PROJECT_ID}/packages/npm/:_authToken=\${CI_JOB_TOKEN}"
} | tee -a .npmrc
- npm publish