-
Notifications
You must be signed in to change notification settings - Fork 3
/
.gitlab-ci.yml
212 lines (193 loc) · 7.67 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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
include:
- project: "waldur/waldur-pipelines"
file: "/templates/stages.yml"
- project: "waldur/waldur-pipelines"
file: "/templates/test/check-merge-compatibility.yml"
Lint MD files:
image: registry.hpc.ut.ee/mirror/library/node:lts-alpine
stage: test
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
changes:
- "*.md"
- docs/**/*
before_script:
- npm install
script:
- node lint-markdown.mjs
Test mkdocs:
image: registry.hpc.ut.ee/mirror/library/python:3.12
stage: test
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
script:
- pip install poetry
- poetry config virtualenvs.create false
- poetry install
- mkdocs build --strict --verbose --site-dir test
.build_before_script: &build_before_script
- echo "[+] Adding SSH keys to the home directory"
- mkdir -p ~/.ssh
- cat "$SSH_JENKINS_GITHUB_PRIVATE_KEY" | tr -d '\r' > ~/.ssh/id_rsa
- cat "$SSH_JENKINS_GITHUB_PUBLIC_KEY" | tr -d '\r' > ~/.ssh/id_rsa.pub
- chmod 600 ~/.ssh/id_rsa
- chmod 600 ~/.ssh/id_rsa.pub
- ssh-keygen -lf ~/.ssh/id_rsa.pub
- ssh-keyscan -H "github.com" >> ~/.ssh/known_hosts
- git config --global user.name "$GITLAB_USER_NAME"
- git config --global user.email "$GITLAB_USER_EMAIL"
.build_script_steps: &build_script_steps
- git remote add github_waldur [email protected]:waldur/waldur-docs.git || true
- git remote -v
- pip install poetry
- poetry config virtualenvs.create false
- poetry install
- cd $CI_PROJECT_DIR
- export ENABLE_PDF_EXPORT=1
- git branch -D gh-pages || true
- git fetch github_waldur
Build latest pages:
image: registry.hpc.ut.ee/mirror/library/python:3.12
stage: deploy
rules:
- if: '$CI_COMMIT_BRANCH == "master"'
script:
- *build_script_steps
- mike deploy latest -p -r github_waldur -b gh-pages
before_script: *build_before_script
Build tagged pages:
image: registry.hpc.ut.ee/mirror/library/python:3.12
stage: postdeploy
rules:
- if: '$CI_COMMIT_TAG =~ /^\d+\.\d+\.\d+$/'
script:
- *build_script_steps
- mike deploy $CI_COMMIT_TAG -p -r github_waldur -b gh-pages
before_script: *build_before_script
Test Docker Compose deployment before tagging:
stage: test
rules:
- if: '$CI_COMMIT_TAG =~ /^\d+\.\d+\.\d+$/'
trigger:
waldur/waldur-docker-compose
Test Helm deployment before tagging:
stage: test
rules:
- if: '$CI_COMMIT_TAG =~ /^\d+\.\d+\.\d+$/'
trigger:
waldur/waldur-helm
Test changelog generation:
image:
name: registry.hpc.ut.ee/mirror/bitnami/git:2.39.1
stage: test
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
variables:
CI_COMMIT_TAG_MESSAGE: "Tag message"
CI_RELEASE_DESCRIPTION: "Release description"
CI_COMMIT_TAG: "v10.0.0"
script:
- export VERSION=${CI_COMMIT_TAG}
- echo $CI_COMMIT_TAG_MESSAGE
- echo $CI_RELEASE_DESCRIPTION
- export TIMESTAMP=$(date)
- PREV_TAG=$(cat docs/about/CHANGELOG.md| grep "##" | head -n 1 | sed "s/## //" )
- echo $PREV_TAG
- sed -i -E -e "s/# Changelog//" docs/about/CHANGELOG.md
- |
echo -e "# Changelog
## $VERSION
Notes: ${CI_RELEASE_DESCRIPTION:-None}
* Waldur Mastermind: [tag diff](https://github.com/waldur/waldur-mastermind/compare/$PREV_TAG...$CI_COMMIT_TAG)
* Waldur Homeport: [tag diff](https://github.com/waldur/waldur-homeport/compare/$PREV_TAG...$CI_COMMIT_TAG)
* Waldur Helm: [tag diff](https://github.com/waldur/waldur-helm/compare/$PREV_TAG...$CI_COMMIT_TAG)
* Waldur Docker Compose: [tag diff](https://github.com/waldur/waldur-docker-compose/compare/$PREV_TAG...$CI_COMMIT_TAG)
Date: $TIMESTAMP\n" | cat - docs/about/CHANGELOG.md > tmp
- cat tmp
- mv -f tmp docs/about/CHANGELOG.md
Tag Mastermind, Homeport and Helm repositories:
image:
name: registry.hpc.ut.ee/mirror/bitnami/git:2.39.1
stage: deploy
rules:
- if: '$CI_COMMIT_TAG =~ /^\d+\.\d+\.\d+$/'
before_script:
- git config --global user.name "$GITLAB_USER_NAME"
- git config --global user.email "$GITLAB_USER_EMAIL"
- git remote set-url origin "https://gitlab-ci-token:${GITLAB_TOKEN}@${CI_SERVER_HOST}/${CI_PROJECT_PATH}.git"
- git remote -v
- git fetch origin master
- git branch -D master || true
- git checkout --track origin/master
- git pull
- export VERSION=${CI_COMMIT_TAG}
- echo $CI_COMMIT_TAG_MESSAGE
- echo $CI_RELEASE_DESCRIPTION
- export TIMESTAMP=$(date)
- PREV_TAG=$(cat docs/about/CHANGELOG.md| grep "##" | head -n 1 | sed "s/## //" )
- echo $PREV_TAG
# Drop first 2 lines from the changelog
- sed -i '1,2d' docs/about/CHANGELOG.md
- |
echo -e "# Changelog
## $VERSION
Notes: ${CI_COMMIT_TAG_MESSAGE:-None}
* Waldur Mastermind: [tag diff](https://github.com/waldur/waldur-mastermind/compare/$PREV_TAG...$CI_COMMIT_TAG)
* Waldur Homeport: [tag diff](https://github.com/waldur/waldur-homeport/compare/$PREV_TAG...$CI_COMMIT_TAG)
* Waldur Helm: [tag diff](https://github.com/waldur/waldur-helm/compare/$PREV_TAG...$CI_COMMIT_TAG)
* Waldur Docker Compose: [tag diff](https://github.com/waldur/waldur-docker-compose/compare/$PREV_TAG...$CI_COMMIT_TAG)
* Waldur Prometheus Exporter: [tag diff](https://github.com/waldur/waldur-prometheus-exporter/compare/$PREV_TAG...$CI_COMMIT_TAG)
Date: $TIMESTAMP\n" | cat - docs/about/CHANGELOG.md > tmp
- cat tmp
- mv -f tmp docs/about/CHANGELOG.md
- git --no-pager diff
- git add docs/about/CHANGELOG.md
- git commit -m "Update changelog for $CI_COMMIT_TAG"
- git --no-pager show
- git push origin master
script:
- git clone "https://gitlab-ci-token:$GITLAB_TOKEN@$CI_SERVER_HOST/waldur/waldur-mastermind.git"
- cd waldur-mastermind/
- git tag -a $CI_COMMIT_TAG -m "$CI_COMMIT_TAG_MESSAGE"
- git push origin $CI_COMMIT_TAG
- cd ../
- git clone "https://gitlab-ci-token:$GITLAB_TOKEN@$CI_SERVER_HOST/waldur/waldur-homeport.git"
- cd waldur-homeport/
- git tag -a $CI_COMMIT_TAG -m "$CI_COMMIT_TAG_MESSAGE"
- git push origin $CI_COMMIT_TAG
- cd ../
- git clone "https://gitlab-ci-token:$GITLAB_TOKEN@$CI_SERVER_HOST/waldur/waldur-helm.git"
- cd waldur-helm/
# Add new tag to Chart.yaml and values.yaml
- |
sed -i -E -e "s/^version: ('.*'|.*)$/version: $CI_COMMIT_TAG/" waldur/Chart.yaml
- |
sed -i -E -e "s/^appVersion: ('.*'|.*)$/appVersion: \"$CI_COMMIT_TAG\"/" waldur/Chart.yaml
- |
sed -i -E -e "s/^ imageTag: ('.*'|.*)$/ imageTag: \"$CI_COMMIT_TAG\"/" waldur/values.yaml
- git status
- git diff
- git add waldur/Chart.yaml waldur/values.yaml
- git commit -m "Set target version to ${CI_COMMIT_TAG}"
- git push -o "ci.skip"
- git tag -a $CI_COMMIT_TAG -m "$CI_COMMIT_TAG_MESSAGE"
- git push origin $CI_COMMIT_TAG
- cd ../
- git clone "https://gitlab-ci-token:$GITLAB_TOKEN@$CI_SERVER_HOST/waldur/waldur-docker-compose.git"
- cd waldur-docker-compose/
# Add new tag to .env.example
- |
sed -i -E -e "s/^WALDUR_MASTERMIND_IMAGE_TAG=('.*'|.*)$/WALDUR_MASTERMIND_IMAGE_TAG=$CI_COMMIT_TAG/" .env.example
- |
sed -i -E -e "s/^WALDUR_HOMEPORT_IMAGE_TAG=('.*'|.*)$/WALDUR_HOMEPORT_IMAGE_TAG=$CI_COMMIT_TAG/" .env.example
- git status
- git diff
- git add .env.example
- git commit -m "Set target version to ${CI_COMMIT_TAG}"
- git push -o "ci.skip"
- git tag -a $CI_COMMIT_TAG -m "$CI_COMMIT_TAG_MESSAGE"
- git push origin $CI_COMMIT_TAG
- git clone "https://gitlab-ci-token:$GITLAB_TOKEN@$CI_SERVER_HOST/waldur/waldur-prometheus-exporter.git"
- cd waldur-prometheus-exporter/
- git tag -a $CI_COMMIT_TAG -m "$CI_COMMIT_TAG_MESSAGE"
- git push origin $CI_COMMIT_TAG