Skip to content

Commit

Permalink
Extend install to support Linux
Browse files Browse the repository at this point in the history
Signed-off-by: Juan Cruz Viotti <[email protected]>
  • Loading branch information
jviotti committed Jun 3, 2024
1 parent 50464aa commit bbdbbf7
Showing 1 changed file with 29 additions and 5 deletions.
34 changes: 29 additions & 5 deletions install
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,38 @@ set -o errexit
set -o nounset

UNAME="$(uname)"
ARCH="$(uname -m)"

if [ "$UNAME" = "Darwin" ]
then
if [ "$ARCH" != "arm64" ]
then
echo "ERROR: There are no pre-built JSON Schema CLI binaries for macOS on $ARCH" 1>&2
echo "You might be able to build it from source" 1>&2
exit 1
fi

echo "---- Attempting to install the JSON Schema CLI using Homebrew" 1>&2
brew install intelligence-ai/apps/jsonschema
exit 0
elif [ "$UNAME" = "Linux" ]
then
OWNER="intelligence-ai"
REPOSITORY="jsonschema"
LATEST_TAG="$(curl --silent "https://api.github.com/repos/$OWNER/$REPOSITORY/releases/latest" \
| grep '"tag_name"' | cut -d ':' -f 2 | tr -d 'v" ,')"
PACKAGE_BASE_URL="https://github.com/$OWNER/$REPOSITORY/releases/download/v$LATEST_TAG"
PACKAGE_PLATFORM_NAME="$(echo "$UNAME" | tr '[:upper:]' '[:lower:]')"
PACKAGE_URL="$PACKAGE_BASE_URL/jsonschema-$LATEST_TAG-$PACKAGE_PLATFORM_NAME-$ARCH.zip"
OUTPUT="/usr/local"
TMP="$(mktemp -d)"
clean() { rm -rf "$TMP"; }
trap clean EXIT
curl --location --output "$TMP/artifact.zip" "$PACKAGE_URL"
unzip "$TMP/artifact.zip" -d "$TMP/out"
mkdir -p "$OUTPUT/bin"
install -v -m 0755 "$TMP/out/jsonschema-$LATEST_TAG-$PACKAGE_PLATFORM_NAME-$ARCH/bin/jsonschema" "$OUTPUT/bin"
else
echo "ERROR: I don't know how to install the JSON Schema CLI in $UNAME!" 1>&2
echo "Open an issue here: https://github.com/Intelligence-AI/jsonschema/issues" 1>&2
exit 1
fi

echo "ERROR: I don't know how to install the JSON Schema CLI in $UNAME!" 1>&2
echo "Open an issue here: https://github.com/Intelligence-AI/jsonschema/issues" 1>&2
exit 1

0 comments on commit bbdbbf7

Please sign in to comment.