forked from mutable-org/mutable
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
657 lines (598 loc) · 23.9 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
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
# vim: set expandtab tabstop=4 shiftwidth=4:
#-----------------------------------------------------------------------------------------------------------------------
# GENERAL
#-----------------------------------------------------------------------------------------------------------------------
variables:
PYTHON_VERSION: "3.10"
default:
before_script:
- >
# if [ "$CI_COMMIT_REF_PROTECTED" == "true" ];
# then
# echo "Running on protected branch. Importing SSH identity."
mkdir -p "${HOME}/.ssh"
chmod 700 "${HOME}/.ssh"
eval $(ssh-agent -s)
echo "${SSH_PRIVATE_KEY}" | tr -d '\r' | ssh-add -
echo "${SSH_GITHUB_DEPLOY_KEY}" | tr -d '\r' | ssh-add -
echo "${SSH_KNOWN_HOSTS}" > "${HOME}/.ssh/known_hosts"
chmod 644 "${HOME}/.ssh/known_hosts"
# else
# echo "Running on unprotected branch."
# fi
workflow:
rules:
- if: $CI_MERGE_REQUEST_IID # run on MRs
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH # run on main branch after MR
- if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS # don't run on individual commits that are part of a MR…
when: never # …to prevent duplicate pipelines for branches with a MR
# Define the stages of the pipeline.
stages:
- check
- build:debug
- test:debug
- build:release
- test:release
- report
- upload
- publish
.build_cache:
cache:
- key: "third-party"
paths:
- "third-party"
- "build/{debug,release,coverage}/**/*-download" # cache CMake download stamps
- "build/{debug,release,coverage}/**/*-gitclone-lastrun.txt" # cache CMake Git stamps
- "build/{debug,release,coverage}/**/*-gitinfo.txt" # cache CMake Git stamps
- "build/{debug,release,coverage}/**/*-configure" # cache CMake configure stamps
- key: "build:${BUILD_TYPE}:${LIBRARY_TYPE}"
paths:
- "build/${BUILD_TYPE}/bin" # cache our executables
- "build/${BUILD_TYPE}/lib/libmutable.{a,so,dylib,dll}" # cache our library
- "build/${BUILD_TYPE}/third-party/src/*-build" # cache third-party build
- "build/${BUILD_TYPE}/src/**/*.o" # cache all object files
.static:
variables:
LIBRARY_TYPE: static
.shared:
variables:
LIBRARY_TYPE: shared
.debug:
variables:
BUILD_TYPE: debug
.release:
variables:
BUILD_TYPE: release
rules:
# run on default branch
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
when: on_success
# run on branches with `release` in their name
- if: $CI_COMMIT_BRANCH =~ /release/i
when: on_success
# never run on merge requests in WIP/Draft mode
- if: $CI_MERGE_REQUEST_TITLE == null || ($CI_MERGE_REQUEST_TITLE =~ /^wip:/i || $CI_MERGE_REQUEST_TITLE =~ /^draft:/i)
when: never
# run on other merge requests (i.e. not marked as WIP/Draft)
- if: $CI_MERGE_REQUEST_TITLE
when: on_success
.coverage:
variables:
BUILD_TYPE: coverage
.upload:
rules:
# Do not run if tag was created
- if: $CI_COMMIT_TAG
when: never
# run on default branch
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
when: on_success
.publish:
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
when: on_success
- when: never
#-----------------------------------------------------------------------------------------------------------------------
# CHECK
#-----------------------------------------------------------------------------------------------------------------------
check:syntax:
stage: check
script:
- echo ${CI_COMMIT_BEFORE_SHA} ${CI_COMMIT_SHA} ${CI_COMMIT_REF_NAME} | hooks/pre-receive
#-----------------------------------------------------------------------------------------------------------------------
# DEBUG BUILD
#-----------------------------------------------------------------------------------------------------------------------
build:debug:linux-amd64:
stage: build:debug
tags:
- linux
- amd64
extends:
- .debug
- .shared
- .build_cache
script:
- pipenv --python $PYTHON_VERSION sync
- pipenv run cmake -S . -B build/${BUILD_TYPE}
--fresh
-G Ninja
-DCMAKE_C_COMPILER=clang
-DCMAKE_CXX_COMPILER=clang++
-DCMAKE_BUILD_TYPE=Debug
-DBUILD_SHARED_LIBS=ON
-DWITH_V8=ON
-DENABLE_SANITIZERS=ON
-DENABLE_SANITY_FIELDS=ON
- pipenv run cmake --build build/${BUILD_TYPE} --target Boost gitversion
- pipenv run cmake --build build/${BUILD_TYPE} --target all unittest
- find build/${BUILD_TYPE}/third-party -name '*.so' -exec cp {} build/${BUILD_TYPE}/lib \; # collect shared libraries
- find build/${BUILD_TYPE}/third-party -name '*.so.*' -exec cp {} build/${BUILD_TYPE}/lib \; # collect shared libraries
artifacts:
paths:
- "build/${BUILD_TYPE}/bin/{lex,parse,check,shell,unittest}"
- "build/${BUILD_TYPE}/lib/"
expire_in: 1 day
build:debug:macos-amd64:
stage: build:debug
tags:
- macos
- amd64
extends:
- .debug
- .shared
- .build_cache
script:
- pipenv --python $PYTHON_VERSION sync
- pipenv run cmake -S . -B build/${BUILD_TYPE}
--fresh
-G Ninja
-DCMAKE_C_COMPILER=$(brew --prefix llvm@17)/bin/clang
-DCMAKE_CXX_COMPILER=$(brew --prefix llvm@17)/bin/clang++
-DCMAKE_BUILD_TYPE=Debug
-DBUILD_SHARED_LIBS=ON
-DWITH_V8=ON
-DENABLE_SANITIZERS=ON
-DENABLE_SANITY_FIELDS=ON
- pipenv run cmake --build build/${BUILD_TYPE} --target Boost gitversion
- pipenv run cmake --build build/${BUILD_TYPE} --target all unittest
- find build/${BUILD_TYPE}/third-party -name '*.dylib' -exec cp {} build/${BUILD_TYPE}/lib \; # collect shared libraries
- find build/${BUILD_TYPE}/third-party -name '*.dylib.*' -exec cp {} build/${BUILD_TYPE}/lib \; # collect shared libraries
artifacts:
paths:
- "build/${BUILD_TYPE}/bin/{lex,parse,check,shell,unittest}"
- "build/${BUILD_TYPE}/lib/"
expire_in: 1 day
#-----------------------------------------------------------------------------------------------------------------------
# TEST DEBUG
#-----------------------------------------------------------------------------------------------------------------------
unittest:linux-amd64:
stage: test:debug
tags:
- linux
- amd64
needs:
- job: "build:debug:linux-amd64"
artifacts: true
script:
- pipenv --python $PYTHON_VERSION sync
- env pipenv run utils/unittest-parallel.py -r --out unittest-sanity.xml build/debug/bin/unittest -t '[test-sanity]' || true
- head -n1 unittest-sanity.xml | perl -n -e '/errors="(\d+)" failures="(\d+)" tests="(\d+)/ && exit ($1 != 2 or $2 != 1 or $3 != 2)' # we expect 2 errors (abort & segv), one failure (failure), and two tests run (failure & success)
- env UBSAN_OPTIONS=print_stacktrace=1 ASAN_OPTIONS=detect_stack_use_after_return=1 pipenv run utils/unittest-parallel.py -r --out unittest-results.xml build/debug/bin/unittest
artifacts:
when: always
paths:
- unittest-sanity.xml
- unittest-results.xml
reports:
junit: unittest-results.xml
unittest:macos-amd64:
stage: test:debug
tags:
- macos
- amd64
needs:
- job: "build:debug:macos-amd64"
artifacts: true
script:
- pipenv --python $PYTHON_VERSION sync
- env pipenv run utils/unittest-parallel.py -r --out unittest-sanity.xml build/debug/bin/unittest -t '[test-sanity]' || true
- head -n1 unittest-sanity.xml | perl -n -e '/errors="(\d+)" failures="(\d+)" tests="(\d+)/ && exit ($1 != 2 or $2 != 1 or $3 != 2)' # we expect 2 errors (abort & segv), one failure (failure), and two tests run (failure & success)
- env UBSAN_OPTIONS=print_stacktrace=1 ASAN_OPTIONS=detect_stack_use_after_return=1:detect_container_overflow=0 MallocNanoZone=0 pipenv run utils/unittest-parallel.py -r --out unittest-results.xml build/debug/bin/unittest
artifacts:
when: always
paths:
- unittest-sanity.xml
- unittest-results.xml
reports:
junit: unittest-results.xml
integrationtest:linux-amd64:
stage: test:debug
tags:
- linux
- amd64
needs:
- job: "build:debug:linux-amd64"
artifacts: true
script:
- pipenv --python $PYTHON_VERSION sync
- env UBSAN_OPTIONS=print_stacktrace=1 ASAN_OPTIONS=detect_stack_use_after_return=1 --unset=TERM pipenv run test/IntegrationTest.py --required-only --debug --builddir build/debug
integrationtest:macos-amd64:
stage: test:debug
tags:
- macos
- amd64
needs:
- job: "build:debug:macos-amd64"
artifacts: true
script:
- pipenv --python $PYTHON_VERSION sync
- env UBSAN_OPTIONS=print_stacktrace=1 ASAN_OPTIONS=detect_stack_use_after_return=1:detect_container_overflow=0 MallocNanoZone=0 --unset=TERM pipenv run test/IntegrationTest.py --required-only --debug --builddir build/debug
ensure-exported-symbols:debug:linux:
stage: test:debug
tags:
- linux
extends:
- .debug
- .shared
needs:
- job: "build:debug:linux-amd64"
artifacts: true
script:
- llvm-nm -C build/${BUILD_TYPE}/lib/libmutable.so | awk 'BEGIN{rc=1}; /T m::init\(\)/{rc=0}; END{exit rc}'
ensure-exported-symbols:debug:macos:
stage: test:debug
tags:
- macos
extends:
- .debug
- .shared
needs:
- job: "build:debug:macos-amd64"
artifacts: true
script:
- llvm-nm -C build/${BUILD_TYPE}/lib/libmutable.dylib | awk 'BEGIN{rc=1}; /T m::init\(\)/{rc=0}; END{exit rc}'
#-----------------------------------------------------------------------------------------------------------------------
# RELEASE BUILD
#-----------------------------------------------------------------------------------------------------------------------
build:release:linux-amd64:
stage: build:release
tags:
- linux
- amd64
extends:
- .release
- .static
- .build_cache
script:
- cmake -S . -B build/${BUILD_TYPE}
--fresh
-G Ninja
-DCMAKE_C_COMPILER=clang
-DCMAKE_CXX_COMPILER=clang++
-DCMAKE_BUILD_TYPE=Release
-DBUILD_SHARED_LIBS=OFF
-DWITH_V8=ON
-DENABLE_SANITIZERS=OFF
-DENABLE_SANITY_FIELDS=OFF
- cmake --build build/${BUILD_TYPE} --target Boost gitversion
- cmake --build build/${BUILD_TYPE} --target shell cardinality_gen
- mkdir -p mutable/lib mutable/bin
- cp -R include mutable
- cp build/${BUILD_TYPE}/lib/libmutable_bundled.a mutable/lib
- cp build/${BUILD_TYPE}/bin/cardinality_gen mutable/bin
- cp build/${BUILD_TYPE}/bin/shell mutable/bin
artifacts:
paths:
- "mutable"
expire_in: 1 day
build:release:macos-amd64:
stage: build:release
tags:
- macos
- amd64
extends:
- .release
- .static
- .build_cache
script:
- cmake -S . -B build/${BUILD_TYPE}
--fresh
-G Ninja
-DCMAKE_C_COMPILER=$(brew --prefix llvm@17)/bin/clang
-DCMAKE_CXX_COMPILER=$(brew --prefix llvm@17)/bin/clang++
-DCMAKE_BUILD_TYPE=Release
-DBUILD_SHARED_LIBS=OFF
-DWITH_V8=ON
-DENABLE_SANITIZERS=OFF
-DENABLE_SANITY_FIELDS=OFF
- cmake --build build/${BUILD_TYPE} --target Boost gitversion
- cmake --build build/${BUILD_TYPE} --target shell cardinality_gen
- mkdir -p mutable/lib mutable/bin
- cp -R include mutable
- cp build/${BUILD_TYPE}/lib/libmutable_bundled.a mutable/lib
- cp build/${BUILD_TYPE}/bin/cardinality_gen mutable/bin
- cp build/${BUILD_TYPE}/bin/shell mutable/bin
artifacts:
paths:
- "mutable"
expire_in: 1 day
#-----------------------------------------------------------------------------------------------------------------------
# TEST RELEASE
#-----------------------------------------------------------------------------------------------------------------------
ensure-exported-symbols:release:linux:
stage: test:release
tags:
- linux
extends:
- .release
- .static
needs:
- job: "build:release:linux-amd64"
artifacts: true
script:
- llvm-nm -C mutable/lib/libmutable_bundled.a | awk 'BEGIN{rc=1}; /T m::init\(\)/{rc=0}; END{exit rc}'
- llvm-nm -C mutable/lib/libmutable_bundled.a | awk 'BEGIN{rc=1}; /T v8::V8::Initialize\(int\)/{rc=0}; END{exit rc}'
- llvm-nm -C mutable/lib/libmutable_bundled.a | awk 'BEGIN{rc=1}; /T wasm::IString::interned\(/{rc=0}; END{exit rc}'
ensure-exported-symbols:release:macos:
stage: test:release
tags:
- macos
extends:
- .release
- .static
needs:
- job: "build:release:macos-amd64"
artifacts: true
script:
- llvm-nm -C mutable/lib/libmutable_bundled.a | awk 'BEGIN{rc=1}; /T m::init\(\)/{rc=0}; END{exit rc}'
- llvm-nm -C mutable/lib/libmutable_bundled.a | awk 'BEGIN{rc=1}; /T v8::V8::Initialize\(/{rc=0}; END{exit rc}'
- llvm-nm -C mutable/lib/libmutable_bundled.a | awk 'BEGIN{rc=1}; /T wasm::IString::interned\(/{rc=0}; END{exit rc}'
benchmark-test:release:linux-amd64:
stage: test:release
tags:
- linux
- amd64
extends:
- .release
- .static
needs:
- job: "build:release:linux-amd64"
artifacts: true
script:
# Install DuckDB
- wget 'https://github.com/duckdb/duckdb/releases/download/v0.10.2/duckdb_cli-linux-amd64.zip'
- unzip 'duckdb_cli-linux-amd64.zip' -d 'benchmark/database_connectors/'
# Run benchmarks
- pipenv --python $PYTHON_VERSION sync
- env pipenv run benchmark/Benchmark.py -v -b mutable -o dummy.csv benchmark/dummy
# Validate results
- cat dummy.csv | perl -n -e '/dummy,Dummy,(.*),Execution Time/ && print "$1\n"' | sort | uniq > names.txt # collect system names
- |
diff names.txt - <<- EOF
DuckDB (16 cores)
DuckDB (single core)
HyPer (16 cores)
HyPer (single core)
"mutable (single core, WasmV8, PAX4M)"
PostgreSQL
EOF
artifacts:
when: always
paths:
- dummy.csv
- names.txt
#-----------------------------------------------------------------------------------------------------------------------
# REPORT
#-----------------------------------------------------------------------------------------------------------------------
report:doxygen:
stage: report
tags:
- nginx
script:
- doxygen -q Doxyfile 2>doxygen.log
- rm -rf /srv/http/mutable/doxy
- mkdir -p /srv/http/mutable/doxy
- cp -rf doxy/html/* /srv/http/mutable/doxy
- scp -r doxy/html/* [email protected]:/srv/http/mutable-doxy
artifacts:
paths:
- "doxygen.log"
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
when: on_success
- if: $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME =~ /report/i
when: on_success
report:coverage:
stage: report
tags:
- nginx
needs: [ "build:debug:linux-amd64" ]
script:
- utils/coverage.sh
- rm -rf /srv/http/mutable/coverage
- mv build/${BUILD_TYPE}/html /srv/http/mutable/coverage
coverage: '/lines\.+: \d+\.\d+/'
extends:
- .coverage
- .shared
- .build_cache
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
when: on_success
- if: $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME =~ /coverage/i
when: on_success
#-----------------------------------------------------------------------------------------------------------------------
# UPLOAD GENERIC PACKAGE & CREATE GITLAB RELEASE
#-----------------------------------------------------------------------------------------------------------------------
upload:tag-version:
stage: upload
extends:
- .upload
script:
# Find the latest version tag in the git log (ignore failure since we handle it inside this script)
- latest_version_tag=$(git describe --tags --match "v*" --abbrev=0 2>/dev/null) || true
# If no version tags are found, start with v0.0.0
# Else get the version number from the latest version tag
- |
if [ -z "$latest_version_tag" ]; then
latest_version="0.0.0"
else
latest_version=$(echo "$latest_version_tag" | tail -c +2)
fi
- echo "New version tag is ${new_version}"
- |
if git tag --points-at HEAD | grep -q "v[0-9]\+\.[0-9]\+\.[0-9]\+"; then
echo "Latest commit already has a version tag '$latest_version_tag'"
echo "TAG=${latest_version_tag}" >> variables.env
else
echo "Bump patch number"
patch=$(echo "$latest_version" | awk -F. '{print $3}')
((new_patch = patch + 1))
new_version=$(printf "v%s.%s.%s" "$(echo "$latest_version" | head -c 1)" "$(echo "$latest_version" | cut -d "." -f 2)" "$new_patch")
echo "TAG=${new_version}" >> variables.env
echo "Push new tag '$new_version' to git."
curl --fail --header "PRIVATE-TOKEN: ${ADD_RELEASES_TOKEN}" --request POST "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/repository/tags?tag_name=${new_version}&ref=${CI_COMMIT_SHA}"
fi
artifacts:
reports:
dotenv: variables.env
upload:package:linux-amd64:
stage: upload
extends:
- .upload
tags:
- linux
- amd64
needs:
- job: build:release:linux-amd64
artifacts: true
- job: upload:tag-version
artifacts: true
script:
- cd mutable
- zip -r mutable-linux-amd64.zip *
- >
curl --fail --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file mutable-linux-amd64.zip
"${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/mutable/${TAG}/mutable-linux-amd64-${TAG}.zip"
artifacts:
paths:
- "mutable/mutable-linux-amd64.zip"
expire_in: 1 day
upload:package:macos-amd64:
stage: upload
extends:
- .upload
tags:
- macos
- amd64
needs:
- job: build:release:macos-amd64
artifacts: true
- job: upload:tag-version
artifacts: true
script:
- cd mutable
- zip -r mutable-macos-amd64.zip *
- >
curl --fail --header "JOB-TOKEN: ${CI_JOB_TOKEN}" --upload-file mutable-macos-amd64.zip
"${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/mutable/${TAG}/mutable-macos-amd64-${TAG}.zip"
artifacts:
paths:
- "mutable/mutable-macos-amd64.zip"
expire_in: 1 day
upload:release:
stage: upload
extends:
- .upload
needs:
- job: upload:package:linux-amd64
- job: upload:package:macos-amd64
- job: upload:tag-version
artifacts: true
script:
# Create Release on GitLab
- >
curl -v --fail --header "Content-Type: application/json"
--header "PRIVATE-TOKEN: ${ADD_RELEASES_TOKEN}"
--data "{ \"name\": \"Mutable Release ${TAG}\", \"tag_name\": \"${TAG}\",
\"assets\": { \"links\": [
{ \"name\": \"mutable linux-amd64\",
\"url\": \"${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/mutable/${TAG}/mutable-linux-amd64-${TAG}.zip\",
\"link_type\": \"package\" },
{ \"name\": \"mutable macos-amd64\",
\"url\": \"${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/mutable/${TAG}/mutable-macos-amd64-${TAG}.zip\",
\"link_type\": \"package\" } ] } }"
--request POST "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/releases"
#-----------------------------------------------------------------------------------------------------------------------
# MIRROR TO GITHUB
#-----------------------------------------------------------------------------------------------------------------------
publish:github-repository:
stage: publish
extends:
- .publish
script:
- git remote add gitlab [email protected]:bigdata/mutable/mutable.git || true
- git remote remove github || true
- git remote add github [email protected]:mutable-org/mutable.git
- git fetch gitlab
- git push --tags github gitlab/$CI_DEFAULT_BRANCH:$CI_DEFAULT_BRANCH # update main branch on GitHub
- git push github gitlab/$CI_DEFAULT_BRANCH:pr-target # update branch pr-target on GitHub
publish:github-release:
stage: publish
extends:
- .publish
needs:
- job: publish:github-repository
- job: upload:package:linux-amd64
artifacts: true
- job: upload:package:macos-amd64
artifacts: true
- job: upload:tag-version
artifacts: true
script:
# generate JSON Web Token (JWT) for our GitHub App
- |
header=$(echo -n '{"typ":"JWT","alg":"RS256"}' | openssl base64 -A | sed 's/=*$//g')
payload=$(echo -n '{"iat": '$(date +%s)', "exp": '$(($(date +%s) + 590))', "iss": "317308" }' | openssl base64 -A | sed 's/=*$//g')
signature=$(echo -n "$header.$payload" | openssl dgst -sha256 -sign <(echo "$SSH_GITHUB_APP_TOKEN") | openssl base64 -A | sed 's/=*$//g' | tr '/' '_' | tr '+' '-')
jwt="$header.$payload.$signature"
# generate installation access token for the mutable GitHub repository
- >
response=$(curl -L -f
-H "Accept: application/vnd.github+json"
-H "Authorization: Bearer $jwt"
-H "X-GitHub-Api-Version: 2022-11-28"
"https://api.github.com/app/installations/36391181/access_tokens"
-d '{"repository":"mutable","permissions":{"contents":"write"}}')
- |
inst_acc_token=$(echo "$response" | grep -oP '(?<=token": ").*?(?=")')
# create GitHub release
- >
response=$(curl -L -f
-X POST
-H "Accept: application/vnd.github+json"
-H "Authorization: Bearer $inst_acc_token"
-H "X-GitHub-Api-Version: 2022-11-28"
"https://api.github.com/repos/mutable-org/mutable/releases"
-d "{\"tag_name\":\"${TAG}\",\"target_commitish\":\"main\"}")
- |
upload_url=$(echo "$response" | grep -oP '(?<=upload_url": ").*?(?={)')
# add assets to release
- >
curl -L -f
-X POST
-H "Accept: application/vnd.github+json"
-H "Authorization: Bearer $inst_acc_token"
-H "X-GitHub-Api-Version: 2022-11-28"
-H "Content-Type: application/octet-stream"
"${upload_url}?name=mutable-linux-amd64-${TAG}.zip"
--data-binary "@mutable/mutable-linux-amd64.zip"
- >
curl -L -f
-X POST
-H "Accept: application/vnd.github+json"
-H "Authorization: Bearer $inst_acc_token"
-H "X-GitHub-Api-Version: 2022-11-28"
-H "Content-Type: application/octet-stream"
"${upload_url}?name=mutable-macos-amd64-${TAG}.zip"
--data-binary "@mutable/mutable-macos-amd64.zip"