|
8 | 8 | # Prevent running with partial download |
9 | 9 | { # this ensures the entire script is downloaded |
10 | 10 |
|
11 | | -# Function to get latest release info using GitHub API |
12 | | -get_latest_release() { |
13 | | - curl --silent "https://api.github.com/repos/render-oss/cli/releases/latest" | |
14 | | - sed -n 's/.*"tag_name": "\([^"]*\)".*/\1/p' |
15 | | -} |
16 | | - |
17 | | -# Function to output error message and exit |
18 | | -error() { |
| 11 | + # Function to get latest release info using GitHub API |
| 12 | + get_latest_release() { |
| 13 | + curl --silent "https://api.github.com/repos/render-oss/cli/releases/latest" \ |
| 14 | + | sed -n 's/.*"tag_name": "\([^"]*\)".*/\1/p' |
| 15 | + } |
| 16 | + |
| 17 | + # Function to output error message and exit |
| 18 | + error() { |
19 | 19 | echo "Error: $1" >&2 |
20 | 20 | exit 1 |
21 | | -} |
22 | | - |
23 | | -# Check for required commands |
24 | | -command -v curl >/dev/null 2>&1 || error "curl is required but not installed" |
25 | | -command -v sed >/dev/null 2>&1 || error "sed is required but not installed" |
26 | | -command -v unzip >/dev/null 2>&1 || error "unzip is required but not installed" |
27 | | - |
28 | | -# Detect OS |
29 | | -OS="$(uname -s)" |
30 | | -case "${OS}" in |
31 | | - Linux*) OS_NAME=linux;; |
32 | | - Darwin*) OS_NAME=darwin;; |
33 | | - *) error "Unsupported operating system: ${OS}";; |
34 | | -esac |
35 | | - |
36 | | -# Detect architecture |
37 | | -ARCH="$(uname -m)" |
38 | | -case "${ARCH}" in |
39 | | - x86_64*) ARCH_NAME=amd64;; |
40 | | - arm64*) ARCH_NAME=arm64;; |
41 | | - aarch64*) ARCH_NAME=arm64;; |
42 | | - *) error "Unsupported architecture: ${ARCH}";; |
43 | | -esac |
44 | | - |
45 | | -# Get the latest release version |
46 | | -VERSION=$(get_latest_release) |
47 | | -if [ -z "$VERSION" ]; then |
| 21 | + } |
| 22 | + |
| 23 | + # Check for required commands |
| 24 | + command -v curl > /dev/null 2>&1 || error "curl is required but not installed" |
| 25 | + command -v sed > /dev/null 2>&1 || error "sed is required but not installed" |
| 26 | + command -v unzip > /dev/null 2>&1 || error "unzip is required but not installed" |
| 27 | + |
| 28 | + # Detect OS |
| 29 | + OS="$(uname -s)" |
| 30 | + case "${OS}" in |
| 31 | + Linux*) OS_NAME=linux ;; |
| 32 | + Darwin*) OS_NAME=darwin ;; |
| 33 | + *) error "Unsupported operating system: ${OS}" ;; |
| 34 | + esac |
| 35 | + |
| 36 | + # Detect architecture |
| 37 | + ARCH="$(uname -m)" |
| 38 | + case "${ARCH}" in |
| 39 | + x86_64*) ARCH_NAME=amd64 ;; |
| 40 | + arm64*) ARCH_NAME=arm64 ;; |
| 41 | + aarch64*) ARCH_NAME=arm64 ;; |
| 42 | + *) error "Unsupported architecture: ${ARCH}" ;; |
| 43 | + esac |
| 44 | + |
| 45 | + # Get the latest release version |
| 46 | + VERSION=$(get_latest_release) |
| 47 | + if [ -z "$VERSION" ]; then |
48 | 48 | error "Failed to get latest release version" |
49 | | -fi |
| 49 | + fi |
50 | 50 |
|
51 | | -# Remove 'v' prefix from version if present |
52 | | -VERSION_NUM="${VERSION#v}" |
| 51 | + # Remove 'v' prefix from version if present |
| 52 | + VERSION_NUM="${VERSION#v}" |
53 | 53 |
|
54 | | -echo "Installing Render CLI version ${VERSION}..." |
| 54 | + echo "Installing Render CLI version ${VERSION}..." |
55 | 55 |
|
56 | | -# Construct download URL |
57 | | -BINARY_NAME="cli_${VERSION_NUM}_${OS_NAME}_${ARCH_NAME}.zip" |
58 | | -DOWNLOAD_URL="https://github.com/render-oss/cli/releases/download/${VERSION}/${BINARY_NAME}" |
| 56 | + # Construct download URL |
| 57 | + BINARY_NAME="cli_${VERSION_NUM}_${OS_NAME}_${ARCH_NAME}.zip" |
| 58 | + DOWNLOAD_URL="https://github.com/render-oss/cli/releases/download/${VERSION}/${BINARY_NAME}" |
59 | 59 |
|
60 | | -# Create temporary directory |
61 | | -TMP_DIR=$(mktemp -d) |
62 | | -trap 'rm -rf "$TMP_DIR"' EXIT |
| 60 | + # Create temporary directory |
| 61 | + TMP_DIR=$(mktemp -d) |
| 62 | + trap 'rm -rf "$TMP_DIR"' EXIT |
63 | 63 |
|
64 | | -# Download and install |
65 | | -echo "Downloading from ${DOWNLOAD_URL}..." |
66 | | -curl -fsSL "$DOWNLOAD_URL" -o "${TMP_DIR}/${BINARY_NAME}" |
| 64 | + # Download and install |
| 65 | + echo "Downloading from ${DOWNLOAD_URL}..." |
| 66 | + curl -fsSL "$DOWNLOAD_URL" -o "${TMP_DIR}/${BINARY_NAME}" |
67 | 67 |
|
68 | | -# Determine install location |
69 | | -if [ "$(id -u)" -eq 0 ]; then |
| 68 | + # Determine install location |
| 69 | + if [ "$(id -u)" -eq 0 ]; then |
70 | 70 | INSTALL_DIR="/usr/local/bin" |
71 | | -else |
| 71 | + else |
72 | 72 | INSTALL_DIR="$HOME/.local/bin" |
73 | 73 | mkdir -p "$INSTALL_DIR" |
74 | | -fi |
| 74 | + fi |
75 | 75 |
|
76 | | -# Unzip in temporary directory |
77 | | -unzip -o "${TMP_DIR}/${BINARY_NAME}" -d "${TMP_DIR}" >/dev/null 2>&1 |
| 76 | + # Unzip in temporary directory |
| 77 | + unzip -o "${TMP_DIR}/${BINARY_NAME}" -d "${TMP_DIR}" > /dev/null 2>&1 |
78 | 78 |
|
79 | | -# Find and move the binary |
80 | | -RENDER_BINARY=$(find "${TMP_DIR}" -type f -name "cli_v*" | head -n 1) |
81 | | -if [ -z "$RENDER_BINARY" ]; then |
| 79 | + # Find and move the binary |
| 80 | + RENDER_BINARY=$(find "${TMP_DIR}" -type f -name "cli_v*" | head -n 1) |
| 81 | + if [ -z "$RENDER_BINARY" ]; then |
82 | 82 | error "Could not find CLI binary in the archive" |
83 | | -fi |
| 83 | + fi |
84 | 84 |
|
85 | | -mv "${RENDER_BINARY}" "${INSTALL_DIR}/render" |
86 | | -chmod +x "${INSTALL_DIR}/render" |
| 85 | + mv "${RENDER_BINARY}" "${INSTALL_DIR}/render" |
| 86 | + chmod +x "${INSTALL_DIR}/render" |
87 | 87 |
|
88 | | -# Verify installation by checking the binary directly |
89 | | -if [ -x "${INSTALL_DIR}/render" ]; then |
| 88 | + # Verify installation by checking the binary directly |
| 89 | + if [ -x "${INSTALL_DIR}/render" ]; then |
90 | 90 | echo "✨ Successfully installed Render CLI to ${INSTALL_DIR}/render" |
91 | 91 | echo |
92 | | - if ! command -v render >/dev/null 2>&1; then |
93 | | - echo "NOTE: Make sure ${INSTALL_DIR} is in your PATH by adding this to your shell's rc file:" |
94 | | - echo " export PATH=\$PATH:${INSTALL_DIR}" |
95 | | - echo |
96 | | - echo "To use render CLI immediately, run:" |
97 | | - echo " export PATH=\$PATH:${INSTALL_DIR}" |
98 | | - echo " ${INSTALL_DIR}/render --version" |
| 92 | + if ! command -v render > /dev/null 2>&1; then |
| 93 | + echo "NOTE: Make sure ${INSTALL_DIR} is in your PATH by adding this to your shell's rc file:" |
| 94 | + echo " export PATH=\$PATH:${INSTALL_DIR}" |
| 95 | + echo |
| 96 | + echo "To use render CLI immediately, run:" |
| 97 | + echo " export PATH=\$PATH:${INSTALL_DIR}" |
| 98 | + echo " ${INSTALL_DIR}/render --version" |
99 | 99 | else |
100 | | - "${INSTALL_DIR}/render" --version |
| 100 | + "${INSTALL_DIR}/render" --version |
101 | 101 | fi |
102 | | -else |
| 102 | + else |
103 | 103 | error "Installation failed: Could not install binary to ${INSTALL_DIR}/render" |
104 | | -fi |
| 104 | + fi |
105 | 105 |
|
106 | 106 | } |
0 commit comments