ci: improve install script
This commit is contained in:
parent
ec0cf0e8ef
commit
e0a46a338d
|
@ -1,22 +1,40 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# Installs Solc and Geth binaries
|
# Installs Solc and Geth binaries
|
||||||
|
# Note: intended for use only with CI (x86_64 Ubuntu, MacOS or Windows)
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
GETH_BUILD=${GETH_BUILD:-"1.11.2-73b01f40"}
|
GETH_BUILD=${GETH_BUILD:-"1.11.2-73b01f40"}
|
||||||
SOLC_VERSION=${SOLC_VERSION:-"0.8.19"}
|
SOLC_VERSION=${SOLC_VERSION:-"0.8.19"}
|
||||||
|
|
||||||
DIR="$HOME/bin"
|
BIN_DIR=${BIN_DIR:-"$HOME/bin"}
|
||||||
mkdir -p "$DIR"
|
BIN_DIR=$(realpath "$BIN_DIR")
|
||||||
cd "$DIR"
|
|
||||||
export PATH="$DIR:$PATH"
|
PLATFORM="$(uname -s | awk '{print tolower($0)}')"
|
||||||
if [ "$GITHUB_PATH" ]; then
|
if [ "$PLATFORM" != "linux" ] && [ "$PLATFORM" != "darwin" ]; then
|
||||||
echo "$DIR" >> "$GITHUB_PATH"
|
EXT=".exe"
|
||||||
echo "$HOME/.cargo/bin" >> "$GITHUB_PATH"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Installing Geth"
|
main() {
|
||||||
PLATFORM="$(uname -s | awk '{print tolower($0)}')"
|
mkdir -p "$BIN_DIR"
|
||||||
case "$PLATFORM" in
|
cd "$BIN_DIR"
|
||||||
|
export PATH="$BIN_DIR:$PATH"
|
||||||
|
if [ "$GITHUB_PATH" ]; then
|
||||||
|
echo "$BIN_DIR" >> "$GITHUB_PATH"
|
||||||
|
fi
|
||||||
|
|
||||||
|
install_geth &
|
||||||
|
install_solc &
|
||||||
|
wait
|
||||||
|
|
||||||
|
echo "Installed Geth:"
|
||||||
|
geth version
|
||||||
|
echo ""
|
||||||
|
echo "Installed Solc:"
|
||||||
|
solc --version
|
||||||
|
}
|
||||||
|
|
||||||
|
install_geth() {
|
||||||
|
case "$PLATFORM" in
|
||||||
linux|darwin)
|
linux|darwin)
|
||||||
GETH_ARCHIVE_NAME="geth-$PLATFORM-amd64-$GETH_BUILD"
|
GETH_ARCHIVE_NAME="geth-$PLATFORM-amd64-$GETH_BUILD"
|
||||||
curl "https://gethstore.blob.core.windows.net/builds/$GETH_ARCHIVE_NAME.tar.gz" | tar -xzvf -
|
curl "https://gethstore.blob.core.windows.net/builds/$GETH_ARCHIVE_NAME.tar.gz" | tar -xzvf -
|
||||||
|
@ -32,21 +50,18 @@ case "$PLATFORM" in
|
||||||
mv -f "$GETH_ARCHIVE_NAME/geth.exe" ./
|
mv -f "$GETH_ARCHIVE_NAME/geth.exe" ./
|
||||||
rm -rf "$GETH_ARCHIVE_NAME" "$zip"
|
rm -rf "$GETH_ARCHIVE_NAME" "$zip"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
geth version
|
install_solc() {
|
||||||
|
case "$PLATFORM" in
|
||||||
|
linux) SOLC_NAME="solc-static-linux";;
|
||||||
|
darwin) SOLC_NAME="solc-macos";;
|
||||||
|
*) SOLC_NAME="solc-windows.exe";;
|
||||||
|
esac
|
||||||
|
wget -q "https://github.com/ethereum/solidity/releases/download/v$SOLC_VERSION/$SOLC_NAME"
|
||||||
|
mv -f "$SOLC_NAME" "solc$EXT"
|
||||||
|
chmod +x "solc$EXT"
|
||||||
|
}
|
||||||
|
|
||||||
echo "Installing Solc"
|
main
|
||||||
cargo install --locked svm-rs
|
|
||||||
# install only if it doesn't exist already
|
|
||||||
if command -v solc; then
|
|
||||||
if [ -z "$(solc --version | grep "$SOLC_VERSION" || true)" ]; then
|
|
||||||
svm install "$SOLC_VERSION"
|
|
||||||
fi
|
|
||||||
svm use "$SOLC_VERSION"
|
|
||||||
fi
|
|
||||||
|
|
||||||
solc --version
|
|
||||||
|
|
||||||
which geth
|
|
||||||
which solc
|
|
||||||
|
|
Loading…
Reference in New Issue