Skip to content

Commit 8b8c6cc

Browse files
committed
add ci-install.sh
1 parent ccbc617 commit 8b8c6cc

File tree

2 files changed

+101
-1
lines changed

2 files changed

+101
-1
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ push-gist:
2020
rm -rf sitedog_gist
2121
git clone [email protected]:fe278d331980a1ce09c3d946bbf0b83b.git --depth 1 sitedog_gist
2222
rm -rf sitedog_gist/*
23-
cp demo.html.tpl scripts/install.sh scripts/uninstall.sh sitedog_gist/
23+
cp demo.html.tpl scripts/install.sh scripts/ci-install.sh scripts/uninstall.sh sitedog_gist/
2424
cd sitedog_gist && \
2525
if git diff --quiet; then \
2626
echo "No changes to deploy"; \

scripts/ci-install.sh

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
# Colors for output
6+
GREEN='\033[0;32m'
7+
RED='\033[0;31m'
8+
YELLOW='\033[1;33m'
9+
NC='\033[0m' # No Color
10+
11+
# Function to print colored output
12+
print_info() {
13+
echo "${GREEN}$1${NC}"
14+
}
15+
16+
print_error() {
17+
echo "${RED}$1${NC}"
18+
}
19+
20+
print_warning() {
21+
echo "${YELLOW}$1${NC}"
22+
}
23+
24+
# Detect platform and architecture
25+
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
26+
ARCH=$(uname -m)
27+
28+
case "$ARCH" in
29+
x86_64|amd64) ARCH="amd64" ;;
30+
aarch64|arm64) ARCH="arm64" ;;
31+
*)
32+
print_error "Unsupported architecture: $ARCH"
33+
exit 1
34+
;;
35+
esac
36+
37+
case "$OS" in
38+
linux) BIN_NAME="sitedog-linux-$ARCH" ;;
39+
darwin) BIN_NAME="sitedog-darwin-$ARCH" ;;
40+
*)
41+
print_error "Unsupported OS: $OS"
42+
exit 1
43+
;;
44+
esac
45+
46+
# GitHub repository and API
47+
REPO="SiteDog-io/sitedog-cli"
48+
API_URL="https://api.github.com/repos/$REPO/releases/latest"
49+
50+
# Get latest release assets
51+
RELEASE_INFO=$(curl -s "$API_URL")
52+
if [ $? -ne 0 ]; then
53+
print_error "Failed to fetch release information from GitHub"
54+
exit 1
55+
fi
56+
57+
# Extract version and binary download URL
58+
VERSION=$(echo "$RELEASE_INFO" | grep '"tag_name"' | head -n1 | cut -d '"' -f 4)
59+
ASSET_URL=$(echo "$RELEASE_INFO" | grep 'browser_download_url' | grep "$BIN_NAME" | head -n1 | cut -d '"' -f 4)
60+
61+
if [ -z "$ASSET_URL" ]; then
62+
print_error "Could not find binary $BIN_NAME in the latest release"
63+
exit 1
64+
fi
65+
66+
echo "Downloading sitedog $VERSION to current directory..."
67+
68+
# Download binary to current directory
69+
curl -sL "$ASSET_URL" -o "./sitedog"
70+
71+
if [ ! -f "./sitedog" ]; then
72+
print_error "Failed to download binary"
73+
exit 1
74+
fi
75+
76+
chmod +x "./sitedog"
77+
78+
# Download template to current directory
79+
TPL_NAME="demo.html.tpl"
80+
TPL_URL=$(echo "$RELEASE_INFO" | grep 'browser_download_url' | grep "$TPL_NAME" | head -n1 | cut -d '"' -f 4)
81+
82+
if [ -z "$TPL_URL" ]; then
83+
print_error "Could not find template $TPL_NAME in the latest release"
84+
exit 1
85+
fi
86+
87+
curl -sL "$TPL_URL" -o "./demo.html.tpl"
88+
89+
if [ ! -f "./demo.html.tpl" ]; then
90+
print_error "Failed to download template"
91+
exit 1
92+
fi
93+
94+
# Success message
95+
echo ""
96+
print_info "SiteDog successfully installed!"
97+
echo ""
98+
echo "Usage:"
99+
echo "./sitedog push SITEDOG_TOKEN=your-sitedog-cli-token"
100+
echo ""

0 commit comments

Comments
 (0)