-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
639 lines (639 loc) · 25.5 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
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
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
default:
image: $CI_REGISTRY_IMAGE/projet-integrateur-cicd
cache:
paths:
- .cache/pre-commit
before_script:
# Fix Unistra GitLab Docker runner permission issues
- echo $(ls -ld .git/ | awk '{print $3}') > RUNNER_USER
- mkdir -p .cache/pre-commit/
- chown -R $(whoami) .
after_script:
# Fix Unistra GitLab Docker runner permission issues
- chown -fR "$(cat RUNNER_USER)" .cache/pre-commit/
stages:
- build
- test
- deploy
- release
variables:
PRE_COMMIT_HOME: "$CI_PROJECT_DIR/.cache/pre-commit"
RELEASE_TAG: '/^v\d+\.\d+\.\d+.*$/'
CLIENT_PACKAGE_NAME: "Unity-Client"
test 1/2:
stage: test
dependencies: []
script:
- dotnet restore server/OkeyApi
- dotnet restore server/OkeyServer
- pre-commit run -a
rules:
- if: $CI_COMMIT_BRANCH
allow_failure: true
tags:
- kubernetes
test 2/2:
stage: test
dependencies: []
script:
- dotnet docfx docs/docfx.json
- cp -r docs/_site public
rules:
- if: $CI_COMMIT_BRANCH
artifacts:
paths:
- public
tags:
- kubernetes
docker-ci:
# Docker, Docker in Docker (dind) and Buildah don't work
# with Unistra GitLab's kubernetes shared runners due to
# various permission and runner configuration issues (user space/kernel space)
image:
name: gcr.io/kaniko-project/executor:v1.21.1-debug
entrypoint: [""]
stage: build
variables:
IMAGE_NAME: projet-integrateur-cicd
before_script:
# Store registry auth credentials for Kaniko to read during push
- echo "{\"auths\":{\"${CI_REGISTRY}\":{\"auth\":\"$(printf "%s:%s" "${CI_REGISTRY_USER}" "${CI_REGISTRY_PASSWORD}" | base64 | tr -d '\n')\"}}}" > /kaniko/.docker/config.json
script:
- /kaniko/executor --context "${CI_PROJECT_DIR}" --dockerfile "${CI_PROJECT_DIR}/docker/CICD.Dockerfile" --destination "${CI_REGISTRY_IMAGE}/${IMAGE_NAME}"
after_script: ""
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
changes:
- docker/CICD.Dockerfile
- requirements.txt
- .config/dotnet-tools.json
when: always
tags:
- kubernetes
docker-api:
# Docker, Docker in Docker (dind) and Buildah don't work
# with Unistra GitLab's kubernetes shared runners due to
# various permission and runner configuration issues (user space/kernel space)
image:
name: gcr.io/kaniko-project/executor:v1.21.1-debug
entrypoint: [""]
stage: build
variables:
IMAGE_NAME: okeyapi
before_script:
# Store registry auth credentials for Kaniko to read during push
- echo "{\"auths\":{\"${CI_REGISTRY}\":{\"auth\":\"$(printf "%s:%s" "${CI_REGISTRY_USER}" "${CI_REGISTRY_PASSWORD}" | base64 | tr -d '\n')\"}}}" > /kaniko/.docker/config.json
- IMAGE_TAG=$(if [ "${CI_COMMIT_BRANCH}" ]; then echo "dev-${CI_COMMIT_SHORT_SHA}"; else echo ${CI_COMMIT_TAG}; fi)
- IMAGE_SLIDING_TAG=$(if [ "${CI_COMMIT_BRANCH}" ]; then echo "dev"; else echo "latest"; fi)
script:
- /kaniko/executor --context "${CI_PROJECT_DIR}" --dockerfile "${CI_PROJECT_DIR}/docker/OkeyApi.Dockerfile" --destination "${CI_REGISTRY_IMAGE}/${IMAGE_NAME}:${IMAGE_TAG}" --destination "${CI_REGISTRY_IMAGE}/${IMAGE_NAME}:${IMAGE_SLIDING_TAG}"
after_script: ""
rules:
- if: $CI_COMMIT_BRANCH == "back-end"
changes:
- docker/OkeyApi.Dockerfile
- docker/OkeyApi.Dockerfile.dockerignore
- server/OkeyApi/**/*.cs
- server/OkeyApi/appsettings*.json
- server/OkeyApi/**/launchSettings.json
- server/OkeyApi/*.csproj
- server/OkeyApi/*.sln
when: always
- if: '$CI_COMMIT_TAG =~ $RELEASE_TAG'
when: always
tags:
- kubernetes
docker-server:
# Docker, Docker in Docker (dind) and Buildah don't work
# with Unistra GitLab's kubernetes shared runners due to
# various permission and runner configuration issues (user space/kernel space)
image:
name: gcr.io/kaniko-project/executor:v1.21.1-debug
entrypoint: [""]
stage: build
variables:
IMAGE_NAME: okeyserver
before_script:
# Store registry auth credentials for Kaniko to read during push
- echo "{\"auths\":{\"${CI_REGISTRY}\":{\"auth\":\"$(printf "%s:%s" "${CI_REGISTRY_USER}" "${CI_REGISTRY_PASSWORD}" | base64 | tr -d '\n')\"}}}" > /kaniko/.docker/config.json
- IMAGE_TAG=$(if [ "${CI_COMMIT_BRANCH}" ]; then echo "dev-${CI_COMMIT_SHORT_SHA}"; else echo ${CI_COMMIT_TAG}; fi)
- IMAGE_SLIDING_TAG=$(if [ "${CI_COMMIT_BRANCH}" ]; then echo "dev"; else echo "latest"; fi)
script:
- /kaniko/executor --context "${CI_PROJECT_DIR}" --dockerfile "${CI_PROJECT_DIR}/docker/OkeyServer.Dockerfile" --destination "${CI_REGISTRY_IMAGE}/${IMAGE_NAME}:${IMAGE_TAG}" --destination "${CI_REGISTRY_IMAGE}/${IMAGE_NAME}:${IMAGE_SLIDING_TAG}"
after_script: ""
rules:
- if: $CI_COMMIT_BRANCH == "back-end"
changes:
- docker/OkeyServer.Dockerfile
- docker/OkeyServer.Dockerfile.dockerignore
- server/OkeyServer/**/*.cs
- server/OkeyServer/*.csproj
- server/OkeyServer/*.sln
when: always
- if: '$CI_COMMIT_TAG =~ $RELEASE_TAG'
when: always
tags:
- kubernetes
docker-db-init:
# Docker, Docker in Docker (dind) and Buildah don't work
# with Unistra GitLab's kubernetes shared runners due to
# various permission and runner configuration issues (user space/kernel space)
image:
name: gcr.io/kaniko-project/executor:v1.21.1-debug
entrypoint: [""]
stage: build
variables:
IMAGE_NAME: db-init
before_script:
# Store registry auth credentials for Kaniko to read during push
- echo "{\"auths\":{\"${CI_REGISTRY}\":{\"auth\":\"$(printf "%s:%s" "${CI_REGISTRY_USER}" "${CI_REGISTRY_PASSWORD}" | base64 | tr -d '\n')\"}}}" > /kaniko/.docker/config.json
- IMAGE_TAG=$(if [ "${CI_COMMIT_BRANCH}" ]; then echo "dev-${CI_COMMIT_SHORT_SHA}"; else echo ${CI_COMMIT_TAG}; fi)
- IMAGE_SLIDING_TAG=$(if [ "${CI_COMMIT_BRANCH}" ]; then echo "dev"; else echo "latest"; fi)
script:
- /kaniko/executor --context "${CI_PROJECT_DIR}" --dockerfile "${CI_PROJECT_DIR}/docker/DB-Init.Dockerfile" --destination "${CI_REGISTRY_IMAGE}/${IMAGE_NAME}:${IMAGE_TAG}" --destination "${CI_REGISTRY_IMAGE}/${IMAGE_NAME}:${IMAGE_SLIDING_TAG}"
after_script: ""
rules:
- if: $CI_COMMIT_BRANCH == "back-end"
changes:
- docker/DB-Init.Dockerfile
- docker/DB-Init.Dockerfile.dockerignore
- server/OkeyApi/**/*.cs
- server/OkeyApi/appsettings*.json
- server/OkeyApi/**/launchSettings.json
- server/OkeyApi/*.csproj
- server/OkeyApi/*.sln
when: always
- if: '$CI_COMMIT_TAG =~ $RELEASE_TAG'
when: always
tags:
- kubernetes
docker-website:
# Docker, Docker in Docker (dind) and Buildah don't work
# with Unistra GitLab's kubernetes shared runners due to
# various permission and runner configuration issues (user space/kernel space)
image:
name: gcr.io/kaniko-project/executor:v1.21.1-debug
entrypoint: [""]
stage: build
variables:
IMAGE_NAME: okeywebsite
before_script:
# Store registry auth credentials for Kaniko to read during push
- echo "{\"auths\":{\"${CI_REGISTRY}\":{\"auth\":\"$(printf "%s:%s" "${CI_REGISTRY_USER}" "${CI_REGISTRY_PASSWORD}" | base64 | tr -d '\n')\"}}}" > /kaniko/.docker/config.json
- IMAGE_TAG=$(if [ "${CI_COMMIT_BRANCH}" ]; then echo "dev-${CI_COMMIT_SHORT_SHA}"; else echo ${CI_COMMIT_TAG}; fi)
- IMAGE_SLIDING_TAG=$(if [ "${CI_COMMIT_BRANCH}" ]; then echo "dev"; else echo "latest"; fi)
script:
- /kaniko/executor --context "${CI_PROJECT_DIR}" --dockerfile "${CI_PROJECT_DIR}/docker/OkeyWebsite.Dockerfile" --destination "${CI_REGISTRY_IMAGE}/${IMAGE_NAME}:${IMAGE_TAG}" --destination "${CI_REGISTRY_IMAGE}/${IMAGE_NAME}:${IMAGE_SLIDING_TAG}"
after_script: ""
rules:
- if: $CI_COMMIT_BRANCH == "back-end"
changes:
- docker/OkeyWebsite.Dockerfile
- server/okeywebsite/new_app/**/*
when: always
- if: '$CI_COMMIT_TAG =~ $RELEASE_TAG'
when: always
tags:
- kubernetes
unity-linux-test:
image:
name: unityci/editor:ubuntu-2022.3.19f1-base-3.0.1
stage: build
needs:
- job: unity-linux-local-test
artifacts: false
- job: unity-mac-local-test
artifacts: false
- job: unity-windows-local-test
artifacts: false
variables:
BUILD_PATH: client/OkeyClient/Builds/Linux
before_script:
- /opt/unity/Editor/Unity -quit -batchmode -nographics -serial "$UNITY_SERIAL" -username "$UNITY_EMAIL" -password "$UNITY_PASSWORD"
- git config --global --add safe.directory "$CI_PROJECT_DIR"
script:
- export OKEY_BUILD_VERSION=$(scripts/generate_unity_build_version.sh)
- /opt/unity/Editor/Unity -quit -batchmode -nographics -logFile - -projectPath client/OkeyClient -timestamps -executeMethod Builder.LinuxTestBuild
- tar cJf "OkeyTest_Linux_x86-64_${OKEY_BUILD_VERSION}.tar.xz" ${BUILD_PATH}/OkeyTest ${BUILD_PATH}/OkeyTest_s.debug ${BUILD_PATH}/OkeyTest_Data ${BUILD_PATH}/UnityPlayer.so ${BUILD_PATH}/UnityPlayer_s.debug
- mkdir -p public/
- mv "OkeyTest_Linux_x86-64_${OKEY_BUILD_VERSION}.tar.xz" public/
after_script:
- /opt/unity/Editor/Unity -quit -batchmode -nographics -returnlicense -username "$UNITY_EMAIL" -password "$UNITY_PASSWORD"
rules:
- if: $CI_COMMIT_BRANCH == "front-end"
changes:
- client/OkeyClient/**/*
when: always
- if: $CI_COMMIT_TAG =~ $RELEASE_TAG
when: always
artifacts:
name: "unity-linux-test-build"
paths:
- public
expire_in: 30 days
tags:
- kubernetes
unity-mac-test:
image:
name: unityci/editor:ubuntu-2022.3.19f1-mac-mono-3.0.1
stage: build
needs:
- job: unity-linux-local-test
artifacts: false
- job: unity-mac-local-test
artifacts: false
- job: unity-windows-local-test
artifacts: false
variables:
BUILD_PATH: client/OkeyClient/Builds/Mac
before_script:
- /opt/unity/Editor/Unity -quit -batchmode -nographics -serial "$UNITY_SERIAL" -username "$UNITY_EMAIL" -password "$UNITY_PASSWORD"
- git config --global --add safe.directory "$CI_PROJECT_DIR"
script:
- export OKEY_BUILD_VERSION=$(scripts/generate_unity_build_version.sh)
- /opt/unity/Editor/Unity -quit -batchmode -nographics -logFile - -projectPath client/OkeyClient -timestamps -executeMethod Builder.MacTestBuild
- chmod a+x ${BUILD_PATH}/OkeyTest.app/Contents/MacOS/Okey
- tar cJf "OkeyTest_Mac_Universal_${OKEY_BUILD_VERSION}.tar.xz" ${BUILD_PATH}/OkeyTest.app
- mkdir -p public/
- mv "OkeyTest_Mac_Universal_${OKEY_BUILD_VERSION}.tar.xz" public/
after_script:
- /opt/unity/Editor/Unity -quit -batchmode -nographics -returnlicense -username "$UNITY_EMAIL" -password "$UNITY_PASSWORD"
rules:
- if: $CI_COMMIT_BRANCH == "front-end"
changes:
- client/OkeyClient/**/*
when: always
- if: $CI_COMMIT_TAG =~ $RELEASE_TAG
when: always
artifacts:
name: "unity-mac-test-build"
paths:
- public
expire_in: 30 days
tags:
- kubernetes
unity-windows-test:
image:
name: unityci/editor:ubuntu-2022.3.19f1-windows-mono-3.0.1
stage: build
needs:
- job: unity-linux-local-test
artifacts: false
- job: unity-mac-local-test
artifacts: false
- job: unity-windows-local-test
artifacts: false
variables:
BUILD_PATH: client/OkeyClient/Builds/Windows
before_script:
- /opt/unity/Editor/Unity -quit -batchmode -nographics -serial "$UNITY_SERIAL" -username "$UNITY_EMAIL" -password "$UNITY_PASSWORD"
- git config --global --add safe.directory "$CI_PROJECT_DIR"
script:
- export OKEY_BUILD_VERSION=$(scripts/generate_unity_build_version.sh)
- /opt/unity/Editor/Unity -quit -batchmode -nographics -logFile - -projectPath client/OkeyClient -timestamps -executeMethod Builder.WindowsTestBuild
- tar cJf "OkeyTest_Windows_x86-64_${OKEY_BUILD_VERSION}.tar.xz" ${BUILD_PATH}/OkeyTest.exe ${BUILD_PATH}/OkeyTest_Data ${BUILD_PATH}/UnityPlayer.dll ${BUILD_PATH}/UnityCrashHandler64.exe ${BUILD_PATH}/WinPixEventRuntime.dll ${BUILD_PATH}/MonoBleedingEdge
- mkdir -p public/
- mv "OkeyTest_Windows_x86-64_${OKEY_BUILD_VERSION}.tar.xz" public/
after_script:
- /opt/unity/Editor/Unity -quit -batchmode -nographics -returnlicense -username "$UNITY_EMAIL" -password "$UNITY_PASSWORD"
rules:
- if: $CI_COMMIT_BRANCH == "front-end"
changes:
- client/OkeyClient/**/*
when: always
- if: $CI_COMMIT_TAG =~ $RELEASE_TAG
when: always
artifacts:
name: "unity-windows-test-build"
paths:
- public
expire_in: 30 days
tags:
- kubernetes
unity-linux-local-test:
image:
name: unityci/editor:ubuntu-2022.3.19f1-base-3.0.1
stage: build
dependencies: []
variables:
BUILD_PATH: client/OkeyClient/Builds/Linux
before_script:
- /opt/unity/Editor/Unity -quit -batchmode -nographics -serial "$UNITY_SERIAL" -username "$UNITY_EMAIL" -password "$UNITY_PASSWORD"
- git config --global --add safe.directory "$CI_PROJECT_DIR"
script:
- export OKEY_BUILD_VERSION=$(scripts/generate_unity_build_version.sh)
- /opt/unity/Editor/Unity -quit -batchmode -nographics -logFile - -projectPath client/OkeyClient -timestamps -executeMethod Builder.LinuxLocalTestBuild
- tar cJf "OkeyTest_Linux_x86-64_${OKEY_BUILD_VERSION}_Local.tar.xz" ${BUILD_PATH}/OkeyTest ${BUILD_PATH}/OkeyTest_s.debug ${BUILD_PATH}/OkeyTest_Data ${BUILD_PATH}/UnityPlayer.so ${BUILD_PATH}/UnityPlayer_s.debug
- mkdir -p public/
- mv "OkeyTest_Linux_x86-64_${OKEY_BUILD_VERSION}_Local.tar.xz" public/
after_script:
- /opt/unity/Editor/Unity -quit -batchmode -nographics -returnlicense -username "$UNITY_EMAIL" -password "$UNITY_PASSWORD"
rules:
- if: $CI_COMMIT_BRANCH == "front-end"
changes:
- client/OkeyClient/**/*
when: always
- if: $CI_COMMIT_TAG =~ $RELEASE_TAG
when: always
artifacts:
name: "unity-linux-local-test-build"
paths:
- public
expire_in: 30 days
tags:
- kubernetes
unity-mac-local-test:
image:
name: unityci/editor:ubuntu-2022.3.19f1-mac-mono-3.0.1
stage: build
dependencies: []
variables:
BUILD_PATH: client/OkeyClient/Builds/Mac
before_script:
- /opt/unity/Editor/Unity -quit -batchmode -nographics -serial "$UNITY_SERIAL" -username "$UNITY_EMAIL" -password "$UNITY_PASSWORD"
- git config --global --add safe.directory "$CI_PROJECT_DIR"
script:
- export OKEY_BUILD_VERSION=$(scripts/generate_unity_build_version.sh)
- /opt/unity/Editor/Unity -quit -batchmode -nographics -logFile - -projectPath client/OkeyClient -timestamps -executeMethod Builder.MacLocalTestBuild
- chmod a+x ${BUILD_PATH}/OkeyTest.app/Contents/MacOS/Okey
- tar cJf "OkeyTest_Mac_Universal_${OKEY_BUILD_VERSION}_Local.tar.xz" ${BUILD_PATH}/OkeyTest.app
- mkdir -p public/
- mv "OkeyTest_Mac_Universal_${OKEY_BUILD_VERSION}_Local.tar.xz" public/
after_script:
- /opt/unity/Editor/Unity -quit -batchmode -nographics -returnlicense -username "$UNITY_EMAIL" -password "$UNITY_PASSWORD"
rules:
- if: $CI_COMMIT_BRANCH == "front-end"
changes:
- client/OkeyClient/**/*
when: always
- if: $CI_COMMIT_TAG =~ $RELEASE_TAG
when: always
artifacts:
name: "unity-mac-local-test-build"
paths:
- public
expire_in: 30 days
tags:
- kubernetes
unity-windows-local-test:
image:
name: unityci/editor:ubuntu-2022.3.19f1-windows-mono-3.0.1
stage: build
dependencies: []
variables:
BUILD_PATH: client/OkeyClient/Builds/Windows
before_script:
- /opt/unity/Editor/Unity -quit -batchmode -nographics -serial "$UNITY_SERIAL" -username "$UNITY_EMAIL" -password "$UNITY_PASSWORD"
- git config --global --add safe.directory "$CI_PROJECT_DIR"
script:
- export OKEY_BUILD_VERSION=$(scripts/generate_unity_build_version.sh)
- /opt/unity/Editor/Unity -quit -batchmode -nographics -logFile - -projectPath client/OkeyClient -timestamps -executeMethod Builder.WindowsLocalTestBuild
- tar cJf "OkeyTest_Windows_x86-64_${OKEY_BUILD_VERSION}_Local.tar.xz" ${BUILD_PATH}/OkeyTest.exe ${BUILD_PATH}/OkeyTest_Data ${BUILD_PATH}/UnityPlayer.dll ${BUILD_PATH}/UnityCrashHandler64.exe ${BUILD_PATH}/WinPixEventRuntime.dll ${BUILD_PATH}/MonoBleedingEdge
- mkdir -p public/
- mv "OkeyTest_Windows_x86-64_${OKEY_BUILD_VERSION}_Local.tar.xz" public/
after_script:
- /opt/unity/Editor/Unity -quit -batchmode -nographics -returnlicense -username "$UNITY_EMAIL" -password "$UNITY_PASSWORD"
rules:
- if: $CI_COMMIT_BRANCH == "front-end"
changes:
- client/OkeyClient/**/*
when: always
- if: $CI_COMMIT_TAG =~ $RELEASE_TAG
when: always
artifacts:
name: "unity-windows-local-test-build"
paths:
- public
expire_in: 30 days
tags:
- kubernetes
unity-linux-release:
image:
name: unityci/editor:ubuntu-2022.3.19f1-base-3.0.1
stage: build
needs:
- job: unity-linux-test
artifacts: false
- job: unity-mac-test
artifacts: false
- job: unity-windows-test
artifacts: false
variables:
BUILD_PATH: client/OkeyClient/Builds/Linux
ENV_FILE: unity-linux-release.env
before_script:
- /opt/unity/Editor/Unity -quit -batchmode -nographics -serial "$UNITY_SERIAL" -username "$UNITY_EMAIL" -password "$UNITY_PASSWORD"
- git config --global --add safe.directory "$CI_PROJECT_DIR"
script:
- export OKEY_BUILD_VERSION=$(scripts/generate_unity_build_version.sh)
- export ARCHIVE_PATH="Okey_Linux_x86-64_${OKEY_BUILD_VERSION}.tar.xz"
- /opt/unity/Editor/Unity -quit -batchmode -nographics -logFile - -projectPath client/OkeyClient -timestamps -executeMethod Builder.LinuxReleaseBuild
- tar cJf "$ARCHIVE_PATH" ${BUILD_PATH}/Okey ${BUILD_PATH}/Okey_Data ${BUILD_PATH}/UnityPlayer.so
- mkdir -p public/
- cp "$ARCHIVE_PATH" public/
- if [ "$CI_COMMIT_TAG" ]; then scripts/unity-upload-package.sh; fi
after_script:
- /opt/unity/Editor/Unity -quit -batchmode -nographics -returnlicense -username "$UNITY_EMAIL" -password "$UNITY_PASSWORD"
rules:
- if: $CI_COMMIT_BRANCH == "front-end"
changes:
- client/OkeyClient/**/*
when: always
- if: $CI_COMMIT_TAG =~ $RELEASE_TAG
when: always
artifacts:
name: "unity-linux-release-build"
paths:
- public
expire_in: 30 days
reports:
dotenv: $ENV_FILE
tags:
- kubernetes
unity-mac-release:
image:
name: unityci/editor:ubuntu-2022.3.19f1-mac-mono-3.0.1
stage: build
needs:
- job: unity-linux-test
artifacts: false
- job: unity-mac-test
artifacts: false
- job: unity-windows-test
artifacts: false
variables:
BUILD_PATH: client/OkeyClient/Builds/Mac
ENV_FILE: unity-mac-release.env
before_script:
- /opt/unity/Editor/Unity -quit -batchmode -nographics -serial "$UNITY_SERIAL" -username "$UNITY_EMAIL" -password "$UNITY_PASSWORD"
- git config --global --add safe.directory "$CI_PROJECT_DIR"
script:
- export OKEY_BUILD_VERSION=$(scripts/generate_unity_build_version.sh)
- export ARCHIVE_PATH="Okey_Mac_Universal_${OKEY_BUILD_VERSION}.tar.xz"
- /opt/unity/Editor/Unity -quit -batchmode -nographics -logFile - -projectPath client/OkeyClient -timestamps -executeMethod Builder.MacReleaseBuild
- chmod a+x ${BUILD_PATH}/Okey.app/Contents/MacOS/Okey
- tar cJf "$ARCHIVE_PATH" ${BUILD_PATH}/Okey.app
- mkdir -p public/
- cp "$ARCHIVE_PATH" public/
- if [ "$CI_COMMIT_TAG" ]; then scripts/unity-upload-package.sh; fi
after_script:
- /opt/unity/Editor/Unity -quit -batchmode -nographics -returnlicense -username "$UNITY_EMAIL" -password "$UNITY_PASSWORD"
rules:
- if: $CI_COMMIT_BRANCH == "front-end"
changes:
- client/OkeyClient/**/*
when: always
- if: $CI_COMMIT_TAG =~ $RELEASE_TAG
when: always
artifacts:
name: "unity-mac-release-build"
paths:
- public
expire_in: 30 days
reports:
dotenv: $ENV_FILE
tags:
- kubernetes
unity-windows-release:
image:
name: unityci/editor:ubuntu-2022.3.19f1-windows-mono-3.0.1
stage: build
needs:
- job: unity-linux-test
artifacts: false
- job: unity-mac-test
artifacts: false
- job: unity-windows-test
artifacts: false
variables:
BUILD_PATH: client/OkeyClient/Builds/Windows
ENV_FILE: unity-windows-release.env
before_script:
- /opt/unity/Editor/Unity -quit -batchmode -nographics -serial "$UNITY_SERIAL" -username "$UNITY_EMAIL" -password "$UNITY_PASSWORD"
- git config --global --add safe.directory "$CI_PROJECT_DIR"
script:
- export OKEY_BUILD_VERSION=$(scripts/generate_unity_build_version.sh)
- export ARCHIVE_PATH="Okey_Windows_x86-64_${OKEY_BUILD_VERSION}.tar.xz"
- /opt/unity/Editor/Unity -quit -batchmode -nographics -logFile - -projectPath client/OkeyClient -timestamps -executeMethod Builder.WindowsReleaseBuild
- tar cJf "$ARCHIVE_PATH" ${BUILD_PATH}/Okey.exe ${BUILD_PATH}/Okey_Data ${BUILD_PATH}/UnityPlayer.dll ${BUILD_PATH}/UnityCrashHandler64.exe ${BUILD_PATH}/MonoBleedingEdge
- mkdir -p public/
- cp "$ARCHIVE_PATH" public/
- if [ "$CI_COMMIT_TAG" ]; then scripts/unity-upload-package.sh; fi
after_script:
- /opt/unity/Editor/Unity -quit -batchmode -nographics -returnlicense -username "$UNITY_EMAIL" -password "$UNITY_PASSWORD"
rules:
- if: $CI_COMMIT_BRANCH == "front-end"
changes:
- client/OkeyClient/**/*
when: always
- if: $CI_COMMIT_TAG =~ $RELEASE_TAG
when: always
artifacts:
name: "unity-windows-release-build"
paths:
- public
expire_in: 30 days
reports:
dotenv: $ENV_FILE
tags:
- kubernetes
deploy-backend-staging:
stage: deploy
dependencies: []
# process_mode=oldest_first
resource_group: staging
environment:
name: Deploy/Staging
variables:
TARGET: dev
PERSIST_PATH: '/home/ubuntu/'
SECURE_FILES_DOWNLOAD_PATH: "/ssh/"
script:
- curl --silent "https://gitlab.com/gitlab-org/incubation-engineering/mobile-devops/download-secure-files/-/raw/main/installer" | bash
- cp -r /builds/okaybytes/okey/ssh /
- chmod -R 600 /ssh
- cp /ssh/config /etc/ssh/ssh_config.d/config.conf # https://linuxize.com/post/using-the-ssh-config-file/
- ansible-playbook -i scripts/ansible/inventory.yml scripts/ansible/playbook.yml --limit dev
- echo "$CI_REGISTRY_PASSWORD" | docker login $CI_REGISTRY -u $CI_REGISTRY_USER --password-stdin # https://medium.com/@vitalypanukhin/docker-compose-and-gitlab-b209d09210f6
- cd docker/
- docker-compose -H "ssh://pi0" --profile extra down --remove-orphans
- ssh pi0 "rm -rf docker_data/config/ ; mkdir -p docker_data/"
- scp -r docker_data/config pi0:${PERSIST_PATH}/docker_data/
- docker-compose -H "ssh://pi0" --profile extra pull
- docker-compose -H "ssh://pi0" --profile extra up -d
- docker -H "ssh://pi0" system prune --all --force --volumes
rules:
- if: $CI_COMMIT_BRANCH == "back-end"
tags:
- kubernetes
deploy-backend-production:
# https://forum.gitlab.com/t/how-can-i-set-the-stage-environment-from-a-condition/67401/2
extends: deploy-backend-staging
# process_mode=oldest_first
resource_group: production
environment:
name: Deploy/Production
variables:
TARGET: "$CI_COMMIT_TAG"
script:
- curl --silent "https://gitlab.com/gitlab-org/incubation-engineering/mobile-devops/download-secure-files/-/raw/main/installer" | bash
- cp -r /builds/okaybytes/okey/ssh /
- chmod -R 600 /ssh
- cp /ssh/config /etc/ssh/ssh_config.d/config.conf # https://linuxize.com/post/using-the-ssh-config-file/
- ansible-playbook -i scripts/ansible/inventory.yml scripts/ansible/playbook.yml --limit prod
- echo "$CI_REGISTRY_PASSWORD" | docker login $CI_REGISTRY -u $CI_REGISTRY_USER --password-stdin # https://medium.com/@vitalypanukhin/docker-compose-and-gitlab-b209d09210f6
- cd docker/
- docker-compose -H "ssh://pi1" --profile extra down --remove-orphans
- ssh pi1 "rm -rf docker_data/config/ ; mkdir -p docker_data/"
- scp -r docker_data/config pi1:${PERSIST_PATH}/docker_data/
- docker-compose -H "ssh://pi1" --profile extra pull
- docker-compose -H "ssh://pi1" --profile extra up -d
- docker -H "ssh://pi1" system prune --all --force --volumes
rules:
- if: $CI_COMMIT_TAG =~ $RELEASE_TAG
pages:
stage: deploy
dependencies: []
script:
- dotnet docfx docs/docfx.json
- cp -r docs/_site public
rules:
- if: '$CI_COMMIT_TAG =~ $RELEASE_TAG' # Run this job when a release tag is created
artifacts:
paths:
- public
tags:
- kubernetes
release_job:
stage: release
dependencies: ["unity-linux-release", "unity-mac-release", "unity-windows-release"]
image: registry.gitlab.com/gitlab-org/release-cli:latest
rules:
- if: '$CI_COMMIT_TAG =~ $RELEASE_TAG' # Run this job when a release tag is created
before_script:
- apk add --update --no-cache git python3 && ln -sf python3 /usr/bin/python
- git config --global --add safe.directory "$CI_PROJECT_DIR"
script:
- echo "Running release_job for $CI_COMMIT_TAG"
- scripts/create_latest_release_description.sh > RELEASE_NOTES.md
after_script: ""
release: # See https://docs.gitlab.com/ee/ci/yaml/#release for available properties
tag_name: $CI_COMMIT_TAG
name: 'Release $CI_COMMIT_TAG'
description: './RELEASE_NOTES.md'
assets:
links:
- name: "$Linux_LINK_NAME"
url: "$Linux_LINK_URL"
link_type: 'package'
filepath: "/binaries/$Linux_LINK_NAME"
- name: "$Mac_LINK_NAME"
url: "$Mac_LINK_URL"
link_type: 'package'
filepath: "/binaries/$Mac_LINK_NAME"
- name: "$Windows_LINK_NAME"
url: "$Windows_LINK_URL"
link_type: 'package'
filepath: "/binaries/$Windows_LINK_NAME"
tags:
- kubernetes