mirror of
https://github.com/AikidoSec/safe-chain.git
synced 2026-05-26 12:10:49 +00:00
Make scripts release-proof again
This commit is contained in:
parent
a578ee7213
commit
ac6567ba59
3 changed files with 55 additions and 6 deletions
|
|
@ -7,7 +7,7 @@
|
|||
set -e # Exit on error
|
||||
|
||||
# Configuration
|
||||
VERSION="${SAFE_CHAIN_VERSION:-v0.0.7-binaries-beta}"
|
||||
VERSION="${SAFE_CHAIN_VERSION:-}" # Will be fetched from latest release if not set
|
||||
INSTALL_DIR="${HOME}/.safe-chain/bin"
|
||||
REPO_URL="https://github.com/AikidoSec/safe-chain"
|
||||
|
||||
|
|
@ -54,6 +54,26 @@ command_exists() {
|
|||
command -v "$1" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
# Fetch latest release version tag from GitHub
|
||||
fetch_latest_version() {
|
||||
info "Fetching latest release version..."
|
||||
|
||||
# Try using GitHub API to get the latest release tag
|
||||
if command_exists curl; then
|
||||
latest_version=$(curl -fsSL "https://api.github.com/repos/AikidoSec/safe-chain/releases/latest" | grep '"tag_name"' | sed -E 's/.*"([^"]+)".*/\1/')
|
||||
elif command_exists wget; then
|
||||
latest_version=$(wget -qO- "https://api.github.com/repos/AikidoSec/safe-chain/releases/latest" | grep '"tag_name"' | sed -E 's/.*"([^"]+)".*/\1/')
|
||||
else
|
||||
error "Neither curl nor wget found. Please install one of them or set SAFE_CHAIN_VERSION environment variable."
|
||||
fi
|
||||
|
||||
if [ -z "$latest_version" ]; then
|
||||
error "Failed to fetch latest version from GitHub API. Please set SAFE_CHAIN_VERSION environment variable."
|
||||
fi
|
||||
|
||||
echo "$latest_version"
|
||||
}
|
||||
|
||||
# Download file
|
||||
download() {
|
||||
url="$1"
|
||||
|
|
@ -135,6 +155,11 @@ main() {
|
|||
# Parse command-line arguments
|
||||
parse_arguments "$@"
|
||||
|
||||
# Fetch latest version if VERSION is not set
|
||||
if [ -z "$VERSION" ]; then
|
||||
VERSION=$(fetch_latest_version)
|
||||
fi
|
||||
|
||||
# Build installation message
|
||||
INSTALL_MSG="Installing safe-chain ${VERSION}"
|
||||
if [ "$INCLUDE_PYTHON" = "true" ]; then
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue