Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add merod and meroctl installation scripts #1022

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions .github/workflows/cross-platform-install-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ on:
branches:
- master

pull_request:
pull_request_target:
types: [opened, reopened]
branches:
- master

Expand All @@ -32,10 +33,21 @@ jobs:
echo "BRANCH_NAME=${{ github.ref_name }}" >> $GITHUB_ENV
fi

# Run the installation script
# Run the merod script
- name: Test installation script
run: |
curl -s https://raw.githubusercontent.com/calimero-network/core/${{ env.BRANCH_NAME }}/scripts/install.sh | bash
curl -s https://raw.githubusercontent.com/calimero-network/core/${{ env.BRANCH_NAME }}/scripts/install-merod.sh | bash

# Validate the binary installation
- name: Validate installation
run: |
which meroctl
merod --version

# Run the meroctl script
- name: Test installation script
run: |
curl -s https://raw.githubusercontent.com/calimero-network/core/${{ env.BRANCH_NAME }}/scripts/install-meroctl.sh | bash

# Validate the binary installation
- name: Validate installation
Expand Down
2 changes: 1 addition & 1 deletion scripts/install.sh → scripts/install-meroctl.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

BINARY_NAME="meroctl"
VERSION="v0.1.1"
VERSION="v0.2.0"
REPO="calimero-network/core"
INSTALL_DIR="$HOME/.local/bin"

Expand Down
68 changes: 68 additions & 0 deletions scripts/install-merod.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#!/bin/bash

BINARY_NAME="merod"
VERSION="v0.2.1"
REPO="calimero-network/core"
INSTALL_DIR="$HOME/.local/bin"

# Detect OS and Architecture
OS=$(uname | tr '[:upper:]' '[:lower:]')
ARCH=$(uname -m)

case "$ARCH" in
"x86_64") ARCH="x86_64" ;;
"arm64" | "aarch64") ARCH="aarch64" ;;
*)
echo "Unsupported architecture: $ARCH."
exit 1
;;
esac

if [ "$OS" == "darwin" ]; then
PLATFORM="apple-darwin"
elif [ "$OS" == "linux" ]; then
PLATFORM="unknown-linux-gnu"
else
echo "Unsupported operating system: $OS."
exit 1
fi

# Construct download URL
TARBALL_NAME="${BINARY_NAME}_${ARCH}-${PLATFORM}.tar.gz"
DOWNLOAD_URL="https://github.com/$REPO/releases/download/$VERSION/$TARBALL_NAME"

# Ensure installation directory exists
mkdir -p "$INSTALL_DIR"

# Download binary tarball
echo "Downloading $TARBALL_NAME from $DOWNLOAD_URL..."
curl -L -o "$TARBALL_NAME" "$DOWNLOAD_URL"

# Extract binary
echo "Extracting $TARBALL_NAME..."
tar -xzf "$TARBALL_NAME"
chmod +x "$BINARY_NAME"

# Move binary to user-local bin directory
mv "$BINARY_NAME" "$INSTALL_DIR/$BINARY_NAME"
rm "$TARBALL_NAME"

# Add $HOME/.local/bin to PATH if not already present
if ! echo "$PATH" | grep -q "$INSTALL_DIR"; then
SHELL_CONFIG_FILE="$HOME/.bashrc"
case "$SHELL" in
*/zsh) SHELL_CONFIG_FILE="$HOME/.zshrc" ;;
*/fish) SHELL_CONFIG_FILE="$HOME/.config/fish/config.fish" ;;
*/csh|*/tcsh) SHELL_CONFIG_FILE="$HOME/.cshrc" ;;
esac

echo 'export PATH="$HOME/.local/bin:$PATH"' >> "$SHELL_CONFIG_FILE"
echo "Added $HOME/.local/bin to PATH in $SHELL_CONFIG_FILE. Please reload your shell or run: source $SHELL_CONFIG_FILE"
fi

# Final message
echo "$BINARY_NAME installed successfully in $INSTALL_DIR."
echo "To verify the installation, make sure $INSTALL_DIR is in your PATH."
echo "Run the following command to update your current shell session if needed:"
echo "source <your-shell-config-file>"
echo "Then run '$BINARY_NAME --version' to confirm the installation."
Loading