@@ -48,8 +48,11 @@ check:lint:
48
48
npm run lint;
49
49
'
50
50
rules :
51
+ # Runs on feature and staging commits and ignores version commits
51
52
- if : $CI_COMMIT_BRANCH =~ /^(?:feature.*|staging)$/ && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
53
+ # Runs on tag pipeline where the tag is a prerelease or release version
52
54
- if : $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
55
+ # Manually run on commits other than master and ignore version commits
53
56
- if : $CI_COMMIT_BRANCH && $CI_COMMIT_BRANCH != 'master' && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
54
57
when : manual
55
58
@@ -59,8 +62,11 @@ check:nix-dry:
59
62
script :
60
63
- nix-build -v -v --dry-run ./release.nix
61
64
rules :
65
+ # Runs on feature and staging commits and ignores version commits
62
66
- if : $CI_COMMIT_BRANCH =~ /^(?:feature.*|staging)$/ && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
67
+ # Runs on tag pipeline where the tag is a prerelease or release version
63
68
- if : $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
69
+ # Manually run on commits other than master and ignore version commits
64
70
- if : $CI_COMMIT_BRANCH && $CI_COMMIT_BRANCH != 'master' && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
65
71
when : manual
66
72
@@ -79,9 +85,9 @@ check:test:
79
85
junit :
80
86
- ./tmp/junit.xml
81
87
rules :
82
- # Run on feature branches, but not on version commits
88
+ # Runs on staging commits and ignores version commits
83
89
- if : $CI_COMMIT_BRANCH =~ /^feature.*$/ && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
84
- # For branches other than master and staging, manually activate, but not on version commits
90
+ # Manually run on commits other than master and staging and ignore version commits
85
91
- if : $CI_COMMIT_BRANCH && $CI_COMMIT_BRANCH !~ /^(?:master|staging)$/ && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
86
92
when : manual
87
93
@@ -106,7 +112,9 @@ build:linux:
106
112
# Only the build:linux preserves the dist
107
113
- ./dist
108
114
rules :
115
+ # Runs on staging commits and ignores version commits
109
116
- if : $CI_COMMIT_BRANCH == 'staging' && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
117
+ # Runs on tag pipeline where the tag is a prerelease or release version
110
118
- if : $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
111
119
112
120
build:windows :
@@ -134,7 +142,9 @@ build:windows:
134
142
paths :
135
143
- ./prebuilds/
136
144
rules :
145
+ # Runs on staging commits and ignores version commits
137
146
- if : $CI_COMMIT_BRANCH == 'staging' && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
147
+ # Runs on tag pipeline where the tag is a prerelease or release version
138
148
- if : $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
139
149
140
150
build:macos :
@@ -168,7 +178,9 @@ build:macos:
168
178
paths :
169
179
- ./prebuilds/
170
180
rules :
181
+ # Runs on staging commits and ignores version commits
171
182
- if : $CI_COMMIT_BRANCH == 'staging' && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
183
+ # Runs on tag pipeline where the tag is a prerelease or release version
172
184
- if : $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
173
185
174
186
build:prerelease :
@@ -211,10 +223,10 @@ build:prerelease:
211
223
after_script :
212
224
- rm -f ./.npmrc
213
225
rules :
214
- # Only runs on tag pipeline, and only where the tag is a prerelease version
226
+ # Only runs on tag pipeline where the tag is a prerelease version
215
227
# This requires dependencies to also run on tag pipeline
216
- # However release tagging comes with a release commit
217
- # Dependencies must not run on the release commit
228
+ # However version tag comes with a version commit
229
+ # Dependencies must not run on the version commit
218
230
- if : $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+-.*[0-9]+$/
219
231
220
232
integration:builds :
@@ -250,7 +262,9 @@ integration:builds:
250
262
paths :
251
263
- ./builds/
252
264
rules :
253
- - if : $CI_COMMIT_BRANCH == 'staging'
265
+ # Runs on staging commits and ignores version commits
266
+ - if : $CI_COMMIT_BRANCH == 'staging' && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
267
+ # Runs on tag pipeline where the tag is a prerelease or release version
254
268
- if : $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
255
269
256
270
integration:deployment :
@@ -260,13 +274,17 @@ integration:deployment:
260
274
script :
261
275
- echo 'Perform service deployment for integration testing'
262
276
rules :
263
- - if : $CI_COMMIT_BRANCH == 'staging'
277
+ # Runs on staging commits and ignores version commits
278
+ - if : $CI_COMMIT_BRANCH == 'staging' && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
279
+ # Runs on tag pipeline where the tag is a prerelease or release version
264
280
- if : $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
265
281
266
282
integration:nix :
267
283
stage : integration
268
284
needs :
269
285
- integration:builds
286
+ - job : integration:deployment
287
+ optional : true
270
288
script :
271
289
- >
272
290
build_application="$( \
@@ -276,13 +294,17 @@ integration:nix:
276
294
)"
277
295
- $build_application/bin/typescript-demo-lib
278
296
rules :
279
- - if : $CI_COMMIT_BRANCH == 'staging'
297
+ # Runs on staging commits and ignores version commits
298
+ - if : $CI_COMMIT_BRANCH == 'staging' && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
299
+ # Runs on tag pipeline where the tag is a prerelease or release version
280
300
- if : $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
281
301
282
302
integration:docker :
283
303
stage : integration
284
304
needs :
285
305
- integration:builds
306
+ - job : integration:deployment
307
+ optional : true
286
308
image : docker:20.10.11
287
309
services :
288
310
- docker:20.10.11-dind
@@ -294,43 +316,57 @@ integration:docker:
294
316
- image="$(docker load --input ./builds/*docker* | cut -d' ' -f3)"
295
317
- docker run "$image"
296
318
rules :
297
- - if : $CI_COMMIT_BRANCH == 'staging'
319
+ # Runs on staging commits and ignores version commits
320
+ - if : $CI_COMMIT_BRANCH == 'staging' && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
321
+ # Runs on tag pipeline where the tag is a prerelease or release version
298
322
- if : $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
299
323
300
324
integration:linux :
301
325
stage : integration
302
326
needs :
303
327
- integration:builds
328
+ - job : integration:deployment
329
+ optional : true
304
330
image : ubuntu:latest
305
331
script :
306
332
- for f in ./builds/*-linux-*; do "$f"; done
307
333
rules :
308
- - if : $CI_COMMIT_BRANCH == 'staging'
334
+ # Runs on staging commits and ignores version commits
335
+ - if : $CI_COMMIT_BRANCH == 'staging' && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
336
+ # Runs on tag pipeline where the tag is a prerelease or release version
309
337
- if : $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
310
338
311
339
integration:windows :
312
340
stage : integration
313
341
needs :
314
342
- integration:builds
343
+ - job : integration:deployment
344
+ optional : true
315
345
tags :
316
346
- windows
317
347
script :
318
348
- Get-ChildItem -File ./builds/*-win-* | ForEach {& $_.FullName}
319
349
rules :
320
- - if : $CI_COMMIT_BRANCH == 'staging'
350
+ # Runs on staging commits and ignores version commits
351
+ - if : $CI_COMMIT_BRANCH == 'staging' && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
352
+ # Runs on tag pipeline where the tag is a prerelease or release version
321
353
- if : $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
322
354
323
355
integration:macos :
324
356
stage : integration
325
357
needs :
326
358
- integration:builds
359
+ - job : integration:deployment
360
+ optional : true
327
361
tags :
328
362
- shared-macos-amd64
329
363
image : macos-11-xcode-12
330
364
script :
331
365
- for f in ./builds/*-macos-x64*; do "$f"; done
332
366
rules :
333
- - if : $CI_COMMIT_BRANCH == 'staging'
367
+ # Runs on staging commits and ignores version commits
368
+ - if : $CI_COMMIT_BRANCH == 'staging' && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
369
+ # Runs on tag pipeline where the tag is a prerelease or release version
334
370
- if : $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
335
371
336
372
integration:prerelease :
@@ -380,7 +416,11 @@ integration:prerelease:
380
416
fi;
381
417
'
382
418
rules :
383
- - if : $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
419
+ # Only runs on tag pipeline where the tag is a release version
420
+ # This requires dependencies to also run on tag pipeline
421
+ # However version tag comes with a version commit
422
+ # Dependencies must not run on the version commit
423
+ - if : $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+-.*[0-9]+$/
384
424
385
425
integration:merge :
386
426
stage : integration
@@ -397,13 +437,12 @@ integration:merge:
397
437
optional : true
398
438
script :
399
439
- echo 'use gh to create and merge PR from staging to master'
440
+ - echo 'use github commit status to signal master to allow merge'
400
441
rules :
401
- - if : $CI_COMMIT_BRANCH == 'staging'
402
-
403
- # the expectation is that you must have merged into master from staging to trigger this
404
- # if you directly push to master, you corrupt this entire process
405
- # because this will end up acquiring it from the latest builds from the same path
406
- # thus we prevent master branch, direct merging into master branch
442
+ # Runs on staging commits and ignores version commits
443
+ - if : $CI_COMMIT_BRANCH == 'staging' && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
444
+ # Runs on tag pipeline where the tag is a prerelease or release version
445
+ - if : $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
407
446
408
447
release:deployment :
409
448
stage : release
@@ -413,16 +452,16 @@ release:deployment:
413
452
ref : staging
414
453
artifacts : true
415
454
script :
416
- - echo 'Perform service deployment for production release '
455
+ - echo 'Perform service deployment for production'
417
456
rules :
418
- - if : $CI_COMMIT_BRANCH == 'master'
457
+ # Runs on master commits and ignores version commits
458
+ - if : $CI_COMMIT_BRANCH == 'master' && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
459
+ # Runs on tag pipeline where the tag is a release version
460
+ - if : $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+$/
419
461
420
- # TODO: use gh to produce the final release tag and page with all binaries
421
- # TODO: use npm to produce the final npm erlease too
422
462
release:distribution :
423
463
stage : release
424
464
needs :
425
- - release:deployment
426
465
- project : $CI_PROJECT_PATH
427
466
job : build:linux
428
467
ref : staging
@@ -439,18 +478,48 @@ release:distribution:
439
478
job : integration:builds
440
479
ref : staging
441
480
artifacts : true
481
+ - job : release:deployment
482
+ optional : true
442
483
# Don't interrupt publishing job
443
484
interruptible : false
444
485
allow_failure : true
445
486
before_script :
446
487
- echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ./.npmrc
447
488
script :
489
+ - echo 'Publishing library & application release'
448
490
- >
449
491
nix-shell --run '
450
492
npm publish --access public;
451
493
'
494
+ - >
495
+ for d in prebuilds/*; do
496
+ tar \
497
+ --create \
498
+ --verbose \
499
+ --file="prebuilds/$(basename $d).tar" \
500
+ --directory=prebuilds \
501
+ "$(basename $d)";
502
+ done;
503
+ - >
504
+ nix-shell -I nixpkgs=./pkgs.nix --packages git gitAndTools.gh --run '
505
+ gh release \
506
+ create "$CI_COMMIT_TAG" \
507
+ prebuilds/*.tar \
508
+ builds/*.closure.gz \
509
+ builds/*-docker-* \
510
+ builds/*-linux-* \
511
+ builds/*-win-* \
512
+ builds/*-macos-* \
513
+ --title "Build-$(date -u +"%Y-%m-%dT%H:%M:%SZ")" \
514
+ --notes '' \
515
+ --target master \
516
+ --repo MatrixAI/TypeScript-Demo-Lib-Native;
517
+ '
452
518
after_script :
453
519
- rm -f ./.npmrc
454
520
rules :
455
- # Only npm release tags
521
+ # Only runs on tag pipeline where the tag is a release version
522
+ # This requires dependencies to also run on tag pipeline
523
+ # However version tag comes with a version commit
524
+ # Dependencies must not run on the version commit
456
525
- if : $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+$/
0 commit comments