Skip to content

Commit 09df08d

Browse files
committed
CI: fromJSON not fromJson
1 parent c6b80d4 commit 09df08d

File tree

1 file changed

+63
-29
lines changed

1 file changed

+63
-29
lines changed

.github/workflows/upstream.yaml

Lines changed: 63 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
fail-fast: false
3434
max-parallel: 1
3535
matrix:
36-
release: ${{ fromJson(needs.check.outputs.releases_needed_json) }}
36+
release: ${{ fromJSON(needs.check.outputs.releases_needed_json) }}
3737
runs-on: ubuntu-22.04
3838
outputs:
3939
continue: ${{ steps.download.outputs.continue }}
@@ -54,19 +54,22 @@ jobs:
5454
#
5555
# Get info about the release being processed
5656
echo "Processing $release"
57-
if ! allReleasesJson="$(jq -c . <<< "$(curl -s "${releasesUrl}")")" ; then
57+
if ! allReleasesJson="$( jq -c . <<< "$(curl -s "${releasesUrl}")" )" ; then
5858
echo "‼️ Problem getting releases: ${allReleasesJson}"
5959
fi
60-
if ! releaseJson="$(jq -r ".[] | select(.tag_name==\"${releasePrefix}${release}\")" <<< "$allReleasesJson")" ; then
60+
if ! releaseJson="$( jq -r ".[] | select(.tag_name==\"${releasePrefix}${release}\" )" <<< "$allReleasesJson" )" \
61+
|| [[ "$releaseJson" == "" ]] ; then
6162
echo "‼️ Problem getting release info for ${release}: ${releaseJson}"
6263
fi
63-
if ! gitBranch="$(jq -r ".target_commitish" <<< "$releaseJson")" ; then
64+
if ! gitBranch="$( jq -r ".target_commitish" <<< "$releaseJson" )" \
65+
|| [[ "$gitBranch" == "" ]] ; then
6466
echo "‼️ Problem getting branch: ${gitBranch}"
6567
fi
66-
if ! tagsJson="$(jq -c . <<< "$(curl -s "$tagsUrl")")" ; then
68+
if ! tagsJson="$( jq -c . <<< "$(curl -s "$tagsUrl")" )" ; then
6769
echo "‼️ Problem getting tags: ${tagsJson}"
6870
fi
69-
if ! gitCommit="$(jq -r ".[] | select(.name==\"${release}\") | .commit.sha" <<< "$tagsJson")" ; then
71+
if ! gitCommit="$( jq -r ".[] | select(.name==\"${releasePrefix}${release}\" ) | .commit.sha" <<< "$tagsJson")" \
72+
|| [[ "$gitCommit" == "" ]] ; then
7073
echo "‼️ Problem getting commit: ${gitCommit}"
7174
fi
7275
#
@@ -137,18 +140,33 @@ jobs:
137140
icon: SL.png
138141
manifest: ${{ steps.download.outputs.manifest }}
139142
run: |
140-
if [[ -s "${readme}" ]] ; then
141-
echo "readme=${readme}" >> $GITHUB_OUTPUT
142-
else
143-
echo "README Not found at ${readme}"
144-
fi
145-
if [[ -s "${icon}" ]] ; then
146-
echo "icon=${icon}" >> $GITHUB_OUTPUT
147-
else
148-
echo "Icon Not found at ${icon}"
149-
fi
150-
[[ -f manifest.json ]] && echo "Manifest already exists" || echo $manifest > manifest.json
151-
find .
143+
main() {
144+
if [[ -s "${readme}" ]] ; then
145+
echo "readme=${readme}" >> $GITHUB_OUTPUT
146+
else
147+
echo "README Not found at ${readme}"
148+
fi
149+
if [[ -s "${icon}" ]] ; then
150+
echo "icon=${icon}" >> $GITHUB_OUTPUT
151+
else
152+
echo "Icon Not found at ${icon}"
153+
fi
154+
[[ -f manifest.json ]] && rm -f manifest.json
155+
if checkJson "$platformJson" ; then
156+
echo $manifest > manifest.json
157+
echo "Wrote manifest.json"
158+
fi
159+
find .
160+
}
161+
162+
function checkJson() {
163+
local json="$1" ; local out
164+
if ! out="$( echo "$json" | jq -c '.' )" ; then
165+
echo "‼️ Error: Failed to verify json: $out" >&2
166+
return 1
167+
fi
168+
}
169+
main "$@" ; exit $?
152170
153171
- name: Upload Ancillaries
154172
if: steps.download.outputs.continue == 'true'
@@ -170,8 +188,8 @@ jobs:
170188
fail-fast: true
171189
max-parallel: 3
172190
matrix:
173-
version: ${{ fromJson(needs.check.outputs.releasesNeeded) }}
174-
rid: ${{ fromJson(needs.check.outputs.ridArray) }}
191+
version: ${{ fromJSON(needs.check.outputs.releases_needed_json) }}
192+
rid: ${{ fromJSON(needs.check.outputs.rids_json) }}
175193
runs-on: ubuntu-22.04
176194
steps:
177195
- name: Get Ancillaries
@@ -189,32 +207,49 @@ jobs:
189207
releasePrefix: ${{ needs.check.outputs.releasePrefix }}
190208
rid: ${{ matrix.rid }}
191209
manifest: ${{steps.ancillaries.outputs.download-path}}/manifest.json
192-
manifest_path: ${{steps.ancillaries.outputs.download-path}}
193210
this_repo_url: ${{ github.repositoryUrl }}
194211
this_repo_commit: ${{ github.sha }}
195212
this_repo_branch: ${{ github.ref_name }}
196213
run: |
197214
if [[ ! -s "$manifest" ]] ; then
198-
echo "Manifest does not exist at $manifest"
215+
echo "Manifest does not exist yet at $manifest"
199216
ls -la
200217
unzip ./*.zip
201218
ls -la
202219
[[ ! -s "$manifest" ]] && exit 1
220+
echo "Manifest now exists at $manifest"
203221
fi
204-
if ! ridJson=$(jq -c ".platforms[] | select(.rid==\"${rid}\")" "$manifest") ; then
222+
if ! ridJson="$( jq -c ".platforms[] | select(.rid==\"${rid}\")" "$manifest" )" ; then
205223
echo -e "Problem getting JSON for $rid from $manifest:\n$ridJson"
206224
#exit 1
207225
fi
208226
if [[ "$ridJson" == "" ]] ; then
209227
echo "No manifest for $rid, so no need to continue."
210228
continue="false"
211229
else
212-
gitCommit=$(jq -r ".gitCommit" "$manifest") || echo "Problem getting gitCommit from manifest: $gitCommit"
213-
gitBranch=$(jq -r ".gitBranch" "$manifest") || echo "Problem getting gitBranch from manifest: $gitBranch"
214-
location=$(jq -r ".location" <<< "$ridJson") || echo "Problem getting location from manifest: $location"
215-
filename=$(jq -r ".filename" <<< "$ridJson") || echo "Problem getting filename from manifest: $filename"
230+
echo -n "Reading details; "
231+
if gitCommit="$( jq -r ".gitCommit" "$manifest" )" ; then
232+
echo -n "git commit ${gitCommit}, "
233+
else
234+
echo "Problem getting gitCommit from manifest: $gitCommit"
235+
fi
236+
if gitBranch="$( jq -r ".gitBranch" "$manifest" )" ; then
237+
echo -n "git branch ${gitBranch}, "
238+
else
239+
echo "Problem getting gitBranch from manifest: $gitBranch"
240+
fi
241+
if location="$( jq -r ".location" <<< "$ridJson" )" ; then
242+
echo -n "location ${location}, "
243+
else
244+
echo "Problem getting location from manifest: $location"
245+
fi
246+
if filename="$( jq -r ".filename" <<< "$ridJson" )" ; then
247+
echo -n "filename ${filename}, "
248+
else
249+
echo "Problem getting filename from manifest: $filename"
250+
fi
251+
echo "done."
216252
continue="true"
217-
echo "gitCommit ${gitCommit}, gitBranch ${gitBranch}, location ${location}, filename ${filename}"
218253
fi
219254
# If this is not a produciton build (so it will use our GitHub store), we have to lie about where it comes from
220255
if [[ "$debug" == "true" ]] ; then
@@ -226,7 +261,6 @@ jobs:
226261
#shellcheck disable=SC2129
227262
echo "filename=${filename}" >> "$GITHUB_OUTPUT"
228263
echo "location=${location}" >> "$GITHUB_OUTPUT"
229-
echo "ersion=${version} >> "$GITHUB_OUTPUT" # no "v" prefix, haha
230264
echo "packageName=StirlingLabs.MsQuic.Bindings.runtime.${rid}.openssl" >> "$GITHUB_OUTPUT"
231265
echo "gitUrl=${gitUrl}" >> "$GITHUB_OUTPUT"
232266
echo "gitCommit=${gitCommit}" >> "$GITHUB_OUTPUT"

0 commit comments

Comments
 (0)