-
Notifications
You must be signed in to change notification settings - Fork 17
/
.gitlab-ci.yml
72 lines (68 loc) · 2.37 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
include:
- project: infrastructure/gitlab_shared_ci
file: Sonarqube.gitlab-ci.yml
stages:
- test
- publish
test:
image: node:lts
stage: test
script:
- npm ci
- npm run test:ci
release-publish:
image:
name: git.corellium.co:5050/corellium/ci/docker/nodejs:16
pull_policy: [always, if-not-present]
stage: publish
before_script:
# Configure npmrc to publish to npm registry
- echo "//registry.npmjs.org/:_authToken=${NPM_AUTH_TOKEN}" > .npmrc
# Set up GitHub SSH key
- eval $(ssh-agent -s)
- echo "" >> "${GITHUB_DEPLOY_KEY}" # Add any missing newline on the end ugh
- chmod 400 "${GITHUB_DEPLOY_KEY}"
- ssh-add "${GITHUB_DEPLOY_KEY}"
- mkdir -p ~/.ssh
- ssh-keyscan github.com >> ~/.ssh/known_hosts
script:
# Attempt to parse commit tag of format vX.X.X
- RELEASE_VERSION=${CI_COMMIT_TAG#v}
- |
if [[ -z "$RELEASE_VERSION" ]]; then
echo "Error: Failed to parse release version from tag ${CI_COMMIT_TAG}"
exit 1
fi
- LAST_TAG="$(git describe --tags --abbrev=0 HEAD~1)"
- jq ".version = \"${RELEASE_VERSION}\"" package.json > temp.json
- mv temp.json package.json
- git push [email protected]:corellium/corellium-api.git HEAD:master
- git push [email protected]:corellium/corellium-api.git "refs/tags/${CI_COMMIT_TAG}"
- jq . package.json
- npm publish
rules:
- if: '$CI_COMMIT_TAG =~ /^v/'
local-publish:
image:
name: git.corellium.co:5050/corellium/ci/docker/nodejs:16
pull_policy: [always, if-not-present]
stage: publish
before_script:
# Configure the registry URL and authentication to publish to GitLab registry
- echo "//git.corellium.co/api/v4/projects/${CI_PROJECT_ID}/packages/npm/:_authToken=${CI_JOB_TOKEN}" > .npmrc
- echo "@corellium:registry=${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/npm/" >> .npmrc
script:
# Attempt to parse a version number from the tag
- PKG_VERSION="$(echo ${CI_COMMIT_TAG} | sed -n 's/.*v\([0-9]\+\.[0-9]\+\.[0-9]\+\).*/\1/p')"
- |
if [[ -z "$PKG_VERSION" ]]; then
echo "Error: Failed to parse version from tag ${CI_COMMIT_TAG}"
exit 1
fi
# Update package.json with provided version number and publish
- jq ".version = \"${PKG_VERSION}\"" package.json > temp.json
- mv temp.json package.json
- jq . package.json
- npm publish
only:
- tags