Skip to content

Commit c021272

Browse files
committed
WIP
1 parent ab25a9a commit c021272

File tree

1 file changed

+94
-25
lines changed

1 file changed

+94
-25
lines changed

.gitlab-ci.yml

+94-25
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,11 @@ check:lint:
4848
npm run lint;
4949
'
5050
rules:
51+
# Runs on feature and staging commits and ignores version commits
5152
- 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
5254
- 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
5356
- if: $CI_COMMIT_BRANCH && $CI_COMMIT_BRANCH != 'master' && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
5457
when: manual
5558

@@ -59,8 +62,11 @@ check:nix-dry:
5962
script:
6063
- nix-build -v -v --dry-run ./release.nix
6164
rules:
65+
# Runs on feature and staging commits and ignores version commits
6266
- 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
6368
- 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
6470
- if: $CI_COMMIT_BRANCH && $CI_COMMIT_BRANCH != 'master' && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
6571
when: manual
6672

@@ -79,9 +85,9 @@ check:test:
7985
junit:
8086
- ./tmp/junit.xml
8187
rules:
82-
# Run on feature branches, but not on version commits
88+
# Runs on staging commits and ignores version commits
8389
- 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
8591
- if: $CI_COMMIT_BRANCH && $CI_COMMIT_BRANCH !~ /^(?:master|staging)$/ && $CI_COMMIT_TITLE !~ /^[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
8692
when: manual
8793

@@ -106,7 +112,9 @@ build:linux:
106112
# Only the build:linux preserves the dist
107113
- ./dist
108114
rules:
115+
# Runs on staging commits and ignores version commits
109116
- 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
110118
- if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
111119

112120
build:windows:
@@ -134,7 +142,9 @@ build:windows:
134142
paths:
135143
- ./prebuilds/
136144
rules:
145+
# Runs on staging commits and ignores version commits
137146
- 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
138148
- if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
139149

140150
build:macos:
@@ -168,7 +178,9 @@ build:macos:
168178
paths:
169179
- ./prebuilds/
170180
rules:
181+
# Runs on staging commits and ignores version commits
171182
- 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
172184
- if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
173185

174186
build:prerelease:
@@ -211,10 +223,10 @@ build:prerelease:
211223
after_script:
212224
- rm -f ./.npmrc
213225
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
215227
# 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
218230
- if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+-.*[0-9]+$/
219231

220232
integration:builds:
@@ -250,7 +262,9 @@ integration:builds:
250262
paths:
251263
- ./builds/
252264
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
254268
- if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
255269

256270
integration:deployment:
@@ -260,13 +274,17 @@ integration:deployment:
260274
script:
261275
- echo 'Perform service deployment for integration testing'
262276
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
264280
- if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
265281

266282
integration:nix:
267283
stage: integration
268284
needs:
269285
- integration:builds
286+
- job: integration:deployment
287+
optional: true
270288
script:
271289
- >
272290
build_application="$( \
@@ -276,13 +294,17 @@ integration:nix:
276294
)"
277295
- $build_application/bin/typescript-demo-lib
278296
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
280300
- if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
281301

282302
integration:docker:
283303
stage: integration
284304
needs:
285305
- integration:builds
306+
- job: integration:deployment
307+
optional: true
286308
image: docker:20.10.11
287309
services:
288310
- docker:20.10.11-dind
@@ -294,43 +316,57 @@ integration:docker:
294316
- image="$(docker load --input ./builds/*docker* | cut -d' ' -f3)"
295317
- docker run "$image"
296318
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
298322
- if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
299323

300324
integration:linux:
301325
stage: integration
302326
needs:
303327
- integration:builds
328+
- job: integration:deployment
329+
optional: true
304330
image: ubuntu:latest
305331
script:
306332
- for f in ./builds/*-linux-*; do "$f"; done
307333
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
309337
- if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
310338

311339
integration:windows:
312340
stage: integration
313341
needs:
314342
- integration:builds
343+
- job: integration:deployment
344+
optional: true
315345
tags:
316346
- windows
317347
script:
318348
- Get-ChildItem -File ./builds/*-win-* | ForEach {& $_.FullName}
319349
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
321353
- if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
322354

323355
integration:macos:
324356
stage: integration
325357
needs:
326358
- integration:builds
359+
- job: integration:deployment
360+
optional: true
327361
tags:
328362
- shared-macos-amd64
329363
image: macos-11-xcode-12
330364
script:
331365
- for f in ./builds/*-macos-x64*; do "$f"; done
332366
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
334370
- if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+(?:-.*[0-9]+)?$/
335371

336372
integration:prerelease:
@@ -380,7 +416,11 @@ integration:prerelease:
380416
fi;
381417
'
382418
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]+$/
384424

385425
integration:merge:
386426
stage: integration
@@ -397,13 +437,12 @@ integration:merge:
397437
optional: true
398438
script:
399439
- echo 'use gh to create and merge PR from staging to master'
440+
- echo 'use github commit status to signal master to allow merge'
400441
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]+)?$/
407446

408447
release:deployment:
409448
stage: release
@@ -413,16 +452,16 @@ release:deployment:
413452
ref: staging
414453
artifacts: true
415454
script:
416-
- echo 'Perform service deployment for production release'
455+
- echo 'Perform service deployment for production'
417456
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]+$/
419461

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
422462
release:distribution:
423463
stage: release
424464
needs:
425-
- release:deployment
426465
- project: $CI_PROJECT_PATH
427466
job: build:linux
428467
ref: staging
@@ -439,18 +478,48 @@ release:distribution:
439478
job: integration:builds
440479
ref: staging
441480
artifacts: true
481+
- job: release:deployment
482+
optional: true
442483
# Don't interrupt publishing job
443484
interruptible: false
444485
allow_failure: true
445486
before_script:
446487
- echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ./.npmrc
447488
script:
489+
- echo 'Publishing library & application release'
448490
- >
449491
nix-shell --run '
450492
npm publish --access public;
451493
'
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+
'
452518
after_script:
453519
- rm -f ./.npmrc
454520
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
456525
- if: $CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+$/

0 commit comments

Comments
 (0)