-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·144 lines (116 loc) · 3.84 KB
/
install.sh
File metadata and controls
executable file
·144 lines (116 loc) · 3.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#!/bin/bash
# playconsole-cli - Google Play Console CLI installer
# Usage: curl -fsSL https://raw.githubusercontent.com/AndroidPoet/playconsole-cli/main/install.sh | bash
set -e
REPO="${GPC_REPO:-AndroidPoet/playconsole-cli}"
INSTALL_DIR="${GPC_INSTALL_DIR:-$HOME/.local/bin}"
VERSION="${GPC_VERSION:-latest}"
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m'
info() { echo -e "${GREEN}==>${NC} $1"; }
warn() { echo -e "${YELLOW}==>${NC} $1"; }
error() { echo -e "${RED}Error:${NC} $1"; exit 1; }
# Detect OS
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
case "$OS" in
darwin) OS="darwin" ;;
linux) OS="linux" ;;
mingw*|msys*|cygwin*) OS="windows" ;;
*) error "Unsupported OS: $OS" ;;
esac
# Detect architecture
ARCH=$(uname -m)
case "$ARCH" in
x86_64|amd64) ARCH="amd64" ;;
aarch64|arm64) ARCH="arm64" ;;
*) error "Unsupported architecture: $ARCH" ;;
esac
info "Installing playconsole-cli for ${OS}/${ARCH}..."
# GitHub API headers
AUTH_HEADER=""
if [ -n "$GITHUB_TOKEN" ]; then
AUTH_HEADER="Authorization: token $GITHUB_TOKEN"
fi
# Get download URL
if [ "$VERSION" = "latest" ]; then
RELEASE_URL="https://api.github.com/repos/${REPO}/releases/latest"
else
RELEASE_URL="https://api.github.com/repos/${REPO}/releases/tags/${VERSION}"
fi
info "Fetching release info..."
if [ -n "$AUTH_HEADER" ]; then
RELEASE_JSON=$(curl -fsSL -H "$AUTH_HEADER" "$RELEASE_URL" 2>/dev/null) || error "Failed to fetch release info. Check your GITHUB_TOKEN."
else
RELEASE_JSON=$(curl -fsSL "$RELEASE_URL" 2>/dev/null) || error "Failed to fetch release info."
fi
# Find asset for this platform
ASSET_NAME="playconsole-cli_.*_${OS}_${ARCH}"
if [ "$OS" = "windows" ]; then
ASSET_NAME="${ASSET_NAME}.zip"
else
ASSET_NAME="${ASSET_NAME}.tar.gz"
fi
DOWNLOAD_URL=$(echo "$RELEASE_JSON" | grep -o "\"browser_download_url\": \"[^\"]*${ASSET_NAME}[^\"]*\"" | head -1 | cut -d'"' -f4)
if [ -z "$DOWNLOAD_URL" ]; then
# Try to find any matching asset
warn "No pre-built binary for ${OS}/${ARCH}. Attempting build from source..."
if ! command -v go &> /dev/null; then
error "Go is required to build from source. Install Go from https://go.dev"
fi
TMPDIR=$(mktemp -d)
cd "$TMPDIR"
if [ -n "$GITHUB_TOKEN" ]; then
git clone "https://${GITHUB_TOKEN}@github.com/${REPO}.git" playconsole-cli
else
git clone "https://github.com/${REPO}.git" playconsole-cli
fi
cd playconsole-cli
go build -o playconsole-cli ./cmd/playconsole-cli
mkdir -p "$INSTALL_DIR"
mv playconsole-cli "$INSTALL_DIR/playconsole-cli"
cd /
rm -rf "$TMPDIR"
else
info "Downloading from: $DOWNLOAD_URL"
TMPDIR=$(mktemp -d)
cd "$TMPDIR"
if [ -n "$AUTH_HEADER" ]; then
curl -fsSL -H "$AUTH_HEADER" -H "Accept: application/octet-stream" -o archive "$DOWNLOAD_URL"
else
curl -fsSL -o archive "$DOWNLOAD_URL"
fi
# Extract
if [ "$OS" = "windows" ]; then
unzip -q archive
else
tar -xzf archive
fi
# Install
mkdir -p "$INSTALL_DIR"
mv playconsole-cli "$INSTALL_DIR/playconsole-cli"
cd /
rm -rf "$TMPDIR"
fi
chmod +x "$INSTALL_DIR/playconsole-cli"
# Create gpc alias
ln -sf "$INSTALL_DIR/playconsole-cli" "$INSTALL_DIR/gpc"
info "Installed playconsole-cli to $INSTALL_DIR/playconsole-cli"
info "Created alias: gpc -> playconsole-cli"
# Check PATH
if ! echo "$PATH" | tr ':' '\n' | grep -q "^$INSTALL_DIR$"; then
warn "Add to your PATH by adding this to ~/.bashrc or ~/.zshrc:"
echo ""
echo " export PATH=\"\$PATH:$INSTALL_DIR\""
echo ""
fi
# Verify installation
if "$INSTALL_DIR/playconsole-cli" version &>/dev/null; then
info "Installation complete!"
echo ""
"$INSTALL_DIR/playconsole-cli" version
else
warn "Installed but could not verify. Try running: $INSTALL_DIR/playconsole-cli --help"
fi