-
Notifications
You must be signed in to change notification settings - Fork 129
/
install-foundry-zksync
executable file
·62 lines (49 loc) · 2.12 KB
/
install-foundry-zksync
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
#!/bin/bash
set -e
# URLs to the raw files on GitHub
INSTALL_SCRIPT_URL="https://raw.githubusercontent.com/matter-labs/foundry-zksync/main/foundryup-zksync/install"
FOUNDRYUP_ZKSYNC_URL="https://raw.githubusercontent.com/matter-labs/foundry-zksync/main/foundryup-zksync/foundryup-zksync"
# Download the install script
echo "Downloading the install script..."
curl -L "$INSTALL_SCRIPT_URL" -o install
echo "Making install script executable..."
chmod +x ./install
echo "Running the installation script..."
./install | tee install.log # Capture the output to both stdout and a log file
# Extract the exact path from the install.log
# Use sed to precisely capture the path after 'source' and before the next apostrophe
SHELL_CONFIG_FILE=$(sed -n "s/.*Run 'source \(.*\)'.*/\1/p" install.log)
if [ -n "$SHELL_CONFIG_FILE" ]; then
if [ -n "${CI}" ]; then
# Add manually to $PATH in CI mode as GHA does not work with `.`
FOUNDRY_BIN_DIR="${XDG_CONFIG_HOME:-$HOME}/.foundry/bin"
echo "adding '${FOUNDRY_BIN_DIR}' to PATH and GITHUB_PATH"
export PATH="$PATH:$FOUNDRY_BIN_DIR"
echo "${FOUNDRY_BIN_DIR}" >> $GITHUB_PATH
else
echo "Sourcing the shell configuration file: '$SHELL_CONFIG_FILE'"
# Use dot (.) to source the file, which is more universally compatible
. "$SHELL_CONFIG_FILE"
fi
else
echo "No shell configuration file detected. Please source your shell manually or start a new terminal session."
fi
echo "Downloading foundryup-zksync..."
curl -L "$FOUNDRYUP_ZKSYNC_URL" -o foundryup-zksync
echo "Making foundryup-zksync executable..."
chmod +x ./foundryup-zksync
echo "Running foundryup-zksync setup..."
./foundryup-zksync
# Cleanup: remove install and install.log
# Keeps foundryup-zksync for ease of use
echo "Cleaning up installation artifacts..."
rm -f ./install ./install.log
echo "Cleanup completed."
echo "Installation completed successfully!"
echo "Verifying installation..."
if forge --version | grep -q "0.0.2"; then
echo "Forge version 0.0.2 is successfully installed."
else
echo "Installation verification failed. Forge is not properly installed."
exit 1
fi