Skip to content

Commit 1021a3a

Browse files
wenfengwangclaude
andcommitted
ci: add Cloudflare Pages deploy step to release workflow
Deploy website/public via wrangler-action on every push to main. Also restore install.sh filename. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 5df8486 commit 1021a3a

2 files changed

Lines changed: 192 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,10 @@ jobs:
4646
4747
**Version:** `${{ steps.version.outputs.version }}`
4848
**Commit:** ${{ github.sha }}
49+
50+
- name: Deploy website to Cloudflare Pages
51+
uses: cloudflare/wrangler-action@v3
52+
with:
53+
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
54+
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
55+
command: pages deploy website/public --project-name anycli

website/public/install.sh

Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,185 @@
1+
#!/bin/sh
2+
# AnyCLI installer - https://anycli.dev
3+
# Usage: curl -fsSL https://anycli.dev/install | sh
4+
5+
set -e
6+
7+
REPO="sheet0/anycli"
8+
INSTALL_DIR="${ANYCLI_INSTALL_DIR:-/usr/local/bin}"
9+
ANYCLI_HOME="${ANYCLI_HOME:-$HOME/.anycli}"
10+
11+
# Detect OS and architecture
12+
detect_platform() {
13+
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
14+
ARCH=$(uname -m)
15+
16+
case "$OS" in
17+
darwin) OS="darwin" ;;
18+
linux) OS="linux" ;;
19+
*) echo "error: unsupported OS: $OS"; exit 1 ;;
20+
esac
21+
22+
case "$ARCH" in
23+
x86_64|amd64) ARCH="amd64" ;;
24+
arm64|aarch64) ARCH="arm64" ;;
25+
*) echo "error: unsupported architecture: $ARCH"; exit 1 ;;
26+
esac
27+
28+
echo "${OS}_${ARCH}"
29+
}
30+
31+
# Resolve the download URL for the latest release asset matching the platform
32+
resolve_asset_url() {
33+
local platform="$1"
34+
local api_url="https://api.github.com/repos/${REPO}/releases/tags/latest"
35+
local json
36+
37+
if command -v curl >/dev/null 2>&1; then
38+
json=$(curl -fsSL "$api_url")
39+
elif command -v wget >/dev/null 2>&1; then
40+
json=$(wget -qO- "$api_url")
41+
else
42+
echo "error: curl or wget required" >&2
43+
exit 1
44+
fi
45+
46+
# Find the asset URL matching our platform
47+
echo "$json" | grep "browser_download_url" | grep "$platform" | head -1 | sed 's/.*"\(https[^"]*\)".*/\1/'
48+
}
49+
50+
# Download and install
51+
install() {
52+
PLATFORM=$(detect_platform)
53+
54+
echo "Installing anycli (${PLATFORM})..."
55+
56+
# Download from the rolling "latest" release tag
57+
# Asset naming: anycli_<version>_<os>_<arch>.tar.gz — but version varies,
58+
# so we resolve the actual asset URL from the release API.
59+
ASSET_URL=$(resolve_asset_url "$PLATFORM")
60+
61+
if [ -z "$ASSET_URL" ]; then
62+
echo "error: could not find release asset for ${PLATFORM}"
63+
exit 1
64+
fi
65+
TMP_DIR=$(mktemp -d)
66+
trap 'rm -rf "$TMP_DIR"' EXIT
67+
68+
# Download
69+
if command -v curl >/dev/null 2>&1; then
70+
curl -fsSL -L "$ASSET_URL" -o "$TMP_DIR/anycli.tar.gz"
71+
else
72+
wget -q "$ASSET_URL" -O "$TMP_DIR/anycli.tar.gz"
73+
fi
74+
75+
# Extract
76+
tar -xzf "$TMP_DIR/anycli.tar.gz" -C "$TMP_DIR"
77+
78+
# Install binary
79+
if [ -w "$INSTALL_DIR" ]; then
80+
mv "$TMP_DIR/anycli" "$INSTALL_DIR/anycli"
81+
else
82+
echo "Installing to ${INSTALL_DIR} (requires sudo)..."
83+
sudo mv "$TMP_DIR/anycli" "$INSTALL_DIR/anycli"
84+
fi
85+
86+
chmod +x "$INSTALL_DIR/anycli"
87+
88+
# Create anycli directories
89+
mkdir -p "$ANYCLI_HOME/bin"
90+
mkdir -p "$ANYCLI_HOME/registry"
91+
mkdir -p "$ANYCLI_HOME/credentials"
92+
mkdir -p "$ANYCLI_HOME/tools"
93+
94+
# Add ~/.anycli/bin to PATH if not already present
95+
SHELL_NAME=$(basename "$SHELL")
96+
BIN_PATH="$ANYCLI_HOME/bin"
97+
PATH_LINE="export PATH=\"$BIN_PATH:\$PATH\""
98+
99+
add_to_path() {
100+
local rc_file="$1"
101+
if [ -f "$rc_file" ]; then
102+
if ! grep -q "anycli/bin" "$rc_file" 2>/dev/null; then
103+
echo "" >> "$rc_file"
104+
echo "# AnyCLI" >> "$rc_file"
105+
echo "$PATH_LINE" >> "$rc_file"
106+
fi
107+
fi
108+
}
109+
110+
case "$SHELL_NAME" in
111+
zsh) add_to_path "$HOME/.zshrc" ;;
112+
bash) add_to_path "$HOME/.bashrc"; add_to_path "$HOME/.bash_profile" ;;
113+
fish)
114+
mkdir -p "$HOME/.config/fish"
115+
if ! grep -q "anycli/bin" "$HOME/.config/fish/config.fish" 2>/dev/null; then
116+
echo "" >> "$HOME/.config/fish/config.fish"
117+
echo "# AnyCLI" >> "$HOME/.config/fish/config.fish"
118+
echo "set -gx PATH $BIN_PATH \$PATH" >> "$HOME/.config/fish/config.fish"
119+
fi
120+
;;
121+
*) add_to_path "$HOME/.profile" ;;
122+
esac
123+
124+
echo ""
125+
echo " anycli installed successfully!"
126+
echo ""
127+
echo " Run 'anycli install gh' to get started."
128+
echo ""
129+
echo " Restart your shell or run:"
130+
echo " $PATH_LINE"
131+
echo ""
132+
}
133+
134+
# Uninstall
135+
uninstall() {
136+
echo "Uninstalling anycli..."
137+
138+
# Remove binary
139+
if [ -f "$INSTALL_DIR/anycli" ]; then
140+
if [ -w "$INSTALL_DIR" ]; then
141+
rm -f "$INSTALL_DIR/anycli"
142+
else
143+
sudo rm -f "$INSTALL_DIR/anycli"
144+
fi
145+
fi
146+
147+
# Remove anycli home directory
148+
if [ -d "$ANYCLI_HOME" ]; then
149+
rm -rf "$ANYCLI_HOME"
150+
fi
151+
152+
# Remove PATH entries from shell configs
153+
remove_from_rc() {
154+
local rc_file="$1"
155+
if [ -f "$rc_file" ]; then
156+
# Remove AnyCLI comment and PATH line
157+
sed -i.bak '/# AnyCLI/d' "$rc_file"
158+
sed -i.bak '/anycli\/bin/d' "$rc_file"
159+
rm -f "${rc_file}.bak"
160+
fi
161+
}
162+
163+
remove_from_rc "$HOME/.zshrc"
164+
remove_from_rc "$HOME/.bashrc"
165+
remove_from_rc "$HOME/.bash_profile"
166+
remove_from_rc "$HOME/.profile"
167+
if [ -f "$HOME/.config/fish/config.fish" ]; then
168+
remove_from_rc "$HOME/.config/fish/config.fish"
169+
fi
170+
171+
echo ""
172+
echo " anycli uninstalled successfully."
173+
echo " Restart your shell to apply PATH changes."
174+
echo ""
175+
}
176+
177+
# Parse command
178+
case "${1:-install}" in
179+
install) install ;;
180+
uninstall) uninstall ;;
181+
*)
182+
echo "Usage: install.sh [install|uninstall]"
183+
exit 1
184+
;;
185+
esac

0 commit comments

Comments
 (0)