Skip to content

Commit 392563c

Browse files
authored
feat: aztec-up can be used to manage multiple aztec versions (#19261)
`aztec-up` can be used to manage multiple versions. ``` $ aztec-up aztec-up - Aztec version manager Usage: aztec-up [command] [options] Commands: install <version> Install a version and switch to it use [<version>] Switch to an installed version (or read from .aztecrc) list List installed versions uninstall <version> Remove an installed version self-update Update aztec-up itself to the latest version Options: -h, --help Show this help message Examples: aztec-up install Install the latest version aztec-up install nightly Install the latest nightly version aztec-up install 0.85.0 Install a specific version aztec-up use 0.85.0 Switch to version 0.85.0 aztec-up use Read version from .aztecrc and switch to it aztec-up list Show all installed versions aztec-up self-update Update aztec-up to latest ``` If a `.aztecrc` file is present in the cwd, `aztec` will automatically switch to that version in that run context. ``` t % aztec --version 0.0.1-commit.1142ef1 t % cd fooproj t % cat .aztecrc 0.0.1-commit.6d3c34e t % aztec --version 0.0.1-commit.6d3c34e t % ``` # Testing You can install `aztec-up` with: ``` VERSION=0.0.1-commit.6d3c34e bash -i <(curl -s https://install.aztec.network/0.0.1-commit.6d3c34e/aztec-install) ``` At present you can't list available remote versions. The code does currently support listing available remote aliases, but they're not deployed yet. You can install another version with e.g. ``` aztec-up install 0.0.1-commit.1142ef1 ``` Then list versions with: ``` t % aztec-up list Installed versions: * 0.0.1-commit.1142ef1 (current) 0.0.1-commit.6d3c34e Aliases: (could not fetch aliases) ```
2 parents 11f2ba8 + f69c7bf commit 392563c

File tree

21 files changed

+661
-279
lines changed

21 files changed

+661
-279
lines changed

.github/ci3.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ function handle_release_pr {
7777
git tag "${tag_name}"
7878
git push origin "${tag_name}"
7979
echo "Created and pushed tag: ${tag_name}"
80+
gh pr edit $PR_NUMBER --remove-label ci-release-pr || true
8081
}
8182

8283
function main {

aztec-up/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.terraform
22
.terraform*
33
.DS_Store
4-
bin/versions
4+
bin/0.0.1/versions
55
verdaccio-storage
66
aztec-release-test-image

aztec-up/bin/0.0.1/install

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
#!/usr/bin/env bash
2+
# Per-version installer script
3+
# This script is called by aztec-up to install a specific version of the Aztec toolchain.
4+
# It expects VERSION and INSTALL_URI to be set.
5+
set -euo pipefail
6+
shopt -s inherit_errexit
7+
8+
# Colors
9+
g="\033[32m" # Green
10+
y="\033[33m" # Yellow
11+
b="\033[34m" # Blue
12+
r="\033[0m" # Reset
13+
14+
# Required environment variables
15+
VERSION="${VERSION:?VERSION must be set}"
16+
AZTEC_HOME="${AZTEC_HOME:-$HOME/.aztec}"
17+
INSTALL_URI="${INSTALL_URI:-https://install.aztec.network}"
18+
19+
# Version-specific paths
20+
version_path="$AZTEC_HOME/versions/$VERSION"
21+
version_bin_path="$version_path/bin"
22+
23+
function echo_green {
24+
echo -e "${g}$1${r}"
25+
}
26+
27+
function echo_yellow {
28+
echo -e "${y}$1${r}"
29+
}
30+
31+
function dump_fail {
32+
output=$(mktemp)
33+
34+
set +e
35+
($1) &>$output
36+
status=$?
37+
set -e
38+
39+
# 0 or SIGTERM considered a success.
40+
if [ "$status" -ne 0 ] && [ "$status" -ne 143 ]; then
41+
{
42+
echo
43+
echo -e "${y}command failed${r}: $1 (exit: $status)"
44+
echo -e "${b}--- output ---${r}"
45+
cat $output
46+
} >&2
47+
fi
48+
49+
rm $output
50+
51+
return $status
52+
}
53+
54+
function check_toolchains {
55+
# Check Node.js version.
56+
local node_min_version=$(cat "$version_path/versions" | grep node | cut -d' ' -f2)
57+
local node_installed_version=$(node --version 2>/dev/null | cut -d 'v' -f 2 || echo "none")
58+
if [[ "$(printf '%s\n' "$node_min_version" "$node_installed_version" | sort -V | head -n1)" != "$node_min_version" ]]; then
59+
echo "Minimum Node.js version $node_min_version not found (got $node_installed_version)."
60+
echo "Installation: nvm install --lts && nvm alias default lts/*"
61+
exit 1
62+
fi
63+
}
64+
65+
function install_versions_file {
66+
# Determine the correct URI for fetching the versions file
67+
local versions_uri="$INSTALL_URI"
68+
curl -fsSL "$versions_uri/$VERSION/versions" -o "$version_path/versions"
69+
}
70+
71+
function install_noir {
72+
local noir_version=$(cat "$version_path/versions" | grep noir | cut -d' ' -f2)
73+
74+
# Create a temp directory for noirup to install to
75+
local temp_nargo_home=$(mktemp -d)
76+
mkdir -p "$temp_nargo_home/bin"
77+
78+
# Install noirup if not already present
79+
if [ ! -f "$HOME/.nargo/bin/noirup" ]; then
80+
curl -Ls https://raw.githubusercontent.com/noir-lang/noirup/refs/heads/main/install | bash
81+
fi
82+
83+
# Install noir to temp location and move to version directory
84+
NARGO_HOME="$temp_nargo_home" "$HOME/.nargo/bin/noirup" -v "$noir_version"
85+
86+
# Move the nargo binary to our version bin directory
87+
mv "$temp_nargo_home/bin/nargo" "$version_bin_path/nargo"
88+
89+
# Cleanup temp directory
90+
rm -rf "$temp_nargo_home"
91+
}
92+
93+
function install_foundry {
94+
local foundry_version=$(cat "$version_path/versions" | grep foundry | cut -d' ' -f2)
95+
96+
# Create a temp directory for foundryup to install to
97+
local temp_foundry_dir=$(mktemp -d)
98+
mkdir -p "$temp_foundry_dir/bin"
99+
100+
# Install foundryup if not already present
101+
if [ ! -f "$HOME/.foundry/bin/foundryup" ]; then
102+
curl -L https://foundry.paradigm.xyz | bash
103+
fi
104+
105+
# Install foundry to temp location and move to version directory
106+
FOUNDRY_DIR="$temp_foundry_dir" "$HOME/.foundry/bin/foundryup" -i "$foundry_version"
107+
108+
# Move the foundry binaries to our version bin directory
109+
for binary in forge cast anvil chisel; do
110+
if [ -f "$temp_foundry_dir/bin/$binary" ]; then
111+
mv "$temp_foundry_dir/bin/$binary" "$version_bin_path/$binary"
112+
fi
113+
done
114+
115+
# Cleanup temp directory
116+
rm -rf "$temp_foundry_dir"
117+
}
118+
119+
function install_aztec_packages {
120+
# Install npm packages to the version directory using --prefix
121+
npm install @aztec/aztec@$VERSION @aztec/cli-wallet@$VERSION @aztec/bb.js@$VERSION --prefix "$version_path"
122+
}
123+
124+
function main {
125+
# Create version directory
126+
mkdir -p "$version_bin_path"
127+
128+
# Download versions manifest
129+
echo -n "Installing version manifest... "
130+
dump_fail install_versions_file
131+
echo_green "done."
132+
133+
# Check Node.js version
134+
check_toolchains
135+
136+
# Install noir
137+
echo -n "Installing nargo... "
138+
dump_fail install_noir
139+
echo_green "done."
140+
141+
# Install foundry
142+
echo -n "Installing foundry... "
143+
dump_fail install_foundry
144+
echo_green "done."
145+
146+
# Install aztec npm packages
147+
echo -n "Installing aztec packages... "
148+
dump_fail install_aztec_packages
149+
echo_green "done."
150+
}
151+
152+
main "$@"

aztec-up/bin/aliases/index

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
latest
2+
nightly

aztec-up/bin/aliases/latest

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.0.1

aztec-up/bin/aliases/nightly

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.0.1

0 commit comments

Comments
 (0)