-
Notifications
You must be signed in to change notification settings - Fork 2
1007 lines (860 loc) · 43.3 KB
/
build-targets.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
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# This is a workflow to cache the sources and build all the artifacts for target OSs
name: Cache Sources and build Artifact Libraries per OS
on:
workflow_dispatch:
env:
GH_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN_1 }}
jobs:
setup-src-cache:
runs-on: ubuntu-latest
outputs:
THIRD_PARTY_CACHE_NAME_KEY: ${{ steps.tp-check.outputs.THIRD_PARTY_CACHE_NAME_KEY }}
FOUND_THIRD_PARTY_CURRENT: ${{ steps.tp-check.outputs.FOUND_THIRD_PARTY_CURRENT }}
CACHE_MATRIX: ${{ steps.set-cache-matrix.outputs.CACHE_MATRIX }}
NEEDS_CACHE: ${{ steps.set-cache-matrix.outputs.NEEDS_CACHE }}
CACHE_MULTI_PARAMETER_NAME_KEYS: ${{ steps.set-cache-matrix.outputs.CACHE_MULTI_PARAMETER_NAME_KEYS }}
CACHE_MULTI_PARAMETER_PATHS: ${{ steps.set-cache-matrix.outputs.CACHE_MULTI_PARAMETER_PATHS }}
steps:
- name: Check out main third party without submodules
uses: actions/checkout@v4
with:
submodules: false
- name: Install GH cli extension actions-cache
run: |
gh extension install actions/gh-actions-cache
# get currently authenticated user rate limit info
rateRemaining=`gh api rate_limit --jq ".rate | .remaining"`
echo "Rate limit remaining is $rateRemaining"
gh extension install actions/gh-actions-cache
echo "REPO=${{ github.repository }}" >> $GITHUB_ENV
echo "BRANCH=${{ github.ref_name }}" >> $GITHUB_ENV
- name: Find cache and clean out old caches of `thirdparty`
id: tp-check
run: |
echo "Fetching list of thirdparty cache keys to check if any old ones need deleting"
cacheList=$(gh cache list -k ${BRANCH}/thirdparty --json key --jq ".[].key")
longSHA="${{ github.sha }}"
shortSHA="${longSHA:0:7}"
tpCacheNameSHA="$BRANCH/thirdparty-$shortSHA"
notMatched="$(comm -3 --output-delimiter="" <(echo -en "$tpCacheNameSHA") <(echo -en "$cachesList"))"
oldCaches="$(comm -13 --output-delimiter="" <(echo -en "$tpCacheNameSHA") <(echo -en "$notMatched"))"
notCached="$(comm -12 --output-delimiter="" <(echo -en "$tpCacheNameSHA") <(echo -en "$notMatched"))"
echo -e "notMatched: $notMatched"
echo -e "oldCaches: $oldCaches"
echo -e "notCached: $notCached"
foundThirdPartyCurrent="true"
if [[ $notCached == "$tpCacheNameSHA" ]]; then
foundThirdPartyCurrent="false"
fi
# Set the field separator to new line
IFS=$'\n'
for oldCache in $oldCaches; do
echo -e "Deleting old cache $oldCache"
gh actions-cache delete $oldCache -R $REPO -B $BRANCH --confirm
done
echo "FOUND_THIRD_PARTY_CURRENT=$foundThirdPartyCurrent" >> $GITHUB_OUTPUT
echo "THIRD_PARTY_CACHE_NAME_KEY=$tpCacheNameSHA" >> $GITHUB_OUTPUT
shell: bash
working-directory: ${{github.workspace}}
- name: Cache source files
if: ( steps.tp-check.outputs.FOUND_THIRD_PARTY_CURRENT == 'false' )
uses: GeniusVentures/[email protected]
id: cache-source-directory
with:
key: ${{ steps.tp-check.outputs.THIRD_PARTY_CACHE_NAME_KEY }}
enableCrossOsArchive: true
path: |
!.git/**
./**
- name: Set matrix of src submodules that need updating
id: set-cache-matrix
run: |
echo "Fetching list of cache keys to check if any old ones need deleting"
cacheNames=""
while read -r mode stage longsha location; do
shortSHA="${longsha:0:7}"
cacheNames+="s/$BRANCH/$location-$shortSHA\n"
done <<< $(git ls-tree HEAD | grep "160000 commit")
cacheNames="$(echo -en "$cacheNames" | sort)"
cachesList=$(gh api -H "Accept: application/vnd.github+json" --paginate repos/GeniusVentures/thirdparty/actions/caches?key="s/${BRANCH}" | jq -r ".actions_caches[].key" | sort)
notMatched="$(comm -3 --output-delimiter="" <(echo -en "$cacheNames") <(echo -en "$cachesList"))"
oldCaches="$(comm -13 --output-delimiter="" <(echo -en "$cacheNames") <(echo -en "$notMatched"))"
notCached="$(comm -12 --output-delimiter="" <(echo -en "$cacheNames") <(echo -en "$notMatched"))"
# matrixJson = matrix of source code to cache, that isn't already cached
matrixJson="[ "
first=true
# Set the field separator to new line
IFS=$'\n'
for toCache in $notCached; do
len=${#toCache}
startPos=$((len - 7))
shortSHA="${toCache:$startPos:7}"
lenBranch=${#BRANCH}
# - 10 - lenBranch - 1 for s/$BRANCH/ + '-' + shortSHA
name="${toCache:$((2 + lenBranch + 1)):$((len - 10 - lenBranch - 1))}"
if [[ "$first" != "true" ]]; then
matrixJson+=", "
fi
first=false
matrixJson+="{ \"name\": \"$name\", \"cache-name\": \"$toCache\" }"
done
matrixJson+=" ]"
# Delete old caches
for oldCache in $oldCaches; do
echo "Deleting old cache $oldCache"
gh actions-cache delete $oldCache -R $REPO -B $BRANCH --confirm
done
echo "CACHE_MATRIX=$matrixJson" >> $GITHUB_OUTPUT
if [[ "$notCached" != "" ]]; then
echo "NEEDS_CACHE=true" >> $GITHUB_OUTPUT
else
echo "NEEDS_CACHE=false" >> $GITHUB_OUTPUT
fi
cacheNameKeysContent="[ "
cachePathsContent="[ "
first='true'
for cacheName in $cacheNames; do
len=${#cacheName}
startPos=$((len - 7))
shortSHA="${cacheName:$startPos:7}"
lenBranch=${#BRANCH}
# - 10 - lenBranch - 1 for s/$BRANCH/ + '-' + shortSHA
name="${cacheName:$((2 + lenBranch + 1)):$((len - 10 - lenBranch - 1))}"
if [[ "$first" != "true" ]]; then
cacheNameKeysContent+=", "
cachePathsContent+=", "
fi
first='false'
cacheNameKeysContent+="\"$cacheName\""
cachePathsContent+="[\"!./$name/.git/**\", \"./$name/**\"]"
done
cacheNameKeysContent+=" ]"
echo "CACHE_MULTI_PARAMETER_NAME_KEYS=$cacheNameKeysContent" >> $GITHUB_OUTPUT
cachePathsContent+=" ]"
echo "CACHE_MULTI_PARAMETER_PATHS=$cachePathsContent" >> $GITHUB_OUTPUT
shell: bash
working-directory: ${{github.workspace}}
cache-src:
needs: setup-src-cache
if: (needs.setup-src-cache.outputs.NEEDS_CACHE == 'true')
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
include: ${{ fromJson(needs.setup-src-cache.outputs.CACHE_MATRIX) }}
steps:
- name: Setup
run: |
sudo apt install zstd -y
- name: Cache third party directory
uses: GeniusVentures/cache-multi/[email protected]
id: cache-tp-source-directory
with:
key: ${{ needs.setup-src-cache.outputs.THIRD_PARTY_CACHE_NAME_KEY }}
enableCrossOsArchive: true
path: |
!.git/**
./**
- if: (steps.cache-tp-source-directory.outputs.cache-hit != 'true')
run: |
echo "Couldn't find cached thirdparty code, ${{ needs.setup-src-cache.outputs.THIRD_PARTY_CACHE_NAME_KEY }} fatal error!"
exit 1
- name: Git clone submodule source code
run: |
echo "Cloning source for ${{ matrix.name }}"
git submodule update --init --recommend-shallow --recursive -- ${{ matrix.name }}
shell: bash
working-directory: ${{github.workspace}}
- name: Cache submodule source files
id: cache-source-directory
uses: GeniusVentures/[email protected]
with:
key: ${{ matrix.cache-name }}
enableCrossOsArchive: true
path: |
!./${{ matrix.name }}/.git/**
./${{ matrix.name }}/**
create-targets-matrix:
needs: [setup-src-cache, cache-src]
if: |
always() &&
needs.setup-src-cache.result == 'success' &&
(needs.cache-src.result == 'success' || needs.cache-src.result == 'skipped')
runs-on: ubuntu-latest
outputs:
TARGET_NAMES: ${{ steps.create-target-info.outputs.TARGET_NAMES }}
TARGET_SHAS: ${{ steps.create-target-info.outputs.TARGET_SHAS }}
TARGET_DIRECTORIES: ${{ steps.create-target-info.outputs.TARGET_DIRECTORIES }}
TARGET_REPO_NAMES: ${{ steps.create-target-info.outputs.TARGET_REPO_NAMES }}
steps:
- name: Setup
run: sudo apt install zstd -y
- name: Restore cache third party directory
uses: GeniusVentures/cache-multi/[email protected]
id: cache-tp-source-directory
with:
key: ${{ needs.setup-src-cache.outputs.THIRD_PARTY_CACHE_NAME_KEY }}
enableCrossOsArchive: true
path: |
!.git/**
./**
- if: (steps.cache-tp-source-directory.outputs.cache-hit != 'true')
run: |
echo "Couldn't find cached thirdparty code, ${{ needs.setup-src-cache.outputs.THIRD_PARTY_CACHE_NAME_KEY }} fatal error!"
exit 1
- name: Restore submodule source files
id: cache-source-directory
uses: GeniusVentures/cache-multi/[email protected]
with:
multi-keys: ${{ needs.setup-src-cache.outputs.CACHE_MULTI_PARAMETER_NAME_KEYS }}
enableCrossOsArchive: true
paths: ${{ needs.setup-src-cache.outputs.CACHE_MULTI_PARAMETER_PATHS }}
- name: Create base target library names for target cache to create
id: create-target-info
run: |
cmake -S build/Linux -B build/Linux/Release -DCMAKE_BUILD_TYPE=Release
cd build/Linux/Release/CMakeFiles
declare -A cmakeBuildDir
while IFS=',' read -r cmakeName buildDir; do
cmakeBuildDir["$cmakeName"]="$buildDir"
done < <(grep -m1 -R --include "build.make" -e ".*-complete:.*-build" * |
sed -E -n 's/^(.*)\.dir.*-complete: ([^/]*?)\/src.*/\1,\2/p')
cd ..
declare -A cmakeNamesRepos
for key in "${!cmakeBuildDir[@]}"; do
sourceDir=$(find . -type f -name "${key}-source_dirinfo.txt" -exec sed -n "s|^source_dir=$GITHUB_WORKSPACE\/\(.*\)|\1|p" {} \;)
cmakeNamesRepos["$key"]=$sourceDir
echo "cmakeNameRepos = ${sourceDir}"
done
declare -A gitLibModules
cd ../../..
while IFS=',' read -r longSHA sourceDir; do
echo $longSha $sourceDir
gitLibModules["$sourceDir"]="$longSHA"
done < <(git ls-tree HEAD | sed -E -n 's/^(160000 commit|040000 tree) ([a-f0-9]+)[ \t]+([^ ]+)$/\1,\2/p')
# Initialize the variables
cmakeNames=""
buildDirectoryNames=""
repoNames=""
shortSHAs=""
# Define column widths
name_width=20
build_dir_width=20
source_dir_width=20
# Print header
printf "%-${name_width}s | %-${build_dir_width}s | %-${source_dir_width}s | %-${sha_width}s\n" "Name" "Build dir" "Source dir" "SHA"
for key in "${!cmakeBuildDir[@]}"; do
buildDir="${cmakeBuildDir[$key]}"
sourceDir="${cmakeNamesRepos[$key]}"
shortSHA="${gitLibModules[$sourceDir]:0:7}"
cmakeNames+="${key}\n"
buildDirectoryNames+="${buildDir}\n"
repoNames+="${sourceDir}\n"
shortSHAs+="${shortSHA}\n"
printf "%-${name_width}s | %-${build_dir_width}s | %-${source_dir_width}s | %s\n" "${key}" "${buildDir}" "${sourceDir}" "${shortSHA}"
done
echo "TARGET_NAMES=$cmakeNames" >> $GITHUB_OUTPUT
echo "TARGET_SHAS=$shortSHAs" >> $GITHUB_OUTPUT
echo "TARGET_DIRECTORIES=$buildDirectoryNames" >> $GITHUB_OUTPUT
echo "TARGET_REPO_NAMES=$repoNames" >> $GITHUB_OUTPUT
shell: bash
working-directory: ${{github.workspace}}
save-target-sources:
needs: [setup-src-cache, cache-src, create-targets-matrix]
if: |
always() &&
needs.setup-src-cache.result == 'success' &&
needs.create-targets-matrix.result == 'success' &&
(needs.cache-src.result == 'success' || needs.cache-src.result == 'skipped') &&
needs.create-targets-matrix.result == 'success'
strategy:
fail-fast: false
matrix:
target-os: [Linux, Windows, OSX, iOS, Android]
build-type: [Release, Debug]
runs-on: ubuntu-latest
steps:
- name: Setup
run: |
sudo apt install zstd -y
- name: Create library Keys and Paths to release sources
id: create-src-cache-keys
run: |
TARGET_OS="${{ matrix.target-os }}"
BUILD_TYPE="${{ matrix.build-type }}"
BRANCH=${{ github.ref_name }}
GITHUB_RELEASE_NAME=${TARGET_OS}-${BRANCH}-${BUILD_TYPE}
echo "TARGET_OS=${TARGET_OS}" >> $GITHUB_OUTPUT
echo "BUILD_TYPE=${BUILD_TYPE}" >> $GITHUB_OUTPUT
echo "BRANCH=${BRANCH}" >> $GITHUB_OUTPUT
echo "GITHUB_RELEASE_NAME=${GITHUB_RELEASE_NAME}" >> $GITHUB_OUTPUT
- name: Cache Third Party Directory
uses: GeniusVentures/cache-multi/[email protected]
id: cache-tp-source-directory
with:
key: ${{ needs.setup-src-cache.outputs.THIRD_PARTY_CACHE_NAME_KEY }}
enableCrossOsArchive: true
path: |
!.git/**
./**
- if: (steps.cache-tp-source-directory.outputs.cache-hit != 'true')
run: |
echo "Couldn't find cached thirdparty code, ${{ needs.setup-src-cache.outputs.THIRD_PARTY_CACHE_NAME_KEY }} fatal error!"
exit 1
- name: Cache Submodule source files without .git
id: cache-source-directory
uses: GeniusVentures/cache-multi/[email protected]
with:
multi-keys: ${{ needs.setup-src-cache.outputs.CACHE_MULTI_PARAMETER_NAME_KEYS }}
enableCrossOsArchive: true
paths: ${{ needs.setup-src-cache.outputs.CACHE_MULTI_PARAMETER_PATHS }}
- name: Creating github release tag
id: create-github-release-tag
run: |
echo "Check if github release tag ${{ steps.create-src-cache-keys.outputs.GITHUB_RELEASE_NAME }} available."
set +e
gh release view ${{ steps.create-src-cache-keys.outputs.GITHUB_RELEASE_NAME }}
releaseFound=$?
set -e
if [[ $releaseFound -ne 0 ]];
then
echo "gh release view return value: ${releaseFound}"
echo "Creating github release with tag: ${{ steps.create-src-cache-keys.outputs.GITHUB_RELEASE_NAME }}"
RELEASE_TYPE="--latest"
if [[ "${{ steps.create-src-cache-keys.outputs.BUILD_TYPE }}" != "Release" ]];
then
RELEASE_TYPE="--prerelease"
fi
# Create release on github
gh release create ${{ steps.create-src-cache-keys.outputs.GITHUB_RELEASE_NAME }} \
-n "${{ steps.create-src-cache-keys.outputs.BRANCH }} branch" \
--target "${{ steps.create-src-cache-keys.outputs.BRANCH }}" \
${RELEASE_TYPE} \
-t "${{ steps.create-src-cache-keys.outputs.TARGET_OS }} ${{ steps.create-src-cache-keys.outputs.BRANCH }} branch ${{ steps.create-src-cache-keys.outputs.BUILD_TYPE }} build"
releaseCreated=$?
if [[ $releaseCreated -ne 0 ]];
then
echo "gh release create return value: ${releaseCreated}"
echo "Failed to create github release with tag: ${{ steps.create-src-cache-keys.outputs.GITHUB_RELEASE_NAME }}"
exit 1
fi
fi
- name: Compress and upload targets source folder
id: compress-targets-source
working-directory: ${{github.workspace}}
run: |
# build array of library names
IFS=$'\n' read -d '|' -ra TARGET_NAMES <<< "$(echo -ne '${{ needs.create-targets-matrix.outputs.TARGET_NAMES }}|')"
IFS=$'\n' read -d '|' -ra TARGET_SHAS <<< "$(echo -ne '${{ needs.create-targets-matrix.outputs.TARGET_SHAS }}|')"
IFS=$'\n' read -d '|' -ra TARGET_REPO_NAMES <<< "$(echo -ne '${{ needs.create-targets-matrix.outputs.TARGET_REPO_NAMES }}|')"
# Check if release.json file already available
jsonStr="[]"
jsonFound=`gh release view ${{ steps.create-src-cache-keys.outputs.GITHUB_RELEASE_NAME }} --json assets --jq "any(.assets[]; .name == \"release.json\")"`
if [ $? -eq 0 ]
then
echo "Downloading release.json file"
set +e
gh release download ${{ steps.create-src-cache-keys.outputs.GITHUB_RELEASE_NAME }} --pattern "release.json" --clobber
if [ $? -eq 0 ]
then
echo "Loading release.json file"
jsonStr=`cat release.json`
fi
set -e
fi
RELEASE_ASSETS=`gh release view ${{ steps.create-src-cache-keys.outputs.GITHUB_RELEASE_NAME }} --json assets`
# get currently authenticated user rate limit info
rateRemaining=`gh api rate_limit --jq ".rate | .remaining"`
echo "Rate limit remaining is $rateRemaining"
# if we don't have at least 50 requests left, wait until reset
if [[ $rateRemaining -lt 50 ]];
then
rateReset=`gh api rate_limit --jq ".rate | .reset"`
wait=$((rateReset - `date +%s`));
echo "Rate limit remaining is $rateRemaining, waiting for $wait seconds to reset"
while [ $wait -ge 0 ]
do
sleep 5
wait=$((rateReset - `date +%s`));
echo "Waiting $wait seconds to reset rate limit"
done
rateRemaining=`gh api rate_limit --jq ".rate | .remaining"`
echo "Rate limit has reset to $rateRemaining requests"
fi
for i in "${!TARGET_NAMES[@]}"; do
TARGET_NAME="${TARGET_NAMES[i]}"
TARGET_REPO_NAME="${TARGET_REPO_NAMES[i]}"
TARGET_SHA="${TARGET_SHAS[i]}"
COMPRESSED_TARGET_SRC="${TARGET_NAME}-src.tar.gz"
shaFound=$(jq ".[] | select(.name == \"${TARGET_NAME}\") | .sha" <<<${jsonStr})
COMPRESSED_TARGET_SRC_URL=`jq ".assets[] | select(.name == \"${COMPRESSED_TARGET_SRC}\") | .url" <<< ${RELEASE_ASSETS}`
if [ -z "$COMPRESSED_TARGET_SRC_URL" ] || [[ "${shaFound}" != \"${TARGET_SHA}\" ]];
then
echo "Compressing ${TARGET_OS} version ${TARGET_SHA} of ${TARGET_REPO_NAME} source folder"
tar -zcf ${COMPRESSED_TARGET_SRC} ${TARGET_REPO_NAME}
echo "Uploading target ${COMPRESSED_TARGET_SRC} to github release ${{ steps.create-src-cache-keys.outputs.GITHUB_RELEASE_NAME }}"
gh release upload --clobber ${{ steps.create-src-cache-keys.outputs.GITHUB_RELEASE_NAME }} ${COMPRESSED_TARGET_SRC}
fi
done
build-targets-matrix:
needs:
[setup-src-cache, cache-src, create-targets-matrix, save-target-sources]
if: |
always() &&
needs.setup-src-cache.result == 'success' &&
needs.create-targets-matrix.result == 'success' &&
(needs.cache-src.result == 'success' || needs.cache-src.result == 'skipped') &&
(needs.save-target-sources.result == 'success' || needs.save-target-sources.result == 'skipped')
strategy:
fail-fast: false
matrix:
build-type: [Release, Debug]
target-build-data:
# --------------------------------------------------------------------------
- target-os: Linux
runs-on: ubuntu-latest
shell: bash
init-script:
setup-script: |
sudo apt install ninja-build zstd -y
echo "CMAKE_GENERATOR=Ninja" >> $GITHUB_ENV
cmake-init-script: |
cmake -B $BUILD_TYPE -DCMAKE_BUILD_TYPE=$BUILD_TYPE
# --------------------------------------------------------------------------
- target-os: Android
runs-on: ubuntu-latest
shell: bash
env:
CC: clang
init-script:
setup-script: |
git config --global core.autocrlf false
git config --global core.eol lf
echo "ANDROID_NDK=$ANDROID_NDK_HOME" >> $GITHUB_ENV
echo "ANDROID_NDK_HOME=$ANDROID_NDK_HOME" >> $GITHUB_ENV
sudo apt install zstd ninja-build -y
echo "CMAKE_GENERATOR=Ninja" >> $GITHUB_ENV
arch: |
arm64-v8a
x86_64
x86
armeabi-v7a
cmake-init-script: |
cmake -B $BUILD_TYPE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DANDROID_ABI="arm64-v8a" -DCMAKE_ANDROID_NDK=$ANDROID_NDK -DANDROID_TOOLCHAIN=clang
# --------------------------------------------------------------------------
- target-os: OSX
runs-on: macos-latest
shell: bash
init-script:
setup-script: |
find /Applications/Xcode* -maxdepth 0 -ls
sudo xcode-select --switch "$(find /Applications -mindepth 1 -maxdepth 1 ! -type l | grep "Xcode_[\.0-9]*app" | sort -V | tail -1)/Contents/Developer"
sudo rm -Rf /Library/Developer/CommandLineTools/SDKs/*
brew install zstd ninja
echo "CMAKE_GENERATOR=Ninja" >> $GITHUB_ENV
cargo install cbindgen
cmake-init-script: |
cmake -B $BUILD_TYPE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DPLATFORM=MAC
# --------------------------------------------------------------------------
- target-os: iOS
runs-on: macos-latest
shell: bash
init-script:
uses: actions/setup-python@v2
with:
python-version: "3.5"
setup-script: |
find /Applications/Xcode* -maxdepth 0 -ls
sudo xcode-select --switch "$(find /Applications -mindepth 1 -maxdepth 1 ! -type l | grep "Xcode_*[\.0-9]*app" | sort -V | tail -1)/Contents/Developer"
sudo rm -Rf /Library/Developer/CommandLineTools/SDKs/*
brew install zstd ninja
echo "CMAKE_GENERATOR=Ninja" >> $GITHUB_ENV
cargo install cbindgen
cmake-init-script: |
cmake -B $BUILD_TYPE -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DiOS_ABI=arm64-v8a -DENABLE_ARC=0 -DENABLE_BITCODE=0 -DENABLE_VISIBILITY=1 -DPLATFORM=OS64
# --------------------------------------------------------------------------
- target-os: Windows
runs-on: windows-2022
shell: bash
init-script:
uses: ilammy/msvc-dev-cmd@v1
with:
arch: amd64
sdk: 10.0.22621.0
vsversion: 17
setup-script: |
echo "Adding GNU tar to PATH"
echo C:\Program Files\Git\usr\bin>>"%GITHUB_PATH%"
cmake-init-script: |
cmake -B $BUILD_TYPE -DCMAKE_BUILD_TYPE=$BUILD_TYPE
target-save-data:
- target-os: $TARGET_OS
runs-on: $TARGET_RUNS_ON
shell: bash
upload-release-json: |
GITHUB_RELEASE_NAME=${TARGET_OS}-${BRANCH}-${BUILD_TYPE}
retValue=1
numberOfTries=1
until [[ $retValue -eq 0 ]]
do
if [[ $numberOfTries -gt 5 ]]; then
break
fi
echo "#${numberOfTries} Uploading release.json to github release ${GITHUB_RELEASE_NAME}"
gh release upload --clobber ${GITHUB_RELEASE_NAME} release.json
retValue=$?
if [[ $retValue -ne 0 ]]; then
echo "gh release upload failed, sleep 2 sec before next try"
sleep 2
fi
((numberOfTries++))
done
if [[ $retValue -ne 0 ]]; then
echo "Failed to upload release.json to github release ${GITHUB_RELEASE_NAME}"
exit 1
fi
release-target: |
# Check if release already defined e.g. Linux-master-release
GITHUB_RELEASE_NAME=${TARGET_OS}-${BRANCH}-${BUILD_TYPE}
gh release view ${GITHUB_RELEASE_NAME}
if [ $? -ne 0 ]
then
echo "Creating github release with tag: ${GITHUB_RELEASE_NAME}"
RELEASE_TYPE="--latest"
if [[ "${BUILD_TYPE}" != "Release" ]];
then
RELEASE_TYPE="--prerelease"
fi
# Create release on github
gh release create ${GITHUB_RELEASE_NAME} -n "${BRANCH} branch" --target ${BRANCH} ${RELEASE_TYPE} -t "${TARGET_OS} ${BRANCH} branch ${BUILD_TYPE} build"
if [ $? -ne 0 ]
then
echo "Failed to create github release with tag: ${GITHUB_RELEASE_NAME}"
exit 1
fi
fi
COMPRESSED_TARGET="${TARGET_NAME}-lib.tar.gz"
echo "Compressing ${TARGET_OS} version ${TARGET_SHA} of ${TARGET_NAME} ${BUILD_TYPE} mode (target build folder: ${TARGET_DIRECTORY})"
tar --exclude="src/" --exclude="tmp/" -zcf ${COMPRESSED_TARGET} ${TARGET_DIRECTORY}
retValue=1
numberOfTries=1
until [[ $retValue -eq 0 ]]
do
if [[ $numberOfTries -gt 5 ]]; then
break
fi
echo "#${numberOfTries} Uploading target ${COMPRESSED_TARGET} to github release ${GITHUB_RELEASE_NAME}"
gh release upload --clobber ${GITHUB_RELEASE_NAME} ${COMPRESSED_TARGET}
retValue=$?
if [[ $retValue -ne 0 ]]; then
echo "gh release upload failed, sleep 2 sec before next try"
sleep 2
fi
((numberOfTries++))
done
if [[ $retValue -ne 0 ]]; then
echo "Failed to upload target ${COMPRESSED_TARGET} to github release ${GITHUB_RELEASE_NAME}"
exit 1
fi
runs-on: ${{ matrix.target-build-data.runs-on }}
outputs:
TARGET_BUILT: ${{ steps.cache-library-directory.outputs.TARGET_BUILT }}
steps:
- name: Create library Keys and Paths to Cache/build
id: create-lib-cache-keys
shell: bash
run: |
# build array of library names
IFS=$'\n' read -d '|' -ra TARGET_REPO_NAMES <<< "$(echo -ne '${{ needs.create-targets-matrix.outputs.TARGET_REPO_NAMES }}|')"
IFS=$'\n' read -d '|' -ra TARGET_SHAS <<< "$(echo -ne '${{ needs.create-targets-matrix.outputs.TARGET_SHAS }}|')"
IFS=$'\n' read -d '|' -ra TARGET_DIRECTORIES <<< "$(echo -ne '${{ needs.create-targets-matrix.outputs.TARGET_DIRECTORIES }}|')"
LIB_CACHE_NAME_KEYS="[ "
LIB_CACHE_PATHS="[ "
first=true
for i in "${!TARGET_REPO_NAMES[@]}"; do
if [[ "$first" != "true" ]]; then
LIB_CACHE_NAME_KEYS+=", "
LIB_CACHE_PATHS+=", "
fi
first=false
LIB_CACHE_NAME_KEYS+="\"l/${{ matrix.target-os }}/${{ matrix.build-type }}/${TARGET_REPO_NAMES[i]}-${TARGET_SHAS[i]}\""
LIB_CACHE_PATHS+="[\"./build/${{ matrix.target-os }}/${{ matrix.build-type }}/${TARGET_DIRECTORIES[i]}/**\"]"
done
LIB_CACHE_NAME_KEYS+=" ]"
echo "LIB_CACHE_NAME_KEYS=$LIB_CACHE_NAME_KEYS" >> $GITHUB_OUTPUT
LIB_CACHE_PATHS+=" ]"
echo "LIB_CACHE_PATHS=$LIB_CACHE_PATHS" >> $GITHUB_OUTPUT
- name: Remove old libraries that are cached.
run: |
echo "We really should remove old library caches here"
- name: Install configuration
uses: ChristopherHX/conditional@main
with:
if: ${{ matrix.target-build-data.install-uses != null }}
step: |
uses: ${{ matrix.target-build-data.install-uses.uses || '' }}
with: ${{ (matrix.target-build-data.install-uses.with && toJSON(matrix.target-build-data.install-uses.with)) || '{}' }}
- name: Cache Third Party Directory
uses: GeniusVentures/cache-multi/[email protected]
id: cache-tp-source-directory
with:
key: ${{ needs.setup-src-cache.outputs.THIRD_PARTY_CACHE_NAME_KEY }}
enableCrossOsArchive: true
path: |
!.git/**
./**
- if: (steps.cache-tp-source-directory.outputs.cache-hit != 'true')
run: |
echo "Couldn't find cached thirdparty code, ${{ needs.setup-src-cache.outputs.THIRD_PARTY_CACHE_NAME_KEY }} fatal error!"
exit 1
- name: Cache Submodule source files without .git
id: cache-source-directory
uses: GeniusVentures/cache-multi/[email protected]
with:
multi-keys: ${{ needs.setup-src-cache.outputs.CACHE_MULTI_PARAMETER_NAME_KEYS }}
enableCrossOsArchive: true
paths: ${{ needs.setup-src-cache.outputs.CACHE_MULTI_PARAMETER_PATHS }}
- name: Run setup script for target OS
shell: bash
run: |
echo "Running init script"
${{ matrix.target-build-data.init-script }}
echo "Running setup script"
${{ matrix.target-build-data.setup-script }}
- name: Configure CMake
shell: bash
run: |
TARGET_OS="${{ matrix.target-build-data.target-os }}"
BUILD_TYPE="${{ matrix.build-type }}"
WORKSPACE=${{ github.workspace }}
cd build/$TARGET_OS
${{ matrix.target-build-data.cmake-init-script }}
- name: Load built library caches if any
id: cache-library-directory
shell: bash
run: |
TARGET_OS="${{ matrix.target-build-data.target-os }}"
BUILD_TYPE="${{ matrix.build-type }}"
BRANCH=${{ github.ref_name }}
IFS=$'\n' read -d '|' -ra TARGET_NAMES <<< "$(echo -ne '${{ needs.create-targets-matrix.outputs.TARGET_NAMES }}|')"
IFS=$'\n' read -d '|' -ra TARGET_SHAS <<< "$(echo -ne '${{ needs.create-targets-matrix.outputs.TARGET_SHAS }}|')"
set +e
GITHUB_RELEASE_NAME=${TARGET_OS}-${BRANCH}-${BUILD_TYPE}
# check if release.json file already available
jsonStr="[]"
jsonFound=`gh release view ${GITHUB_RELEASE_NAME} --json assets --jq "any(.assets[]; .name == \"release.json\")"`
if [ $? -eq 0 ]
then
echo "Downloading release.json file"
gh release download ${GITHUB_RELEASE_NAME} --pattern "release.json" --clobber
if [ $? -eq 0 ]
then
echo "Loading release.json file"
jsonStr=`cat release.json`
fi
fi
set -e
targetBuiltList=""
for i in "${!TARGET_NAMES[@]}"; do
TARGET_NAME="${TARGET_NAMES[i]}"
TARGET_SHA="${TARGET_SHAS[i]}"
COMPRESSED_TARGET="${TARGET_NAME}-lib.tar.gz"
targetBuilt=false
shaFound=`jq ".[] | select(.name == \"${TARGET_NAME}\") | .sha" <<< ${jsonStr}`
if [[ "${shaFound}" == \"${TARGET_SHA}\" ]];
then
targetBuilt=true
fi
echo "Check if ${COMPRESSED_TARGET} found on ${GITHUB_RELEASE_NAME}: ${targetBuilt}"
targetBuiltList+="${targetBuilt}\n"
done
echo "TARGET_BUILT=$targetBuiltList" >> $GITHUB_OUTPUT
- name: Build any updated libraries
id: build-updated-libraries
shell: bash
run: |
TARGET_OS="${{ matrix.target-build-data.target-os }}"
TARGET_RUNS_ON="${{ matrix.target-build-data.runs-on }}"
BUILD_TYPE="${{ matrix.build-type }}"
BRANCH=${{ github.ref_name }}
WORKSPACE=${{ github.workspace }}
GITHUB_RELEASE_NAME=${TARGET_OS}-${BRANCH}-${BUILD_TYPE}
IFS=$'\n' read -d '|' -ra TARGET_NAMES <<< "$(echo -ne '${{ needs.create-targets-matrix.outputs.TARGET_NAMES }}|')"
IFS=$'\n' read -d '|' -ra TARGET_SHAS <<< "$(echo -ne '${{ needs.create-targets-matrix.outputs.TARGET_SHAS }}|')"
IFS=$'\n' read -d '|' -ra TARGET_BUILT <<< "$(echo -ne '${{ steps.cache-library-directory.outputs.TARGET_BUILT }}|')"
IFS=$'\n' read -d '|' -ra TARGET_DIRECTORIES <<< "$(echo -ne '${{ needs.create-targets-matrix.outputs.TARGET_DIRECTORIES }}|')"
cd "build/${TARGET_OS}/${BUILD_TYPE}"
jsonStr=""
declare -a listOfTargetNamesToBuild
declare -a listOfTargetSHAsToBuild
declare -a listOfTargetDirToBuild
for i in "${!TARGET_NAMES[@]}"; do
TARGET_NAME="${TARGET_NAMES[i]}"
TARGET_SHA="${TARGET_SHAS[i]}"
TARGET_DIRECTORY="${TARGET_DIRECTORIES[i]}"
COMPRESSED_TARGET="${TARGET_NAME}-lib.tar.gz"
echo "${TARGET_NAME} release found: ${TARGET_BUILT[i]} (Target direcory: $TARGET_DIRECTORY)"
if [ "${TARGET_BUILT[i]}" == "true" ]; then
echo "Downloading cached target: $TARGET_NAME, sha: $TARGET_SHA"
gh release download ${GITHUB_RELEASE_NAME} --pattern "${COMPRESSED_TARGET}" --clobber
if [ $? -eq 0 ]
then
echo "Extracting cached target: ${COMPRESSED_TARGET}"
tar -xf ${COMPRESSED_TARGET}
FOLDER_HASH=`find ./${TARGET_DIRECTORY} -xdev -type f -print0 | LC_COLLATE=C sort -z | xargs -0 cat | md5sum | awk '{print $1}'`
echo "Cached target folder hash: ${FOLDER_HASH}"
jsonStrHash=$(jq -n \
--arg name "$TARGET_NAME" \
--arg sha "$TARGET_SHA" \
--arg binFolderName "$TARGET_DIRECTORY" \
--arg binFolderHash "$FOLDER_HASH" \
'{name: $name, sha: $sha, binFolderName: $binFolderName, binFolderHash: $binFolderHash}')
jsonStr=$(jq -c --argjson obj "$jsonStrHash" '. + [$obj]' <<< "$jsonStr")
echo "Target extracted to `pwd`/${TARGET_DIRECTORY}"
echo "Contents of target folder `pwd`/${TARGET_DIRECTORY}"
ls -la ./${TARGET_DIRECTORY}
else
echo "Failed to download cached target: ${COMPRESSED_TARGET} - need to rebuild it"
listOfTargetNamesToBuild+=("${TARGET_NAME}")
listOfTargetSHAsToBuild+=("${TARGET_SHA}")
listOfTargetDirToBuild+=("${TARGET_DIRECTORY}")
fi
else
echo "Cached target not found: ${COMPRESSED_TARGET} - need to rebuild it"
listOfTargetNamesToBuild+=("${TARGET_NAME}")
listOfTargetSHAsToBuild+=("${TARGET_SHA}")
listOfTargetDirToBuild+=("${TARGET_DIRECTORY}")
fi
done
# Print hash JSON file
jq <<< $jsonStr
# save hash JSON file
jq <<< $jsonStr > hash.json
# check if release.json file already available
releaseJsonStr="[]"
set +e
jsonFound=`gh release view ${GITHUB_RELEASE_NAME} --json assets --jq "any(.assets[]; .name == \"release.json\")"`
if [ $? -eq 0 ]
then
echo "Downloading release.json file"
gh release download ${GITHUB_RELEASE_NAME} --pattern "release.json" --clobber
if [ $? -eq 0 ]
then
echo "Loading release.json file"
releaseJsonStr=`cat release.json`
fi
fi
set -e
for i in "${!listOfTargetNamesToBuild[@]}"; do
TARGET_NAME="${listOfTargetNamesToBuild[i]}"
TARGET_SHA="${listOfTargetSHAsToBuild[i]}"
TARGET_DIRECTORY="${listOfTargetDirToBuild[i]}"
COMPRESSED_TARGET="${TARGET_NAME}-lib.tar.gz"
COMPRESSED_TARGET_SRC="${TARGET_NAME}-src.tar.gz"
echo "Compiling $TARGET_OS version $TARGET_SHA of $TARGET_NAME $BUILD_TYPE mode"
cmake --build . --target $TARGET_NAME --config $BUILD_TYPE -j
echo "Starting to upload target: ${COMPRESSED_TARGET}"
# Upload released target
${{ matrix.target-save-data.release-target }}
RELEASE_ASSETS=`gh release view ${GITHUB_RELEASE_NAME} --json assets`
# Updating release.json
# Get source url
TARGET_SOURCE=`jq ".assets[] | select(.name == \"${COMPRESSED_TARGET_SRC}\") | .url" <<< ${RELEASE_ASSETS}`
# Get target url
TARGET_BINARY=`jq ".assets[] | select(.name == \"${COMPRESSED_TARGET}\") | .url" <<< ${RELEASE_ASSETS}`
releaseFound=$(jq ".[] | select(.name == \"${TARGET_NAME}\")" <<<${releaseJsonStr})
if [ ${#releaseFound} -gt 0 ]
then
echo "Updating release.json file with target ${TARGET_NAME}"
releaseJsonStr=`jq "(. | select(.name == \"${TARGET_NAME}\")).sha |= \"${TARGET_SHA}\" " <<< ${releaseJsonStr}`
releaseJsonStr=`jq "(. | select(.name == \"${TARGET_NAME}\")).binFolderName |= \"${TARGET_DIRECTORY}\" " <<< ${releaseJsonStr}`
releaseJsonStr=`jq "(. | select(.name == \"${TARGET_NAME}\")).source |= \"${TARGET_SOURCE}\" " <<< ${releaseJsonStr}`
releaseJsonStr=`jq "(. | select(.name == \"${TARGET_NAME}\")).binary |= \"${TARGET_BINARY}\" " <<< ${releaseJsonStr}`
else
echo "Adding target ${TARGET_NAME} to release.json file"
jsonStrTarget=$(jq -n \
--arg name "${TARGET_NAME}" \
--arg sha "${TARGET_SHA}" \
--arg binFolderName "${TARGET_DIRECTORY}" \
--arg source "${TARGET_SOURCE}" \
--arg binary "${TARGET_BINARY}" \
'{name: $name, sha: $sha, binFolderName: $binFolderName, source: $source, binary: $binary}')
releaseJsonStr=$(jq -c --argjson obj "$jsonStrTarget" '. + [$obj]' <<<"$releaseJsonStr")
fi
# Upload JSON file release
jq <<< $releaseJsonStr > release.json
${{ matrix.target-save-data.upload-release-json }}
done
- name: Upload JSON file release on build failure
if: ${{ failure() && steps.build-updated-libraries.conclusion == 'failure' }}
shell: bash
run: |
TARGET_OS="${{ matrix.target-build-data.target-os }}"
BUILD_TYPE="${{ matrix.build-type }}"
BRANCH=${{ github.ref_name }}
GITHUB_RELEASE_NAME=${TARGET_OS}-${BRANCH}-${BUILD_TYPE}
retValue=1
numberOfTries=1
until [[ $retValue -eq 0 ]]
do
if [[ $numberOfTries -gt 5 ]]; then
break
fi
echo "#${numberOfTries} Uploading release.json to github release ${GITHUB_RELEASE_NAME}"
gh release upload --clobber ${GITHUB_RELEASE_NAME} release.json
retValue=$?
if [[ $retValue -ne 0 ]]; then
echo "gh release upload failed, sleep 2 sec before next try"
sleep 2
fi
((numberOfTries++))
done
- name: Save target OS SDK as github release
shell: bash
run: |
TARGET_OS="${{ matrix.target-build-data.target-os }}"
TARGET_RUNS_ON="${{ matrix.target-build-data.runs-on }}"
BUILD_TYPE="${{ matrix.build-type }}"
BRANCH=${{ github.ref_name }}
IFS=$'\n' read -d '|' -ra TARGET_NAMES <<< "$(echo -ne '${{ needs.create-targets-matrix.outputs.TARGET_NAMES }}|')"
IFS=$'\n' read -d '|' -ra TARGET_SHAS <<< "$(echo -ne '${{ needs.create-targets-matrix.outputs.TARGET_SHAS }}|')"
IFS=$'\n' read -d '|' -ra TARGET_BUILT <<< "$(echo -ne '${{ steps.cache-library-directory.outputs.TARGET_BUILT }}|')"
IFS=$'\n' read -d '|' -ra TARGET_DIRECTORIES <<< "$(echo -ne '${{ needs.create-targets-matrix.outputs.TARGET_DIRECTORIES }}|')"
GITHUB_RELEASE_NAME=${TARGET_OS}-${BRANCH}-${BUILD_TYPE}
RELEASE_ASSETS=`gh release view ${GITHUB_RELEASE_NAME} --json assets`
jsonStr=""
cd "build/${TARGET_OS}/${BUILD_TYPE}"
for i in "${!TARGET_NAMES[@]}"; do
TARGET_NAME="${TARGET_NAMES[i]}"
TARGET_SHA="${TARGET_SHAS[i]}"
TARGET_DIRECTORY="${TARGET_DIRECTORIES[i]}"
COMPRESSED_TARGET="${TARGET_NAME}-lib.tar.gz"
COMPRESSED_TARGET_SRC="${TARGET_NAME}-src.tar.gz"
echo "${TARGET_NAME} release found: ${TARGET_BUILT[i]}"
if [ "${TARGET_BUILT[i]}" == "true" ]; then
# Compare uncompressed original hash of the binary folder with current to see if any changes has been made
originalHash=`jq "select(.name == \"${TARGET_NAME}\") | .binFolderHash" hash.json`
currentHash=`find ./${TARGET_DIRECTORY} -xdev -type f -print0 | LC_COLLATE=C sort -z | xargs -0 cat | md5sum | awk '{print $1}'`
if [[ "${originalHash}" != \"${currentHash}\" ]];
then
echo "originalHash: ${originalHash}"
echo "currentHash: \"${currentHash}\""
echo "Has does not match, uploading already installed modified target: ${TARGET_NAME}, sha: ${TARGET_SHA}"
${{ matrix.target-save-data.release-target }}
else
echo "Target ${TARGET_NAME} binary folder did not change, no need to update release"
fi
fi
# Update JSON file
# Get source url
TARGET_SOURCE=`jq ".assets[] | select(.name == \"${COMPRESSED_TARGET_SRC}\") | .url" <<< ${RELEASE_ASSETS}`
# Get target url
TARGET_BINARY=`jq ".assets[] | select(.name == \"${COMPRESSED_TARGET}\") | .url" <<< ${RELEASE_ASSETS}`
jsonStrTarget=`jq ". + { \"name\": \"${TARGET_NAME}\", \"sha\" : \"${TARGET_SHA}\", \"binFolderName\" : \"${TARGET_DIRECTORY}\", \"source\" : ${TARGET_SOURCE}, \"binary\" : ${TARGET_BINARY} }" <<< "{}"`
jsonStr=$(jq -c --argjson obj "$jsonStrTarget" '. + [$obj]' <<<"$jsonStr")
done