@@ -16,6 +16,9 @@ name: Build
16
16
on :
17
17
workflow_call :
18
18
inputs :
19
+ version :
20
+ description : Use actions of this version as workaround for https://github.com/actions/runner/issues/2417 (optional, defaults to latest release).
21
+ type : string
19
22
source-dir :
20
23
description : The CMake source directory (optional, defaults to working directory).
21
24
type : string
44
47
permissions : {}
45
48
46
49
concurrency :
47
- group : run -build-${{github.workflow}}-${{github.event_name}}-${{github.ref}}
50
+ group : cmu -build-${{github.workflow}}-${{github.event_name}}-${{github.ref}}
48
51
cancel-in-progress : true
49
52
50
53
jobs :
@@ -61,18 +64,37 @@ jobs:
61
64
62
65
steps :
63
66
# Actions: Load
67
+ - name : ' Actions: Get SHA'
68
+ # Workaround for https://github.com/actions/runner/issues/2417
69
+ id : actions-latest
70
+ shell : bash
71
+ env :
72
+ VERSION : ${{inputs.version}}
73
+ GITHUB_TOKEN : ${{github.token}}
74
+ run : |
75
+ if [[ -z $VERSION ]]; then
76
+ VERSION=$(curl --no-progress-meter \
77
+ -H "Accept: application/vnd.github+json" -H "Authorization: Bearer $GITHUB_TOKEN" \
78
+ "$GITHUB_API_URL/repos/mbeckh/cmake-utils/releases/latest" \
79
+ | jq -r '.tag_name')
80
+ echo "Using latest release: $VERSION"
81
+ fi
82
+ (echo -n "sha=" && curl --no-progress-meter \
83
+ -H "Accept: application/vnd.github.sha" -H "Authorization: Bearer $GITHUB_TOKEN" \
84
+ "$GITHUB_API_URL/repos/mbeckh/cmake-utils/commits/$VERSION) >> $GITHUB_OUTPUT
85
+
64
86
- name : ' Actions: Restore'
65
87
id : actions-restore
66
88
uses : actions/cache/restore@v3
67
89
with :
68
90
path : cmake-utils
69
- key : cmu-cmake-utils-${{github.job_workflow_sha}}
91
+ key : cmu-cmake-utils-${{steps.actions-latest.outputs.sha}} # should be: cmu-cmake-utils-${{ github.job_workflow_sha}}
70
92
71
93
- name : ' Actions: Load'
72
94
if : steps.actions-restore.outputs.cache-hit != 'true'
73
95
shell : bash
74
96
env :
75
- JOB_WORKFLOW_SHA : ${{github.job_workflow_sha}}
97
+ JOB_WORKFLOW_SHA : ${{steps.actions-latest.outputs.sha}} # should be: ${{ github.job_workflow_sha}}
76
98
GITHUB_TOKEN : ${{github.token}}
77
99
run : |
78
100
curl -L --no-progress-meter -o "cmake-utils-$JOB_WORKFLOW_SHA.tar.gz" \
@@ -119,7 +141,7 @@ jobs:
119
141
shell : bash
120
142
working-directory : source${{inputs.source-dir != '.' && inputs.source-dir && '/' || ''}}${{inputs.source-dir != '.' && inputs.source-dir || ''}}
121
143
run : |
122
- (( echo "image-os=$ImageOS") & ( echo "image-version=$ImageVersion") ) >> $GITHUB_OUTPUT
144
+ (echo "image-os=$ImageOS" && echo "image-version=$ImageVersion") >> $GITHUB_OUTPUT
123
145
if [[ -f vcpkg.json ]]; then
124
146
registries=$(jq --sort-keys $([[ -f vcpkg-configuration.json ]] && echo '--slurp') '.' \
125
147
vcpkg.json $([[ -f vcpkg-configuration.json ]] && echo 'vcpkg-configuration.json') \
@@ -131,10 +153,8 @@ jobs:
131
153
| { repository, reference, baseline }
132
154
| del(.. | nulls)
133
155
] | sort')
134
- [[ $RUNNER_DEBUG -eq 1 ]] && echo "$registries" || true
135
- if [[ $registries != '[]' ]]; then
136
- (echo -n 'registries-hash=' && (sha1sum - | cut -d ' ' -f 1)) >> $GITHUB_OUTPUT
137
- fi
156
+ [[ $RUNNER_DEBUG != 1 ]] || echo "$registries"
157
+ [[ $registries == '[]' ]] || (echo -n 'registries-hash=' && (sha1sum - | cut -d ' ' -f 1)) >> $GITHUB_OUTPUT
138
158
fi
139
159
140
160
- name : ' Tools: Restore'
@@ -327,18 +347,37 @@ jobs:
327
347
328
348
steps :
329
349
# Actions: Load
350
+ - name : ' Actions: Get SHA'
351
+ # Workaround for https://github.com/actions/runner/issues/2417
352
+ id : actions-latest
353
+ shell : bash
354
+ env :
355
+ VERSION : ${{inputs.version}}
356
+ GITHUB_TOKEN : ${{github.token}}
357
+ run : |
358
+ if [[ -z $VERSION ]]; then
359
+ VERSION=$(curl --no-progress-meter \
360
+ -H "Accept: application/vnd.github+json" -H "Authorization: Bearer $GITHUB_TOKEN" \
361
+ "$GITHUB_API_URL/repos/mbeckh/cmake-utils/releases/latest" \
362
+ | jq -r '.tag_name')
363
+ echo "Using latest release: $VERSION"
364
+ fi
365
+ (echo -n "sha=" && curl --no-progress-meter \
366
+ -H "Accept: application/vnd.github.sha" -H "Authorization: Bearer $GITHUB_TOKEN" \
367
+ "$GITHUB_API_URL/repos/mbeckh/cmake-utils/commits/$VERSION) >> $GITHUB_OUTPUT
368
+
330
369
- name : ' Actions: Restore'
331
370
id : actions-restore
332
371
uses : actions/cache/restore@v3
333
372
with :
334
373
path : cmake-utils
335
- key : cmu-cmake-utils-${{github.job_workflow_sha}}
374
+ key : cmu-cmake-utils-${{steps.actions-latest.outputs.sha}} # should be: cmu-cmake-utils-${{ github.job_workflow_sha}}
336
375
337
376
- name : ' Actions: Load'
338
377
if : steps.actions-restore.outputs.cache-hit != 'true'
339
378
shell : bash
340
379
env :
341
- JOB_WORKFLOW_SHA : ${{github.job_workflow_sha}}
380
+ JOB_WORKFLOW_SHA : ${{steps.actions-latest.outputs.sha}} # should be: ${{ github.job_workflow_sha}}
342
381
GITHUB_TOKEN : ${{github.token}}
343
382
run : |
344
383
curl -L --no-progress-meter -o "cmake-utils-$JOB_WORKFLOW_SHA.tar.gz" \
@@ -385,7 +424,7 @@ jobs:
385
424
shell : bash
386
425
working-directory : source${{inputs.source-dir != '.' && inputs.source-dir && '/' || ''}}${{inputs.source-dir != '.' && inputs.source-dir || ''}}
387
426
run : |
388
- (( echo "image-os=$ImageOS") & ( echo "image-version=$ImageVersion") ) >> $GITHUB_OUTPUT
427
+ (echo "image-os=$ImageOS" && echo "image-version=$ImageVersion") >> $GITHUB_OUTPUT
389
428
if [[ -f vcpkg.json ]]; then
390
429
registries=$(jq --sort-keys $([[ -f vcpkg-configuration.json ]] && echo '--slurp') '.' \
391
430
vcpkg.json $([[ -f vcpkg-configuration.json ]] && echo 'vcpkg-configuration.json') \
@@ -397,10 +436,8 @@ jobs:
397
436
| { repository, reference, baseline }
398
437
| del(.. | nulls)
399
438
] | sort')
400
- [[ $RUNNER_DEBUG -eq 1 ]] && echo "$registries" || true
401
- if [[ $registries != '[]' ]]; then
402
- (echo -n 'registries-hash=' && (sha1sum - | cut -d ' ' -f 1)) >> $GITHUB_OUTPUT
403
- fi
439
+ [[ $RUNNER_DEBUG != 1 ]] || echo "$registries"
440
+ [[ $registries == '[]' ]] || (echo -n 'registries-hash=' && (sha1sum - | cut -d ' ' -f 1)) >> $GITHUB_OUTPUT
404
441
fi
405
442
406
443
- name : ' Tools: Restore'
@@ -594,11 +631,7 @@ jobs:
594
631
"$next" >> "$2"
595
632
next=$(egrep -i '^link: ' "$2.headers" | grep -P -i -o '(?<=<)([\S]*)(?=>; rel="next")') || [[ $? == 1 ]]
596
633
done
597
- if [[ $RUNNER_DEBUG -eq 1 ]]; then
598
- echo "::group::$1"
599
- cat "$2"
600
- echo "::endgroup::"
601
- fi
634
+ [[ $RUNNER_DEBUG != 1 ]] || echo "::group::$1" && cat "$2" echo "::endgroup::"
602
635
}
603
636
604
637
stamp=$(jq -n -r 'now')
@@ -610,11 +643,7 @@ jobs:
610
643
load_paged "$GITHUB_API_URL/repos/$GITHUB_REPOSITORY/pulls?state=open" pulls.json
611
644
jq -r '.[] | .number | "refs/pull/" + (. | tostring) + "/merge" | @json' pulls.json >> branch-names.json
612
645
613
- if [[ $RUNNER_DEBUG -eq 1 ]]; then
614
- echo "::group::Active Branches"
615
- cat branch-names.json
616
- echo "::endgroup::"
617
- fi
646
+ [[ $RUNNER_DEBUG != 1 ]] || echo "::group::Active Branches" && cat branch-names.json && echo "::endgroup::"
618
647
619
648
jq -r --slurpfile branches branch-names.json --argjson stamp "$stamp" '
620
649
.actions_caches
@@ -632,7 +661,7 @@ jobs:
632
661
' caches.json \
633
662
| while IFS=$'\t' read sequence cache_id cache_key cache_ref cache_created cache_last_accessed; do
634
663
if [[ -n $sequence ]]; then
635
- if [[ $sequence -eq 0 ]]; then
664
+ if [[ $sequence == 0 ]]; then
636
665
echo "## Clean Caches: Deleted Branches" >> $GITHUB_STEP_SUMMARY
637
666
echo "| Branch | Key | Created | Last Accessed |" >> $GITHUB_STEP_SUMMARY
638
667
echo "| --- | --- | --- | --- |" >> $GITHUB_STEP_SUMMARY
@@ -676,7 +705,7 @@ jobs:
676
705
next=$(egrep -i '^link: ' caches.json.headers | grep -P -i -o '(?<=<)([\S]*)(?=>; rel="next")') || [[ $? == 1 ]]
677
706
done
678
707
679
- if [[ 1 == 1 || $RUNNER_DEBUG -eq 1 ]]; then
708
+ if [[ $RUNNER_DEBUG == 1 ]]; then
680
709
echo "::debug::stamp=$(jq -n -r --argjson stamp "$stamp" '$stamp | gmtime | strftime("%Y-%m-%d %H:%M:%S")')"
681
710
echo "::group::$GITHUB_API_URL/repos/$GITHUB_REPOSITORY/actions/caches?ref=$ref"
682
711
cat caches.json
@@ -712,7 +741,7 @@ jobs:
712
741
' caches.json \
713
742
| while IFS=$'\t' read sequence cache_id cache_key cache_ref cache_created cache_last_accessed; do
714
743
if [[ -n $sequence ]]; then
715
- if [[ $sequence -eq 0 ]]; then
744
+ if [[ $sequence == 0 ]]; then
716
745
echo "## Clean Caches: Stale Caches" >> $GITHUB_STEP_SUMMARY
717
746
echo "| Branch | Key | Created | Last Accessed |" >> $GITHUB_STEP_SUMMARY
718
747
echo "| --- | --- | --- | --- |" >> $GITHUB_STEP_SUMMARY
0 commit comments