Skip to content

Commit

Permalink
Fix worker.sh (AppImage#3118)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rosalie241 authored Mar 12, 2023
1 parent ba875e3 commit ac939aa
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions code/worker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ if [ x"${URL:0:18}" == x"https://github.com" ] && [[ "${URL}" != *"download"* ]]
echo "GitHub URL detected"
GHUSER=$(echo "$URL" | cut -d '/' -f 4)
GHREPO=$(echo "$URL" | cut -d '/' -f 5)
GHURL="https://api.github.com/repos/$GHUSER/$GHREPO/releases?access_token=$GH_TOKEN" # Not "/latest" due to https://github.com/AppImage/AppImageHub/issues/12
GHURL="https://api.github.com/repos/$GHUSER/$GHREPO/releases" # Not "/latest" due to https://github.com/AppImage/AppImageHub/issues/12
echo "URL from GitHub: $URL"
fi

Expand All @@ -31,9 +31,10 @@ if [ x"${URL:0:22}" == x"https://api.github.com" ] || [ x"${GHURL:0:22}" == x"ht
GHURL="$URL"
fi
echo "GitHub API URL detected"
URL=$(wget -q "$GHURL" -O - | grep browser_download_url | grep -i AppImage | grep -v 'AppImage\.' | grep -ie 'amd.\?64\|x86.64\|x64\|linux.\?64' | head -n 1 | cut -d '"' -f 4) # TODO: Handle more than one AppImage per release
API_JSON="$(wget -O - --header "Accept: application/vnd.github+json" --header "Authorization: Bearer $GH_TOKEN" --header "X-GitHub-Api-Version: 2022-11-28" "$GHURL")"
URL=$(echo "$API_JSON" | grep browser_download_url | grep -i AppImage | grep -v 'AppImage\.' | grep -ie 'amd.\?64\|x86.64\|x64\|linux.\?64' | head -n 1 | cut -d '"' -f 4) # TODO: Handle more than one AppImage per release
if [ x"" == x"$URL" ] ; then
URL=$(wget -q "$GHURL" -O - | grep browser_download_url | grep -i AppImage | grep -v 'AppImage\.' | head -n 1 | cut -d '"' -f 4) # No 64-bit one found, trying any; TODO: Handle more than one AppImage per release
URL=$(echo "$API_JSON"| grep browser_download_url | grep -i AppImage | grep -v 'AppImage\.' | head -n 1 | cut -d '"' -f 4) # No 64-bit one found, trying any; TODO: Handle more than one AppImage per release
fi
if [ x"" == x"$URL" ] ; then
echo "Unable to get download URL for the AppImage. Is it really there on GitHub Releases?"
Expand All @@ -42,7 +43,7 @@ if [ x"${URL:0:22}" == x"https://api.github.com" ] || [ x"${GHURL:0:22}" == x"ht
echo "URL from GitHub API: $URL"
GHUSER=$(echo "$URL" | cut -d '/' -f 4)
GHREPO=$(echo "$URL" | cut -d '/' -f 5)
LICENSE=$(wget --header "Accept: application/vnd.github.drax-preview+json" "https://api.github.com/repos/$GHUSER/$GHREPO?access_token=$GH_TOKEN" -O - | grep spdx_id | cut -d '"' -f 4 | head -n 1)
LICENSE=$(echo "$API_JSON" | grep spdx_id | cut -d '"' -f 4 | head -n 1)
fi

# Download the file if it is not already there
Expand Down

0 comments on commit ac939aa

Please sign in to comment.