From 857cbc3db064fed11cf74aaaf53b8e3e3858ed21 Mon Sep 17 00:00:00 2001 From: lambda-0x <0xlambda@protonmail.com> Date: Wed, 30 Aug 2023 00:23:02 +0530 Subject: [PATCH] feat(dojoup): remove jq dependency (#847) * feat(dojoup): remove jq dependency * make it more robust --- dojoup/dojoup | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/dojoup/dojoup b/dojoup/dojoup index 3d2047a5b2..a7cb709bc8 100755 --- a/dojoup/dojoup +++ b/dojoup/dojoup @@ -76,14 +76,16 @@ main() { if [[ "$DOJOUP_REPO" == "dojoengine/dojo" && -z "$DOJOUP_BRANCH" && -z "$DOJOUP_COMMIT" ]]; then DOJOUP_VERSION=${DOJOUP_VERSION-stable} DOJOUP_TAG=$DOJOUP_VERSION - need_cmd jq # Normalize versions (handle channels, versions without v prefix if [[ "$DOJOUP_VERSION" == "stable" ]]; then - # Fetch the list of releases from the GitHub API and get the first non-prerelease + # Fetch the list of releases from the GitHub API and filter out `prerelease`` releases and `alpha`` releases DOJOUP_TAG=$(curl -s "https://api.github.com/repos/${DOJOUP_REPO}/releases" \ - | jq -r '.[] | select(.prerelease==false) | .tag_name' \ - | grep -v '-' \ + | grep -oE '"tag_name": "[^"]*"|"prerelease": (true|false)' \ + | grep -B1 '"prerelease": false' \ + | grep '"tag_name":' \ + | grep -oP '"v[0-9]*\.[0-9]*\.[0-9]*"' \ + | tr -d '"' \ | head -n 1) DOJOUP_VERSION=$DOJOUP_TAG elif [[ "$DOJOUP_VERSION" == nightly* ]]; then