From 6dadbd9176e2d70b3a66c4a5c38f97ebc4329758 Mon Sep 17 00:00:00 2001 From: Tobias Waldekranz Date: Mon, 30 Sep 2024 13:19:54 +0200 Subject: [PATCH 1/2] utils/gh-dl-artifact.sh: Look for artifacts in all runs Previously, the assumption was that the artifact could be found in the first run of "Bob the Builder". This does not hold in the case when: 1. An initial run is aborted, and is re-run at a later date 2. When a release is built (by "Release General") --- utils/gh-dl-artifact.sh | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/utils/gh-dl-artifact.sh b/utils/gh-dl-artifact.sh index d80888bf8..fa8bf1edc 100755 --- a/utils/gh-dl-artifact.sh +++ b/utils/gh-dl-artifact.sh @@ -105,15 +105,22 @@ ixmsg "Locating $arch build of $rev" sha=$(gh api "$apibase/commits/$rev" -q .sha || die "ERROR: Unknown revision \"$rev\"") echo "SHA: $sha" -run=$(gh api "$apibase/actions/runs?head_sha=$sha" \ - -q '[.workflow_runs[] | select(.name == "Bob the Builder")][0].id' \ - || die "ERROR: Found no workflow runs associated with $rev") -echo "Run: $run" - -gh api "$apibase/actions/runs/$run/artifacts" \ - -q ".artifacts[] | select(.name == \"artifact-$arch\")" >$workdir/artifact.json \ - || die "ERROR: Found no $arch artifact associated with run $run" -artifact="$(jq .id $workdir/artifact.json)" +runs=$(gh api "$apibase/actions/runs?head_sha=$sha" \ + -q '.workflow_runs[] | .id' | tr '\n' ' ' \ + || die "ERROR: Found no workflow runs associated with $rev") + +echo "Runs: $runs" + +for run in $runs; do + gh api "$apibase/actions/runs/$run/artifacts" \ + -q ".artifacts[] | select(.name == \"artifact-$arch\")" >$workdir/artifact.json \ + || continue + + artifact="$(jq .id $workdir/artifact.json)" + [ "$artifact" ] && break +done + +[ "$artifact" ] || die "ERROR: Found no $arch artifact associated with any of the runs $runs" echo "Artifact: $artifact" url="$(jq -r .archive_download_url $workdir/artifact.json)" From fb8ac2aca1b654afc0e894b4932ed5f220dbd42b Mon Sep 17 00:00:00 2001 From: Tobias Waldekranz Date: Mon, 30 Sep 2024 13:34:36 +0200 Subject: [PATCH 2/2] utils/gh-dl-artifact.sh: Support extracting release tarballs Release tarball names contain the version information. Make sure we find these files when extracting them from the artifact ZIP. --- utils/gh-dl-artifact.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/gh-dl-artifact.sh b/utils/gh-dl-artifact.sh index fa8bf1edc..2119f1fe1 100755 --- a/utils/gh-dl-artifact.sh +++ b/utils/gh-dl-artifact.sh @@ -160,7 +160,7 @@ gh api $url >$zip ixmsg "Extracting artifact" mkdir -p $imgdir -unzip -p $zip infix-$arch.tar.gz | gunzip | tar -C $imgdir -x --strip-components=1 +unzip -p $zip "infix-${arch}*.tar.gz" | gunzip | tar -C $imgdir -x --strip-components=1 ixmsg "Done"