-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
125 lines (118 loc) · 2.74 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
image: node:16
stages:
- build
- test
- deploy
- "release"
- publish
build:
stage: build
script:
- npm ci
- npm run build
cache:
key: node-modules-$CI_COMMIT_REF_SLUG
paths:
- node_modules/
artifacts:
expire_in: 1 days
when: on_success
paths:
- node_modules/
- build/
test:
stage: test
coverage: /All files[^|]*\|[^|]*\s+([\d\.]+)/
dependencies:
- build
script:
- npm run test:ci
cache:
key: node-modules-$CI_COMMIT_REF_SLUG
paths:
- node_modules/
artifacts:
paths:
- coverage/
when: always
reports:
junit:
- junit.xml
coverage_report:
coverage_format: cobertura
path: coverage/cobertura-coverage.xml
pages:
stage: deploy
dependencies:
- test
script:
- mkdir public-tmp
- cp -r coverage/* public-tmp
- mv public-tmp public
artifacts:
paths:
- public
only:
- master
changelog:
stage: release
only:
- master
cache:
key: node-modules-$CI_COMMIT_REF_SLUG
paths:
- node_modules/
artifacts:
when: on_success
paths:
- RELEASE_NOTES.md
- package.json
- package-lock.json
reports:
dotenv: build.env
before_script:
- "which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )"
- eval $(ssh-agent -s)
- ssh-add <(echo "$GIT_SSH_PRIV_KEY")
- mkdir -p ~/.ssh
- ssh-keyscan -H gitlab.com >> ~/.ssh/known_hosts
- git config --global user.email "${GITLAB_USER_EMAIL}"
- git config --global user.name "${GITLAB_USER_NAME}"
script:
- git remote rm origin && git remote add origin git@gitlab.com:$CI_PROJECT_PATH.git
- git pull origin $CI_COMMIT_REF_NAME
- |-
if [ "$RELEASE_AS" != "" ]; then
npm run version -- --release-as $RELEASE_AS
else
npm run version
fi
- echo "PACKAGE_VERSION=$(node -p "require('./package.json').version")" >> build.env
- git push -o ci.skip origin HEAD:$CI_COMMIT_REF_NAME # Pushes to the same branch as the trigger
- diff --changed-group-format='%>' --unchanged-group-format='' <( git show HEAD~1:CHANGELOG.md ) CHANGELOG.md > RELEASE_NOTES.md || true
release_job:
only:
- master
needs: ["changelog"]
stage: release
image: registry.gitlab.com/gitlab-org/release-cli:latest
script:
- echo $PACKAGE_VERSION
release:
tag_name: $PACKAGE_VERSION
name: "Release $PACKAGE_VERSION"
description: RELEASE_NOTES.md
publish:
when: manual
only:
- master
stage: publish
dependencies:
- build
- changelog
interruptible: false
retry: 1
script:
- npm config set -- '//registry.npmjs.org/:_authToken' "${NPM_AUTH_TOKEN}"
- head package.json
- npm publish --access public