-
Notifications
You must be signed in to change notification settings - Fork 54
/
config.yml
306 lines (295 loc) · 10 KB
/
config.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
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
# Golang CircleCI 2.0 configuration
version: 2.1
jobs:
build-node:
docker:
- image: cimg/node:lts
working_directory: ~/repo
steps:
- checkout
- run: npm install
- run: npm run ci
build:
docker:
- image: cimg/go:1.17
environment:
working_directory: ~/go/src/github.com/SAP/cloud-mta-build-tool
steps:
- checkout
- run: go version
- run: go env
- run:
name: install dependencies
command: |
go mod vendor
- run: go test -v ./...
- run: sudo chown circleci:circleci $GOPATH/bin
- run: make tools
- run: make lint
- run:
name: cov install coverge deps
command: |
go get golang.org/x/tools/cmd/cover
go get golang.org/x/net/html/charset
go get github.com/mattn/goveralls
go get github.com/modocache/gover
go install github.com/mattn/goveralls
go install github.com/modocache/gover
go get golang.org/x/crypto/ssh/terminal
- run: go test -v ./... -coverprofile=mta.coverprofile
- run: gover
- run: goveralls -v -service=circle-ci -coverprofile=gover.coverprofile -repotoken $COVERALLS_TOKEN
test:
docker:
- image: shimit/mbt_multi:0.3.0
working_directory: ~/go/src/github.com/SAP/cloud-mta-build-tool
steps:
- checkout
- run:
name: install dependencies
command: |
go mod vendor
- run: cf login -a $CF_API -o $ORG -s $SPACE -u $TECH_USER -p $TECH_PASS
- run: cd integration && go test -tags=integration
compliance:
docker:
- image: cimg/python:3.10.0
working_directory: ~/go/src/github.com/SAP/cloud-mta-build-tool
steps:
- checkout
- run:
name: compliance check
command: |
pip3 install --user reuse
~/.local/bin/reuse lint
ghpages:
docker:
- image: squidfunk/mkdocs-material:4.3.1
working_directory: ~/go/src/github.com/SAP/cloud-mta-build-tool
steps:
- checkout
- run:
name: release to GitHub Pages
command: |
cd docs
mkdocs gh-deploy --config-file ../docs/mkdocs.yml --remote-branch gh-pages
release-to-github:
docker:
- image: cimg/go:1.17
working_directory: ~/go/src/github.com/SAP/cloud-mta-build-tool
steps:
- add_ssh_keys:
fingerprints:
- "c3:2b:e9:bb:d5:05:32:ab:df:ce:2b:c3:e5:f7:95:42"
- checkout
- run:
name: install dependencies
command: |
go mod vendor
- run:
name: bump version
command: |
#Make sure HEAD points to master
echo "Release processed by ${CLOUD_MTA_BOT_EMAIL}/${CLOUD_MTA_BOT_USER}"
git checkout master
CURR_MBT_VERSION=$(cat ./VERSION)
echo "Current release: ${CURR_MBT_VERSION}"
MBT_VERSION=$(echo $CURR_MBT_VERSION |awk -F. -v MAJOR_VAR="$MAJOR" -v MINOR_VAR="$MINOR" -v PATCH_VAR="$PATCH" '{
if (MAJOR_VAR == "true"){
$1++
$2=0
$3=0
} else if (MINOR_VAR == "true"){
$2++
$3=0
} else if (PATCH_VAR == "true"){
$3++
}
printf "%d.%d.%d\n", $1, $2 ,$3
}')
echo "New release: ${MBT_VERSION}"
#Update new version in files
sed -i "/\"version\":/s/${CURR_MBT_VERSION}/${MBT_VERSION}/" ./package.json
sed -i "/cli_version:/s/${CURR_MBT_VERSION}/${MBT_VERSION}/" ./configs/version.yaml
sed -i "s/${CURR_MBT_VERSION}/${MBT_VERSION}/" ./VERSION
sed -i "/ARG MBT_VERSION=/ s/${CURR_MBT_VERSION}/${MBT_VERSION}/" ./Dockerfile_mbtci_java8
sed -i "/ARG MBT_VERSION=/ s/${CURR_MBT_VERSION}/${MBT_VERSION}/" ./Dockerfile_mbtci_java11
sed -i "/ARG MBT_VERSION=/ s/${CURR_MBT_VERSION}/${MBT_VERSION}/" ./Dockerfile_mbtci_java17
sed -i "s/- ${CURR_MBT_VERSION}/- ${MBT_VERSION}/" ./test/goss/goss_template.yaml
sed -i "/- Cloud MTA Build Tool -/s/${CURR_MBT_VERSION}/${MBT_VERSION}/" ./README.md
#Generate version file
go generate -run "go run ./internal/buildtools/embed.go ./internal/buildtools/buildtools_msg.go -source=./configs/version.yaml -target=./internal/version/version_cfg.go -name=VersionConfig -package=version"
#Add all updated files to commit
git add ./package.json ./configs/version.yaml ./VERSION ./internal/version/version_cfg.go ./Dockerfile_mbtci_java8 ./Dockerfile_mbtci_java11 ./Dockerfile_mbtci_java17 ./test/goss/goss_template.yaml ./README.md
git config user.email "${CLOUD_MTA_BOT_EMAIL}"
git config user.name "${CLOUD_MTA_BOT_USER}"
git commit --allow-empty -m "[skip ci] Bump version ${MBT_VERSION}"
#Push commit directly to master
git push -q https://github.com/SAP/cloud-mta-build-tool.git master
#Tag
git tag -a v${MBT_VERSION} -m "New release ${MBT_VERSION}"
git push https://github.com/SAP/cloud-mta-build-tool.git v${MBT_VERSION}
- run:
name: release new version
command: |
#Make sure HEAD points to master
git checkout master
export GITHUB_TOKEN=${CLOUD_MTA_BOT_GITHUB_TOKEN}
curl -sL https://git.io/goreleaser | bash
publish-to-dockerhub:
docker:
- image: cimg/go:1.17
working_directory: ~/go/src/github.com/SAP/cloud-mta-build-tool
steps:
- checkout
- setup_remote_docker:
version: 20.10.6
- run:
name: build image pre-setup
command: |
#Make sure HEAD points to master
git checkout master
git fetch
git rebase
- run:
name: "build Java 17 & Node 16 image"
command: |
MBT_VERSION=$(cat ./VERSION)
sh $PWD/scripts/build_image 17 16.18.1 ${MBT_VERSION}
- run:
name: publish image
command: |
#Make sure HEAD points to master
git checkout master
git fetch
git rebase
MBT_VERSION=$(cat ./VERSION)
echo "Image release: ${MBT_VERSION}"
#Push to Docker Hub
echo "$DOCKER_HUB_TOKEN" | docker login --username $DOCKER_HUB_USER --password-stdin
sh $PWD/scripts/publish_image 17 16.18.1 ${MBT_VERSION} "devxci"
#Push to GitHub Container Registry
echo "$CLOUD_MTA_BOT_GITHUB_TOKEN" | docker login "ghcr.io" --username $CLOUD_MTA_BOT_USER --password-stdin
sh $PWD/scripts/publish_image 17 16.18.1 ${MBT_VERSION} "ghcr.io/sap"
- run:
# This won't run if previous commands have failed so the tag should be removed **manually**
name: remove dummy release tag
command: |
git push https://github.com/SAP/cloud-mta-build-tool.git --delete release
publish-to-npm:
docker:
- image: cimg/node:lts
working_directory: ~/repo
steps:
- checkout
- run:
#Make sure HEAD points to master
# TODO: this is horrible as it makes the build non-reproducible
# but the `release` job performs a bump commit as part of the release flow
# so the fetch/rebase is actually needed (unless release process refactored...)
name: rebase to master
command: |
git checkout master
git fetch
git rebase
- run:
# mbt is an unscoped package, do not need to add "--access public" option in npm publish cmd
name: publish to npm
command: |
echo "//registry.npmjs.org/:_authToken=$CLOUD_MTA_BOT_NPM_TOKEN" > .npmrc
npm install
npm run ci
npm publish
workflows:
version: 2
# when sub-branch's code is commited, this workflow will be execed
on_pr_build:
jobs:
- build:
filters:
branches:
ignore: master
- build-node:
filters:
branches:
ignore: master
- compliance:
filters:
branches:
ignore: master
- test:
requires:
- build
filters:
branches:
ignore: master
# when master's code is commited or merged from sub-branch, this workflow will be execed
on_merge_build_test:
jobs:
- build:
filters:
branches:
only: master
- build-node:
filters:
branches:
only: master
- compliance:
filters:
branches:
only: master
- test:
requires:
- build
filters:
branches:
only: master
# when a branch is taged by "release", this workflow will be execed
on_tag_build_release_publish:
jobs:
- build:
filters:
tags:
only: /release/
branches:
ignore: /.*/
- test:
requires:
- build
filters:
tags:
only: /release/
branches:
ignore: /.*/
- ghpages:
requires:
- test
filters:
tags:
only: /release/
branches:
ignore: /.*/
- release-to-github:
requires:
- test
filters:
tags:
only: /release/
branches:
ignore: /.*/
- publish-to-npm:
requires:
- release-to-github
filters:
tags:
only: /release/
branches:
ignore: /.*/
- publish-to-dockerhub:
requires:
- publish-to-npm
filters:
tags:
only: /release/
branches:
ignore: /.*/