From 764ec6cbdbfb3ebab4e318a78ad02de9ef9ff1e2 Mon Sep 17 00:00:00 2001 From: Reece Williams Date: Wed, 30 Oct 2024 11:58:25 -0500 Subject: [PATCH 1/2] shell installer --- install.sh | 45 ++++++++++++++++++++++++++++++++++++++++++++ scripts/bump_docs.sh | 1 + 2 files changed, 46 insertions(+) create mode 100644 install.sh diff --git a/install.sh b/install.sh new file mode 100644 index 00000000..9302f82e --- /dev/null +++ b/install.sh @@ -0,0 +1,45 @@ +#!/bin/bash +# +# curl -sSL https://raw.githubusercontent.com/rollchains/spawn/release/v0.50/install.sh | bash -s -- v0.50 +# + +VERSION=${1:-"v0.50.10"} +BASE_URL="https://github.com/rollchains/spawn/releases/download/$VERSION" + +ARCH=$(uname -m) +case $ARCH in + x86_64) + ARCH="amd64" + ;; + arm64) + ARCH="arm64" + ;; + *) + echo "Unsupported architecture: $ARCH" + exit 1 + ;; +esac + +OS=$(uname -s | tr '[:upper:]' '[:lower:]') +echo "Downloading spawn $VERSION for $OS/$ARCH..." + +VERSION_NORMALIZED=$(echo $VERSION | tr -d 'v') + +URL="${BASE_URL}/${APP_NAME}_${VERSION_NORMALIZED}_${OS}_${ARCH}.tar.gz" + +TARGET_DIR="$(go env GOPATH)/bin" +mkdir -p "$TARGET_DIR" + +wget -O "/tmp/${APP_NAME}.tar.gz" "$URL" + +mkdir -p /tmp/spawn-install +tar -xvf "/tmp/${APP_NAME}.tar.gz" -C /tmp/spawn-install + +mv "/tmp/spawn-install/${APP_NAME}" "$TARGET_DIR" +chmod +x "$TARGET_DIR/spawn" + +echo "Installation complete. spawn is now available in $TARGET_DIR" +echo "To make spawn available from any terminal session, add the following line to your .bashrc or .zshrc:" +echo "export PATH=\"\$PATH:$TARGET_DIR\"" + +rm -rf /tmp/spawn-install diff --git a/scripts/bump_docs.sh b/scripts/bump_docs.sh index 5b795943..e1880e89 100644 --- a/scripts/bump_docs.sh +++ b/scripts/bump_docs.sh @@ -8,3 +8,4 @@ findAndReplace() { } findAndReplace "*.md" "s/$OLD_VERSION/$NEW_VERSION/g" +findAndReplace "install.sh" "s/$OLD_VERSION/$NEW_VERSION/g" From 965b13e91882f33b3dad61916aae9c807f8c92af Mon Sep 17 00:00:00 2001 From: Reece Williams Date: Wed, 30 Oct 2024 12:03:52 -0500 Subject: [PATCH 2/2] fix: cmd --- install.sh | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/install.sh b/install.sh index 9302f82e..745be31c 100644 --- a/install.sh +++ b/install.sh @@ -1,6 +1,6 @@ #!/bin/bash # -# curl -sSL https://raw.githubusercontent.com/rollchains/spawn/release/v0.50/install.sh | bash -s -- v0.50 +# curl -sSL https://raw.githubusercontent.com/rollchains/spawn/release/v0.50/install.sh | bash # VERSION=${1:-"v0.50.10"} @@ -25,21 +25,27 @@ echo "Downloading spawn $VERSION for $OS/$ARCH..." VERSION_NORMALIZED=$(echo $VERSION | tr -d 'v') -URL="${BASE_URL}/${APP_NAME}_${VERSION_NORMALIZED}_${OS}_${ARCH}.tar.gz" +URL="${BASE_URL}/spawn_${VERSION_NORMALIZED}_${OS}_${ARCH}.tar.gz" TARGET_DIR="$(go env GOPATH)/bin" mkdir -p "$TARGET_DIR" -wget -O "/tmp/${APP_NAME}.tar.gz" "$URL" - mkdir -p /tmp/spawn-install -tar -xvf "/tmp/${APP_NAME}.tar.gz" -C /tmp/spawn-install +wget -O "/tmp/spawn-install/spawn.tar.gz" "$URL" +tar -xvf "/tmp/spawn-install/spawn.tar.gz" -C /tmp/spawn-install -mv "/tmp/spawn-install/${APP_NAME}" "$TARGET_DIR" +mv "/tmp/spawn-install/spawn" "$TARGET_DIR" chmod +x "$TARGET_DIR/spawn" -echo "Installation complete. spawn is now available in $TARGET_DIR" -echo "To make spawn available from any terminal session, add the following line to your .bashrc or .zshrc:" -echo "export PATH=\"\$PATH:$TARGET_DIR\"" + +# see if the command spawn is avaliable in `which spawn` +if [ -x "$(command -v spawn)" ]; then + echo "Spawn Installation complete. spawn is now available in $TARGET_DIR. Run the command 'spawn' from any terminal session." +else + echo "Spawn is not available in your PATH" + echo "To make spawn available from any terminal session, add the following line to your .bashrc or .zshrc:" + echo 'export PATH="$PATH:$(go env GOPATH)/bin"' +fi + rm -rf /tmp/spawn-install