-
Notifications
You must be signed in to change notification settings - Fork 5
/
.gitlab-ci.yml
594 lines (593 loc) · 16.4 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
# You can override the included template(s) by including variable overrides
# Secret Detection customization: https://docs.gitlab.com/ee/user/application_security/secret_detection/#customizing-settings
# Dependency Scanning customization: https://docs.gitlab.com/ee/user/application_security/dependency_scanning/#customizing-the-dependency-scanning-settings
# Note that environment variables can be set in several places
# See https://docs.gitlab.com/ee/ci/variables/#cicd-variable-precedence
image: axelterizaki/karaokemugen-ci:node-20
variables:
GIT_SUBMODULE_STRATEGY: recursive
ELECTRON_CACHE: '.cache/electron'
DS_INCLUDE_DEV_DEPENDENCIES: 'false'
DIST_LINUX_X64: dist_linux-x64-8.0.tar.gz
DIST_LINUX_ARM64: dist_linux-arm64-8.0.tar.gz
DIST_WIN: dist_win-8.0.tar.gz
DIST_MAC: dist_mac-8.0.tar.gz
include:
- template: Security/Dependency-Scanning.gitlab-ci.yml
- template: Security/Secret-Detection.gitlab-ci.yml
workflow:
rules:
- if: '$CI_COMMIT_TAG'
- if: $CI_COMMIT_BRANCH == "master"
- if: $CI_COMMIT_BRANCH == "next"
cache:
key: km-app-${CI_COMMIT_REF_SLUG}
paths:
- node_modules/
- kmfrontend/node_modules/
stages:
- schedule
- test
- build
- scan
- package
- deploy
- release
gemnasium-dependency_scanning:
interruptible: true
stage: scan
artifacts:
expire_in: 1 day
tags:
- $RUNNER_LINUX
rules:
- if: '$CI_COMMIT_MESSAGE =~ /^🚀 new release/'
when: never
- if: '$CI_COMMIT_MESSAGE =~ /^:rocket: new release/'
when: never
- if: $SCHEDULED_RELEASES == "true"
when: never
- if: $CI_COMMIT_BRANCH == "next"
- when: never
secret_detection:
interruptible: true
artifacts:
expire_in: 1 day
stage: scan
tags:
- $RUNNER_LINUX
variables:
SECRET_DETECTION_EXCLUDED_PATHS: 'node_modules kmfrontend/node_modules dist'
rules:
- if: '$CI_COMMIT_MESSAGE =~ /^🚀 new release/'
when: never
- if: '$CI_COMMIT_MESSAGE =~ /^:rocket: new release/'
when: never
- if: $SCHEDULED_RELEASES == "true"
when: never
- if: $CI_COMMIT_BRANCH == "next"
- when: never
test:
stage: test
retry:
max: 2
interruptible: true
needs: []
artifacts:
expire_in: 1 day
tags:
- $RUNNER_LINUX
services:
- postgres:13
variables:
POSTGRES_USER: karaokemugen_app
POSTGRES_PASSWORD: musubi
script:
- yarn install --check-files --force --cache-folder .yarn
- touch mpv
- touch ffmpeg
- touch patch
- mkdir app
- cp -f config.CICD.yml app/config.yml
- export LANG=en_US
- node --version
- node util/extUnaccent.js
- export DISPLAY=':99.0'
- Xvfb :99 -screen 0 1920x1080x24 > /dev/null 2>&1 &
- yarn testCI --verbose
rules:
- if: $SCHEDULED_RELEASES == "true"
when: never
- if: '$CI_COMMIT_MESSAGE =~ /^🚀 new release/'
- if: '$CI_COMMIT_MESSAGE =~ /^:rocket: new release/'
- if: '$CI_COMMIT_TAG'
- if: $CI_COMMIT_BRANCH == "master"
- if: $CI_COMMIT_BRANCH == "next"
- when: never
build-migrationsFile:
stage: build
interruptible: true
tags:
- $RUNNER_LINUX
artifacts:
expire_in: 1 day
name: km-app-migrations-$CI_COMMIT_REF_SLUG}
paths:
- migrations/migrations.txt
cache: {}
script:
- cd migrations
- ls *.sql > migrations.txt
rules:
- if: $SCHEDULED_RELEASES == "true"
when: never
- if: '$CI_COMMIT_MESSAGE =~ /^🚀 new release/'
- if: '$CI_COMMIT_MESSAGE =~ /^:rocket: new release/'
- if: '$CI_COMMIT_TAG'
- if: $CI_COMMIT_BRANCH == "master"
- if: $CI_COMMIT_BRANCH == "next"
- when: never
build-react:
stage: build
interruptible: true
tags:
- $RUNNER_LINUX
dependencies:
- test
needs:
- test
artifacts:
expire_in: 1 day
name: km-app-build-${CI_COMMIT_REF_SLUG}
paths:
- kmfrontend/dist/
- dist/
script:
- yarn build
- yarn installkmfrontend
- yarn buildkmfrontend
- node util/sentryUpdateReleases.js
rules:
- if: $SCHEDULED_RELEASES == "true"
when: never
- if: '$CI_COMMIT_MESSAGE =~ /^🚀 new release/'
- if: '$CI_COMMIT_MESSAGE =~ /^:rocket: new release/'
- if: $CI_COMMIT_BRANCH == "master"
- if: $CI_COMMIT_BRANCH == "next"
- if: '$CI_COMMIT_TAG'
- when: never
deploy_kmremote:
stage: deploy
artifacts:
expire_in: 1 day
interruptible: true
tags:
- $RUNNER_LINUX
cache: {}
image: axelterizaki/karaokemugen-ci:transferts
dependencies:
- build-react
needs:
- build-react
script: bash util/pushKMRemote.sh
rules:
- if: $SCHEDULED_RELEASES == "true"
when: never
- if: '$CI_COMMIT_MESSAGE =~ /^🚀 new release/'
- if: '$CI_COMMIT_MESSAGE =~ /^:rocket: new release/'
- if: $CI_COMMIT_BRANCH == "master"
- if: $CI_COMMIT_BRANCH == "next"
- if: '$CI_COMMIT_TAG'
- when: never
pkg_linux_x64:
stage: package
image: electronuserland/builder:latest
tags:
- $RUNNER_LINUX
cache:
key: km-app-${CI_COMMIT_REF_SLUG}
paths:
- node_modules/
- kmfrontend/node_modules/
policy: pull
interruptible: true
artifacts:
expire_in: 1 day
name: km-app-pkglinux-${CI_COMMIT_REF_SLUG}
paths:
- release_linux
dependencies:
- build-react
- build-migrationsFile
needs:
- build-react
- build-migrationsFile
- test
script:
- rm -Rf release_linux
- npm install -g electron-builder
- echo $CI_COMMIT_SHORT_SHA >assets/sha.txt
- wget -qO- http://mugen.karaokes.moe/downloads/$DIST_LINUX_X64 | tar xvz
- echo $SENTRY_DSN >assets/sentry.txt
- bash util/electronBuilder.sh -l --x64
- ls -la packages/
- mkdir release_linux
- rm -Rf packages/*arm64*
- mv packages/*.deb release_linux/
- mv packages/*.tar.gz release_linux/
- mv packages/*.yml release_linux/
- mv packages/*.AppImage release_linux/
- ls -la release_linux/*
rules:
- if: $SCHEDULED_RELEASES == "true"
when: never
- if: '$CI_COMMIT_MESSAGE =~ /^🚀 new release/'
- if: '$CI_COMMIT_MESSAGE =~ /^:rocket: new release/'
- if: '$CI_COMMIT_TAG'
- when: never
pkg_linux_arm64:
stage: package
image: electronuserland/builder:latest
tags:
- $RUNNER_LINUX
cache:
key: km-app-${CI_COMMIT_REF_SLUG}
paths:
- node_modules/
- kmfrontend/node_modules/
policy: pull
interruptible: true
artifacts:
expire_in: 1 day
name: km-app-pkglinux-${CI_COMMIT_REF_SLUG}
paths:
- release_linux
dependencies:
- build-react
- build-migrationsFile
needs:
- build-react
- build-migrationsFile
- test
script:
- rm -Rf release_linux
- npm install -g electron-builder
- echo $CI_COMMIT_SHORT_SHA >assets/sha.txt
- wget -qO- http://mugen.karaokes.moe/downloads/$DIST_LINUX_ARM64 | tar xvz
- echo $SENTRY_DSN >assets/sentry.txt
- bash util/electronBuilder.sh -l --arm64
- ls -la packages/
- mkdir release_linux
- rm -Rf packages/*amd64*
- rm -Rf packages/*x64*
- rm -Rf packages/*x86_64*
- mv packages/*.deb release_linux/
- mv packages/*.tar.gz release_linux/
- mv packages/*.yml release_linux/
- mv packages/*.AppImage release_linux/
- ls -la release_linux/*
rules:
- if: $SCHEDULED_RELEASES == "true"
when: never
- if: '$CI_COMMIT_MESSAGE =~ /^🚀 new release/'
- if: '$CI_COMMIT_MESSAGE =~ /^:rocket: new release/'
- if: '$CI_COMMIT_TAG'
- when: never
pkg_win:
stage: package
image: electronuserland/builder:wine-mono
tags:
- $RUNNER_LINUX
cache:
key: km-app-${CI_COMMIT_REF_SLUG}
paths:
- node_modules/
- kmfrontend/node_modules/
policy: pull
interruptible: true
artifacts:
expire_in: 1 day
name: km-app-pkgwin-${CI_COMMIT_REF_SLUG}
paths:
- release_win
dependencies:
- build-react
- build-migrationsFile
needs:
- build-react
- build-migrationsFile
- test
script:
- rm -Rf release_win
- npm install -g electron-builder
- wget -qO - https://download.opensuse.org/repositories/Emulators:/Wine:/Debian/xUbuntu_20.04/Release.key
| apt-key add -
- apt-get update -qq && apt-get install -y -qq zip
- wget -qO- http://mugen.karaokes.moe/downloads/$DIST_WIN | tar xz
- echo $CI_COMMIT_SHORT_SHA >assets/sha.txt
- echo $SENTRY_DSN >assets/sentry.txt
- bash util/electronBuilder.sh -w
- ls -la packages/
- mkdir release_win
- mv packages/*.exe release_win/
- mv packages/*.yml release_win/
- touch portable
- touch disableAppUpdate
- zip -rv packages/*.zip portable disableAppUpdate
- mv packages/*.zip release_win/
- ls -la release_win/*
rules:
- if: $SCHEDULED_RELEASES == "true"
when: never
- if: '$CI_COMMIT_MESSAGE =~ /^🚀 new release/'
- if: '$CI_COMMIT_MESSAGE =~ /^:rocket: new release/'
- if: '$CI_COMMIT_TAG'
- when: never
pkg_mac:
stage: package
cache:
key: km-app-${CI_COMMIT_REF_SLUG}
paths:
- node_modules/
- kmfrontend/node_modules/
policy: pull
retry:
max: 2
tags:
- macos
interruptible: true
artifacts:
expire_in: 1 day
name: km-app-pkgmac-${CI_COMMIT_REF_SLUG}
paths:
- release_mac
dependencies:
- build-react
- build-migrationsFile
needs:
- build-react
- build-migrationsFile
- test
variables:
ARTIFACT_DOWNLOAD_ATTEMPTS: 10
RESTORE_CACHE_ATTEMPTS: 10
script:
- source ~/.zshrc
- yarn install
- rm -Rf release_mac
- rm -Rf app-mac
- rm -Rf app/bin
- wget -qO- http://mugen.karaokes.moe/downloads/$DIST_MAC | tar xvz
- echo $CI_COMMIT_SHORT_SHA >assets/sha.txt
- echo $SENTRY_DSN >assets/sentry.txt
- security unlock-keychain -p $MACOS_PASSWORD login.keychain
- bash util/electronBuilder.sh -m
- ls -la packages/
- mkdir release_mac
- mv packages/*-mac.yml release_mac
- mv packages/*.dmg release_mac/
- ls -la release_mac/*
rules:
- if: $SCHEDULED_RELEASES == "true"
when: never
- if: '$CI_COMMIT_MESSAGE =~ /^🚀 new release/'
- if: '$CI_COMMIT_MESSAGE =~ /^:rocket: new release/'
- if: '$CI_COMMIT_TAG'
- when: never
deploy_mac:
stage: deploy
image: minidocks/lftp
tags:
- $RUNNER_LINUX
interruptible: true
artifacts:
expire_in: 1 day
variables:
GIT_STRATEGY: none
cache: {}
dependencies:
- pkg_mac
needs:
- pkg_mac
script:
- ls -la release_mac/*
- lftp -c "set cmd:fail-exit yes; set ftp:ssl-allow no; open -u $USERNAME,$PASSWORD
$HOST; cd www/mugen.karaokes.moe/downloads; mput release_mac/*"
rules:
- if: $SCHEDULED_RELEASES == "true"
when: never
- if: '$CI_COMMIT_MESSAGE =~ /^🚀 new release/'
- if: '$CI_COMMIT_MESSAGE =~ /^:rocket: new release/'
- if: '$CI_COMMIT_TAG'
- when: never
deploy_linux:
stage: deploy
image: minidocks/lftp
tags:
- $RUNNER_LINUX
interruptible: true
artifacts:
expire_in: 1 day
cache: {}
variables:
GIT_STRATEGY: none
dependencies:
- pkg_linux_x64
- pkg_linux_arm64
needs:
- pkg_linux_x64
- pkg_linux_arm64
script:
- ls -la release_linux/*
- lftp -c "set cmd:fail-exit yes; set ftp:ssl-allow no; open -u $USERNAME,$PASSWORD
$HOST; cd www/mugen.karaokes.moe/downloads; mput release_linux/*"
rules:
- if: $SCHEDULED_RELEASES == "true"
when: never
- if: '$CI_COMMIT_MESSAGE =~ /^🚀 new release/'
- if: '$CI_COMMIT_MESSAGE =~ /^:rocket: new release/'
- if: '$CI_COMMIT_TAG'
deploy_win:
stage: deploy
image: minidocks/lftp
tags:
- $RUNNER_LINUX
interruptible: true
artifacts:
expire_in: 1 day
variables:
GIT_STRATEGY: none
cache: {}
dependencies:
- pkg_win
needs:
- pkg_win
script:
- ls -la release_win/*
- lftp -c "set cmd:fail-exit yes; set ftp:ssl-allow no; open -u $USERNAME,$PASSWORD
$HOST; cd www/mugen.karaokes.moe/downloads; mput release_win/*"
rules:
- if: $SCHEDULED_RELEASES == "true"
when: never
- if: '$CI_COMMIT_MESSAGE =~ /^🚀 new release/'
- if: '$CI_COMMIT_MESSAGE =~ /^:rocket: new release/'
- if: '$CI_COMMIT_TAG'
- when: never
release_site:
stage: release
image: curlimages/curl
tags:
- $RUNNER_LINUX
interruptible: true
artifacts:
expire_in: 1 day
dependencies: []
cache: {}
needs:
- deploy_win
- deploy_linux
- deploy_mac
script:
- sh util/triggerWebsite.sh
rules:
- if: $SCHEDULED_RELEASES == "true"
when: never
- if: '$CI_COMMIT_MESSAGE =~ /^🚀 new release/'
- if: '$CI_COMMIT_MESSAGE =~ /^:rocket: new release/'
- if: '$CI_COMMIT_TAG'
- when: never
weekly_releases:
stage: schedule
image: axelterizaki/karaokemugen-git-ssh:latest
tags:
- $RUNNER_LINUX
interruptible: true
artifacts:
expire_in: 1 day
cache: {}
needs: []
script:
- bash util/gitPush.sh
rules:
- if: '$CI_COMMIT_MESSAGE =~ /^🚀 new release/'
when: never
- if: '$CI_COMMIT_MESSAGE =~ /^:rocket: new release/'
when: never
- if: $SCHEDULED_RELEASES == "true"
- when: never
flatpak-generated-sources:
stage: build
image: python:3.11-bullseye
tags:
- $RUNNER_LINUX
interruptible: true
artifacts:
expire_in: 1 day
name: km-app-generated_sources-${CI_COMMIT_REF_SLUG}
paths:
- generated-sources.json
script:
- git clone https://github.com/flatpak/flatpak-builder-tools.git
- cd flatpak-builder-tools/node
- pip install .
- cd ../..
- flatpak-node-generator yarn -r yarn.lock -R kmfrontend/yarn.lock -R yarn.lock
rules:
- if: '$CI_COMMIT_TAG'
- when: never
deploy_flathub:
stage: deploy
image: node:18
artifacts:
expire_in: 1 day
tags:
- $RUNNER_LINUX
interruptible: true
cache:
key: km-app-${CI_COMMIT_REF_SLUG}
paths:
- node_modules/
- kmfrontend/node_modules/
policy: pull
dependencies:
- flatpak-generated-sources
needs:
- flatpak-generated-sources
script:
- mkdir ~/.ssh
- chmod 700 ~/.ssh
- ssh-keyscan -H github.com >> ~/.ssh/known_hosts
- cp $GITHUB_SSH_KEY ~/.ssh/id_rsa
- chmod 600 ~/.ssh/id_rsa
- git clone git@github.com:flathub/moe.karaokes.mugen.git
- bash util/updateFlatpak.sh
- cp generated-sources.json moe.karaokes.mugen/
- cd moe.karaokes.mugen
- git branch $CI_COMMIT_REF_SLUG
- git checkout $CI_COMMIT_REF_SLUG
- git status
- git add .
- git config user.name "Karaoke Mugen Release Bot"
- git config user.email "mugen@karaokes.moe"
- git commit -m "New version $CI_COMMIT_REF_NAME"
- git push --set-upstream origin $CI_COMMIT_REF_SLUG
rules:
- if: '$CI_COMMIT_TAG'
- when: never
gitlab_release:
stage: release
image: registry.gitlab.com/gitlab-org/release-cli:latest
rules:
- if: '$CI_COMMIT_TAG'
script:
- echo "running release_job"
- /bin/sh util/extractChangelog.sh $CI_COMMIT_TAG CHANGELOG.md >current_changes.md
release: # See https://docs.gitlab.com/ee/ci/yaml/#release for available properties
tag_name: '$CI_COMMIT_TAG'
description: './current_changes.md'
milestones:
- '$CURRENT_MILESTONE'
assets:
links:
- name: Windows Installer
url: https://mugen.karaokes.moe/downloads/Karaoke%20Mugen%20Setup%20$CI_COMMIT_TAG.exe
- name: Windows Portable
url: https://mugen.karaokes.moe/downloads/Karaoke%20Mugen-$CI_COMMIT_TAG-win.zip
- name: macOS DMG (Apple Silicon)
url: https://mugen.karaokes.moe/downloads/Karaoke%20Mugen-$CI_COMMIT_TAG-mac-arm64.dmg
- name: macOS DMG (Intel)
url: https://mugen.karaokes.moe/downloads/Karaoke%20Mugen-$CI_COMMIT_TAG-mac-x86.dmg
- name: Linux Flatpak (x86)
url: https://flathub.org/apps/moe.karaokes.mugen
- name: Linux DEB (x86)
url: https://mugen.karaokes.moe/downloads/Karaoke%20Mugen-$CI_COMMIT_TAG-linux-amd64.deb
- name: Linux DEB (arm64)
url: https://mugen.karaokes.moe/downloads/Karaoke%20Mugen-$CI_COMMIT_TAG-linux-arm64.deb
- name: Linux AppImage (x86)
url: https://mugen.karaokes.moe/downloads/Karaoke%20Mugen-$CI_COMMIT_TAG-linux-x86_64.AppImage
- name: Linux AppImage (arm64)
url: https://mugen.karaokes.moe/downloads/Karaoke%20Mugen-$CI_COMMIT_TAG-linux-arm64.AppImage
- name: Linux tar.gz (x86)
url: https://mugen.karaokes.moe/downloads/Karaoke%20Mugen-$CI_COMMIT_TAG-linux-x64.tar.gz
- name: Linux tar.gz (arm64)
url: https://mugen.karaokes.moe/downloads/Karaoke%20Mugen-$CI_COMMIT_TAG-linux-arm64.tar.gz