Skip to content

Commit a57a7a6

Browse files
committed
add: installation script
1 parent 7729a17 commit a57a7a6

File tree

2 files changed

+79
-0
lines changed

2 files changed

+79
-0
lines changed

README.md

+8
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@
1717

1818
You can try RayQL using the [Online RayQL editor](https://harshdoesdev.github.io/rayql-studio/).
1919

20+
## Installation
21+
22+
You can install RayQL by running the following command in your terminal:
23+
24+
```bash
25+
curl -s https://raw.githubusercontent.com/harshdoesdev/rayql/main/install.sh | sh
26+
```
27+
2028
## Schema Definition
2129

2230
You can define your database schema by creating a RayQL file called `schema.rayql`.

install.sh

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#!/bin/bash
2+
3+
# Set text colors
4+
RED='\033[0;31m'
5+
GREEN='\033[0;32m'
6+
YELLOW='\033[0;33m'
7+
NC='\033[0m' # No Color
8+
9+
# Set the latest release version
10+
LATEST_VERSION=$(curl -s "https://api.github.com/repos/harshdoesdev/rayql/releases/latest" | grep -o '"tag_name": "v.*"' | cut -d'"' -f4)
11+
12+
# Determine the operating system and architecture
13+
OS=$(uname -s)
14+
ARCH=$(uname -m)
15+
16+
# Set the file extension based on the operating system
17+
if [ "$OS" = "Darwin" ]; then
18+
FILE_EXTENSION="apple-darwin.zip"
19+
elif [ "$OS" = "Linux" ]; then
20+
if [ "$ARCH" = "x86_64" ]; then
21+
FILE_EXTENSION="unknown-linux-musl.tar.gz"
22+
else
23+
echo "${RED}Unsupported architecture: $ARCH${NC}"
24+
exit 1
25+
fi
26+
else
27+
echo "${RED}Unsupported operating system: $OS${NC}"
28+
exit 1
29+
fi
30+
31+
# Get download URL
32+
DOWNLOAD_URL=$(curl -s "https://api.github.com/repos/harshdoesdev/rayql/releases/latest" | grep -o "\"browser_download_url\": *\"[^\"]*${FILE_EXTENSION}\"" | cut -d '"' -f 4)
33+
34+
# Print the download URL
35+
echo -e "⬇️ ${YELLOW}Downloading rayql version $LATEST_VERSION for $OS...${NC}"
36+
37+
# Download the binary
38+
curl -LO "$DOWNLOAD_URL"
39+
40+
# Extract the binary if it's a tarball or zip
41+
if [[ "$DOWNLOAD_URL" == *".tar.gz" ]]; then
42+
tar -xzf "rayql_${LATEST_VERSION}_${ARCH}-${OS}.${FILE_EXTENSION}"
43+
BINARY_PATH="./rayql_${LATEST_VERSION}_${ARCH}-${OS}/rayql"
44+
elif [[ "$DOWNLOAD_URL" == *".zip" ]]; then
45+
ZIP_FILE=$(basename "$DOWNLOAD_URL")
46+
unzip "$ZIP_FILE"
47+
BINARY_PATH="./rayql"
48+
else
49+
echo "${RED}Unsupported file format for extraction${NC}"
50+
exit 1
51+
fi
52+
53+
# Make the binary executable
54+
chmod +x "$BINARY_PATH"
55+
56+
# Move the binary to a directory in the user's PATH
57+
echo -e "🚀 ${YELLOW}Installing rayql into /usr/local/bin...${NC}"
58+
sudo mv "$BINARY_PATH" /usr/local/bin/rayql
59+
60+
# Check if rayql binary exists in PATH
61+
if command -v rayql &>/dev/null; then
62+
# Display installation complete message
63+
echo ""
64+
echo -e "${GREEN}rayql ${LATEST_VERSION} has been successfully installed.${NC}"
65+
else
66+
echo "${RED}❌ Error: Failed to install rayql.${NC}"
67+
exit 1
68+
fi
69+
70+
# Clean up downloaded zip file
71+
rm -f "$ZIP_FILE"

0 commit comments

Comments
 (0)