-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathinstall.sh
More file actions
63 lines (51 loc) · 1.92 KB
/
install.sh
File metadata and controls
63 lines (51 loc) · 1.92 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
#!/bin/bash
# Variables
GITHUB_REPO="arleypadua/PKHeX.Everywhere"
INSTALL_DIR="$HOME/.local/bin/pkhex-cli"
EXECUTABLE_NAME="pkhex-cli"
# Determine the platform and architecture
OS=$(uname | tr '[:upper:]' '[:lower:]')
ARCH=$(uname -m)
if [[ "$OS" == "linux" && "$ARCH" == "x86_64" ]]; then
ZIP_NAME="pkhex-cli-linux-x64.zip"
elif [[ "$OS" == "linux" && "$ARCH" == "aarch64" ]]; then
ZIP_NAME="pkhex-cli-linux-arm64.zip"
elif [[ "$OS" == "darwin" && "$ARCH" == "x86_64" ]]; then
ZIP_NAME="pkhex-cli-osx-x64.zip"
elif [[ "$OS" == "darwin" && "$ARCH" == "arm64" ]]; then
ZIP_NAME="pkhex-cli-osx-arm64.zip"
else
echo "Unsupported platform or architecture: $OS $ARCH"
exit 1
fi
# Fetch the latest release URL
GITHUB_URL=$(curl -s https://api.github.com/repos/$GITHUB_REPO/releases/latest | grep "browser_download_url.*$ZIP_NAME" | cut -d '"' -f 4)
# Check if the URL was fetched successfully
if [ -z "$GITHUB_URL" ]; then
echo "Error: Could not fetch the latest release URL. Please check your GitHub repository and artifact name."
exit 1
fi
# Download the zip file
echo "Downloading $ZIP_NAME from $GITHUB_URL..."
curl -L -o $ZIP_NAME $GITHUB_URL &> /dev/null
# Create the install directory if it doesn't exist
if [ ! -d "$INSTALL_DIR" ]; then
echo "Creating install directory $INSTALL_DIR..."
mkdir -p $INSTALL_DIR &> /dev/null
fi
# Unzip the file
echo "Unzipping $ZIP_NAME..."
unzip -o $ZIP_NAME -d $INSTALL_DIR &> /dev/null
# Make the executable part of the PATH
echo "Making $EXECUTABLE_NAME executable..."
chmod +x $INSTALL_DIR/$EXECUTABLE_NAME &> /dev/null
# Add to PATH if not already in PATH
if [[ ":$PATH:" != *":$INSTALL_DIR:"* ]]; then
echo "Adding $INSTALL_DIR to PATH..."
export PATH=$PATH:$INSTALL_DIR
echo 'export PATH=$PATH:'$INSTALL_DIR >> ~/.bashrc
fi
# Clean up
echo "Cleaning up..."
rm $ZIP_NAME &> /dev/null
echo "Installation complete. You can now use $EXECUTABLE_NAME from anywhere."