Skip to content

Commit 23c944c

Browse files
committed
bash
1 parent 599e9aa commit 23c944c

2 files changed

Lines changed: 47 additions & 13 deletions

File tree

dev/install-rops

Lines changed: 40 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
11
#!/usr/bin/env bash
22
set -e
33

4-
5-
# Load environment variables from .env file
4+
# Install rops binary from GitHub releases
5+
#
6+
# Usage:
7+
# Local: ./install-rops
8+
# Remote: curl -sSL https://raw.githubusercontent.com/quantmind/rops/main/dev/install-rops | GITHUB_TOKEN=your_token bash
9+
#
10+
# Requirements:
11+
# - GITHUB_TOKEN environment variable (for accessing private repos or avoiding rate limits)
12+
13+
# Load environment variables from .env file if it exists (for local development)
614
ENV_FILE="${PWD}/.env"
7-
touch "${ENV_FILE}"
8-
export $(grep -v '^#' "${ENV_FILE}" | xargs)
15+
if [ -f "${ENV_FILE}" ]; then
16+
export $(grep -v '^#' "${ENV_FILE}" | xargs)
17+
fi
918

1019

1120
raw_arch=$(uname -m)
@@ -28,11 +37,23 @@ esac
2837

2938
EXECUTABLE="rops-${ARCH}"
3039

40+
# Prepare authentication header if GITHUB_TOKEN is set
41+
AUTH_HEADER=""
42+
if [ -n "${GITHUB_TOKEN}" ]; then
43+
AUTH_HEADER="Authorization: Bearer ${GITHUB_TOKEN}"
44+
fi
45+
3146
# Fetch the release JSON from GitHub API
32-
RELEASE_JSON=$(curl -s \
33-
-H "Accept: application/vnd.github+json" \
34-
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
35-
https://api.github.com/repos/quantmind/rops/releases/latest)
47+
if [ -n "${AUTH_HEADER}" ]; then
48+
RELEASE_JSON=$(curl -s \
49+
-H "Accept: application/vnd.github+json" \
50+
-H "${AUTH_HEADER}" \
51+
https://api.github.com/repos/quantmind/rops/releases/latest)
52+
else
53+
RELEASE_JSON=$(curl -s \
54+
-H "Accept: application/vnd.github+json" \
55+
https://api.github.com/repos/quantmind/rops/releases/latest)
56+
fi
3657

3758
echo "Release JSON: ${RELEASE_JSON}"
3859
# Extract the top-level release name from the JSON file
@@ -60,13 +81,19 @@ EXECUTABLE_PATH="${INSTALL_DIR}/rops"
6081

6182
ASSET_URL="https://api.github.com/repos/quantmind/rops/releases/assets/${ASSET_ID}"
6283
echo "Download rops executable from ${ASSET_URL}"
63-
curl -L \
64-
-H "Accept: application/octet-stream" \
65-
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
66-
${ASSET_URL} -o ${EXECUTABLE_PATH}
84+
if [ -n "${AUTH_HEADER}" ]; then
85+
curl -L \
86+
-H "Accept: application/octet-stream" \
87+
-H "${AUTH_HEADER}" \
88+
${ASSET_URL} -o ${EXECUTABLE_PATH}
89+
else
90+
curl -L \
91+
-H "Accept: application/octet-stream" \
92+
${ASSET_URL} -o ${EXECUTABLE_PATH}
93+
fi
6794

6895
if [ $? -ne 0 ]; then
69-
echo "Error: Failed to download the asset '${BINARY_NAME}'." >&2
96+
echo "Error: Failed to download the asset '${EXECUTABLE}'." >&2
7097
exit 1
7198
fi
7299

readme.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
Rust operations tool for managing Docker images and Helm charts deployment.
44

5+
## Installation
6+
7+
`Rops` can self-update, but you can also install it manually by running the following command:
8+
9+
```bash
10+
curl -L https://raw.githubusercontent.com/quantmind/rops/main/dev/install-rops | bash
11+
```
512

613
## Configuration
714

0 commit comments

Comments
 (0)