Skip to content

Commit 1ba9fbd

Browse files
committed
ccpp: update etags handling
Print the output variable assigned in the script in case that this fails, otherwise it on the output without NL and will be prepended to next var (if any). This also simplifies the call in YAML.
1 parent be33cbe commit 1ba9fbd

File tree

3 files changed

+24
-19
lines changed

3 files changed

+24
-19
lines changed

.github/scripts/get-etag.sh

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,19 @@
22
# Prints to stdout ETag for given URL.
33
# If failed to obtain and $2=optional the particular tag is replaced with a keyword NOTFOUND
44

5-
ETAG=$(curl -LI "$1" | grep -i '^etag' | sed 's/.*"\(.*\)".*/\1/')
5+
output=$1
6+
url=$2
7+
optional=${3-}
8+
9+
ETAG=$(curl -LI "$url" | grep -i '^etag' | sed 's/.*"\(.*\)".*/\1/')
610
if [ "$ETAG" ]; then
11+
printf '%s=' "$output"
712
printf '%s\n' "$ETAG" | sed 's/[^-._A-Za-z0-9]/_/g'
813
exit 0
914
fi
1015

11-
if [ "${2-}" = optional ]; then
12-
echo NOTFOUND
16+
if [ "$optional" = optional ]; then
17+
echo "$1=NOTFOUND"
1318
exit 0
1419
fi
1520

.github/workflows/ccpp.yml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ jobs:
6262
- name: Fetch SDKs ETags
6363
id: etags
6464
run: |
65-
{ printf ndi=; $GITHUB_WORKSPACE/.github/scripts/get-etag.sh\
65+
$GITHUB_WORKSPACE/.github/scripts/get-etag.sh ndi\
6666
https://downloads.ndi.tv/SDK/NDI_SDK_Linux/\
67-
Install_NDI_SDK_v6_Linux.tar.gz; } >> $GITHUB_OUTPUT
67+
Install_NDI_SDK_v6_Linux.tar.gz >> $GITHUB_OUTPUT
6868
- name: Run actions/cache for NDI
6969
id: cache-ndi
7070
uses: actions/cache@main
@@ -153,13 +153,13 @@ jobs:
153153
- name: Fetch SDKs ETags
154154
id: etags
155155
run: |
156-
{ printf nonfree=; $GITHUB_WORKSPACE/.github/scripts/get-etag.sh\
157-
"$SDK_URL/$DELTA_MAC_ARCHIVE" optional; } >> $GITHUB_OUTPUT
158-
{ printf ndi=; $GITHUB_WORKSPACE/.github/scripts/get-etag.sh\
159-
https://downloads.ndi.tv/SDK/NDI_SDK_Mac/Install_NDI_SDK_v6_Apple.pkg
160-
} >> $GITHUB_OUTPUT
161-
{ printf ximea=; $GITHUB_WORKSPACE/.github/scripts/get-etag.sh\
162-
"$XIMEA_DOWNLOAD_URL"; } >> $GITHUB_OUTPUT
156+
$GITHUB_WORKSPACE/.github/scripts/get-etag.sh nonfree\
157+
"$SDK_URL/$DELTA_MAC_ARCHIVE" optional >> $GITHUB_OUTPUT
158+
$GITHUB_WORKSPACE/.github/scripts/get-etag.sh ndi\
159+
https://downloads.ndi.tv/SDK/NDI_SDK_Mac/Install_NDI_SDK_v6_Apple.pkg\
160+
>> $GITHUB_OUTPUT
161+
$GITHUB_WORKSPACE/.github/scripts/get-etag.sh ximea\
162+
"$XIMEA_DOWNLOAD_URL" >> $GITHUB_OUTPUT
163163
- name: Run actions/cache for Non-Free SDKs
164164
id: cache-macos-nonfree-sdks
165165
uses: actions/cache@main
@@ -249,11 +249,11 @@ jobs:
249249
- name: Fetch SDKs ETags
250250
id: etags
251251
run: |
252-
{ printf ndi=; $GITHUB_WORKSPACE/.github/scripts/get-etag.sh\
253-
https://downloads.ndi.tv/SDK/NDI_SDK/NDI%206%20SDK.exe
254-
} >> $GITHUB_OUTPUT
255-
{ printf ximea=; $GITHUB_WORKSPACE/.github/scripts/get-etag.sh\
256-
"$XIMEA_DOWNLOAD_URL"; } >> $GITHUB_OUTPUT
252+
$GITHUB_WORKSPACE/.github/scripts/get-etag.sh ndi\
253+
https://downloads.ndi.tv/SDK/NDI_SDK/NDI%206%20SDK.exe\
254+
>> $GITHUB_OUTPUT
255+
$GITHUB_WORKSPACE/.github/scripts/get-etag.sh ximea\
256+
"$XIMEA_DOWNLOAD_URL" >> $GITHUB_OUTPUT
257257
- name: Find MSVC
258258
run: .github/scripts/Windows/find_msvc.ps1
259259
shell: pwsh -command ". '{0}'"

.github/workflows/coverity-scan.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ jobs:
4646
if: ${{ env.coverity_token }}
4747
id: etags
4848
run: |
49-
{ printf ndi=; $GITHUB_WORKSPACE/.github/scripts/get-etag.sh\
49+
$GITHUB_WORKSPACE/.github/scripts/get-etag.sh ndi\
5050
https://downloads.ndi.tv/SDK/NDI_SDK_Linux/Install_NDI_SDK_v6_Linux.\
51-
tar.gz; } >> $GITHUB_OUTPUT
51+
tar.gz >> $GITHUB_OUTPUT
5252
- name: Run actions/cache for NDI
5353
if: ${{ env.coverity_token }}
5454
id: cache-ndi

0 commit comments

Comments
 (0)