Skip to content

Commit 81e8ebf

Browse files
authored
feat: Hardcode version into install scripts at release time. (#20986)
You can now install at a specific version with the less fiddly e.g.: ``` bash -i <(curl -sL https://install.aztec-labs.com/0.0.1-commit.c0b82b2) ``` * To avoid the fiddly requirement of setting both the `VERSION` env var, while also putting the version in the curl path, we now hardcode it at release time into the script. * The root installer, when manually uploaded, then sets the VERSION to default to nightly (if not given). * Carefully crafted banner and text to fit on 80 char width terminals. Because it's important we support those. * We add a `prune` command to aztec-up to remove all but current version. I may also have updated the ascii art a bit. I doubt I'll be allowed to keep it because it's so OUTRAGEOUSLY 80's neon cyberpunk. But it's trivial to swap the banner if want something more brand fitting.
2 parents 17a5afb + e44fe38 commit 81e8ebf

6 files changed

Lines changed: 197 additions & 49 deletions

File tree

aztec-up/bin/0.0.1/aztec-banner

Lines changed: 28 additions & 0 deletions
Large diffs are not rendered by default.

aztec-up/bin/0.0.1/aztec-banner-truecolor

Lines changed: 28 additions & 0 deletions
Large diffs are not rendered by default.

aztec-up/bin/0.0.1/aztec-install

Lines changed: 57 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@
55
# or: VERSION=0.85.0 bash -i <(curl -s https://install.aztec.network)
66
set -euo pipefail
77

8-
# Colors
9-
g="\033[32m" # Green
10-
y="\033[33m" # Yellow
11-
b="\033[34m" # Blue
12-
p="\033[35m" # Purple
8+
# Colors (truecolor with 256-color fallback)
139
r="\033[0m" # Reset
1410
bold="\033[1m"
11+
g="\033[38;5;114m" # green
12+
y="\033[38;5;222m" # yellow
13+
b="\033[38;5;111m" # blue
14+
p="\033[38;5;176m" # purple
15+
red="\033[38;5;203m" # red
16+
o="\033[38;5;214m" # orange
1517

1618
if [ ! -t 0 ]; then
1719
NON_INTERACTIVE=1
@@ -23,40 +25,66 @@ fi
2325
AZTEC_HOME="${AZTEC_HOME:-$HOME/.aztec}"
2426
shared_bin_path="$AZTEC_HOME/bin"
2527

26-
VERSION="${VERSION:-nightly}"
28+
VERSION=${VERSION:-0.0.1}
2729

2830
# Install URI (root, not version-specific)
2931
INSTALL_URI="${INSTALL_URI:-https://install.aztec-labs.com}"
3032

31-
# Add color to the AZTEC ascii art.
32-
function print_colored() {
33-
local b=$'\033[34m' # Blue
34-
local y=$'\033[33m' # Yellow
35-
local r=$'\033[0m' # Reset
36-
echo "$1" | sed -E "s/(█+)/${b}\1${y}/g"
33+
# Resolve alias (like "nightly") to actual version number.
34+
function resolve_version {
35+
local version="$1"
36+
local semver_regex='^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.-]+)?(\+[a-zA-Z0-9.]+)?$'
37+
if [[ "$version" =~ $semver_regex ]]; then
38+
echo "$version"
39+
else
40+
local resolved
41+
if ! resolved=$(curl -fsSL "$INSTALL_URI/aliases/$version" 2>/dev/null); then
42+
echo "Error: Could not resolve alias '$version'" >&2
43+
exit 1
44+
fi
45+
echo "$resolved"
46+
fi
47+
}
48+
49+
VERSION=$(resolve_version "$VERSION")
50+
51+
function typewriter {
52+
trap 'printf "${r}\n"; exit 1' INT
53+
local text="$1"
54+
local color="${2:-}"
55+
local delay="${3:-0.02}"
56+
local width=80
57+
local pad=$(( (width - ${#text}) / 2 ))
58+
printf "\r\033[2K%${pad}s${color}" ""
59+
for (( i=0; i<${#text}; i++ )); do printf '%s' "${text:$i:1}"; sleep "$delay"; done
60+
trap - INT
3761
}
3862

3963
function title {
4064
clear
65+
if [ "${COLORTERM:-}" = "truecolor" ] || [ "${COLORTERM:-}" = "24bit" ]; then
66+
curl -fsSL "$INSTALL_URI/$VERSION/aztec-banner-truecolor" 2>/dev/null || true
67+
else
68+
curl -fsSL "$INSTALL_URI/$VERSION/aztec-banner" 2>/dev/null || true
69+
fi
70+
typewriter "initializing stealth protocols..." "${p}"
71+
sleep 1
72+
typewriter "zk loaded." "${y}"
73+
sleep 1
74+
typewriter "privacy restored." "${g}${bold}"
75+
sleep 1
76+
printf "${r}\r"
77+
echo -e "Welcome to ${bold}${b}Aztec${r}! Your journey into blockchain privacy begins... ${bold}${p}now${r}."
4178
echo
42-
print_colored " █████╗ ███████╗████████╗███████╗ ██████╗"
43-
print_colored "██╔══██╗╚══███╔╝╚══██╔══╝██╔════╝██╔════╝"
44-
print_colored "███████║ ███╔╝ ██║ █████╗ ██║"
45-
print_colored "██╔══██║ ███╔╝ ██║ ██╔══╝ ██║"
46-
print_colored "██║ ██║███████╗ ██║ ███████╗╚██████╗"
47-
print_colored "╚═╝ ╚═╝╚══════╝ ╚═╝ ╚══════╝ ╚═════╝"
48-
echo -e "${r}"
49-
echo -e "Welcome to the ${bold}${b}Aztec${r} installer! Your journey into blockchain privacy begins... ${bold}${p}now${r}."
50-
echo
51-
echo -e "Installing version: ${bold}${g}$VERSION${r}"
79+
echo -e "Installing version: ${bold}${o}$VERSION${r}"
5280
echo
53-
echo -e "This install script will install the following and update your PATH if necessary:"
54-
echo -e " ${bold}${g}nargo${r} - the version of the noir programming language compatible with this version of aztec."
55-
echo -e " ${bold}${g}noir-profiler${r} - a sampling profiler for analyzing and visualizing Noir programs."
56-
echo -e " ${bold}${g}bb${r} - the version of the barretenberg proving backend compatible with this version of aztec."
57-
echo -e " ${bold}${g}aztec${r} - a collection of tools to compile and test contracts, to launch subsystems and interact with the aztec network."
58-
echo -e " ${bold}${g}aztec-up${r} - a tool to install and manage aztec toolchain versions."
59-
echo -e " ${bold}${g}aztec-wallet${r} - our minimalistic CLI wallet"
81+
echo -e "This script installs the following and updates your PATH if necessary:"
82+
echo -e " ${bold}${g}nargo${r} - the noir programming language compiler and simulator."
83+
echo -e " ${bold}${g}noir-profiler${r} - a profiler for analyzing and visualizing noir programs."
84+
echo -e " ${bold}${g}bb${r} - the barretenberg proving backend."
85+
echo -e " ${bold}${g}aztec${r} - compiles and tests contracts, interacts with the network."
86+
echo -e " ${bold}${g}aztec-up${r} - installs and manages aztec toolchain versions."
87+
echo -e " ${bold}${g}aztec-wallet${r} - a minimalistic wallet cli."
6088
echo
6189
read -p "Do you wish to continue? (y/n) " -n 1 -r
6290
echo

aztec-up/bin/0.0.1/aztec-up

Lines changed: 65 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ function help {
3737
echo " use [<version>] Switch to an installed version (or read from .aztecrc)"
3838
echo " list List installed versions"
3939
echo " uninstall <version> Remove an installed version"
40+
echo " prune Remove all versions except the current one"
4041
echo " self-update Update aztec-up itself to the latest version"
4142
echo " env Output PATH for .aztecrc version (for eval)"
4243
echo
@@ -159,7 +160,7 @@ function cmd_install {
159160
fi
160161

161162
# Download and run the version-specific installer
162-
curl -fsSL "$install_url" | VERSION="$resolved_version" bash
163+
curl -fsSL "$install_url" | bash
163164

164165
# Update the current symlink
165166
ln -sfn "$AZTEC_HOME/versions/$resolved_version" "$AZTEC_HOME/current"
@@ -328,6 +329,68 @@ function cmd_uninstall {
328329
echo_green "Uninstalled version $version"
329330
}
330331

332+
# Remove all versions except the current one
333+
function cmd_prune {
334+
if [[ "${1:-}" == "-h" || "${1:-}" == "--help" ]]; then
335+
echo "Remove all installed versions except the currently active one"
336+
echo
337+
echo "Usage: aztec-up prune"
338+
echo
339+
echo "Options:"
340+
echo " -h, --help Print help"
341+
echo
342+
echo "Examples:"
343+
echo " aztec-up prune # Remove all versions except current"
344+
return 0
345+
fi
346+
347+
local current_version
348+
current_version=$(get_current_version)
349+
350+
if [ -z "$current_version" ]; then
351+
echo "Error: No version is currently active. Use 'aztec-up use <version>' first."
352+
exit 1
353+
fi
354+
355+
# Collect versions to remove
356+
local to_remove=()
357+
for dir in "$AZTEC_HOME/versions"/*/; do
358+
[ -d "$dir" ] || continue
359+
local version
360+
version=$(basename "$dir")
361+
if [ "$version" != "$current_version" ]; then
362+
to_remove+=("$version")
363+
fi
364+
done
365+
366+
if [ ${#to_remove[@]} -eq 0 ]; then
367+
echo "Nothing to prune. Only the current version ($current_version) is installed."
368+
return 0
369+
fi
370+
371+
echo "Current version: $current_version"
372+
echo
373+
echo "The following versions will be removed:"
374+
for version in "${to_remove[@]}"; do
375+
echo " $version"
376+
done
377+
echo
378+
379+
read -p "Continue? (y/n) " -n 1 -r
380+
echo
381+
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
382+
echo "Aborted."
383+
return 0
384+
fi
385+
386+
for version in "${to_remove[@]}"; do
387+
rm -rf "$AZTEC_HOME/versions/$version"
388+
echo "Removed $version"
389+
done
390+
391+
echo_green "Pruned all versions except $current_version"
392+
}
393+
331394
# Update aztec-up itself
332395
function cmd_self-update {
333396
if [[ "${1:-}" == "-h" || "${1:-}" == "--help" ]]; then
@@ -417,7 +480,7 @@ function main {
417480
""|-h|--help)
418481
help
419482
;;
420-
install|use|list|uninstall|self-update|env)
483+
install|use|list|uninstall|prune|self-update|env)
421484
cmd_$cmd "$@"
422485
;;
423486
*)

aztec-up/bin/0.0.1/install

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@
55
set -euo pipefail
66

77
# Colors
8-
r="\033[31m" # Red
9-
g="\033[32m" # Green
10-
y="\033[33m" # Yellow
11-
b="\033[34m" # Blue
128
reset="\033[0m"
9+
g="\033[38;5;114m" # green
10+
y="\033[38;5;222m" # yellow
11+
b="\033[38;5;111m" # blue
12+
p="\033[38;5;176m" # purple
13+
r="\033[38;5;203m" # red
1314

1415
# Helper function to safely read version from versions file
1516
function get_version {
@@ -24,7 +25,7 @@ function get_version {
2425
}
2526

2627
# Required environment variables
27-
VERSION="${VERSION:?VERSION must be set}"
28+
VERSION=0.0.1
2829
AZTEC_HOME="${AZTEC_HOME:-$HOME/.aztec}"
2930
INSTALL_URI="${INSTALL_URI:-https://install.aztec-labs.com}"
3031

@@ -211,8 +212,8 @@ function main {
211212
dump_fail install_node
212213
echo_green "done."
213214

214-
# Source nvm to ensure node is in PATH.
215-
. "$HOME/.nvm/nvm.sh"
215+
# Source nvm to ensure node is in PATH (if using nvm).
216+
[ -f "$HOME/.nvm/nvm.sh" ] && . "$HOME/.nvm/nvm.sh"
216217

217218
# Install noir
218219
echo -n "Installing nargo... "

aztec-up/bootstrap.sh

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -109,22 +109,23 @@ function release {
109109
echo_header "aztec-up release"
110110
local version=${REF_NAME#v}
111111

112-
# Upload version-specific files to version directory.
113-
do_or_dryrun aws s3 cp bin/0.0.1/install "s3://install.aztec.network/$version/install"
114-
do_or_dryrun aws s3 cp bin/0.0.1/versions "s3://install.aztec.network/$version/versions"
115-
do_or_dryrun aws s3 cp bin/0.0.1/aztec-install "s3://install.aztec.network/$version/aztec-install"
116-
do_or_dryrun aws s3 cp bin/0.0.1/aztec-up "s3://install.aztec.network/$version/aztec-up"
112+
# Upload each file in bin/0.0.1/, replacing VERSION= lines with the release version.
113+
for file in bin/0.0.1/*; do
114+
sed "s/^VERSION=.*/VERSION=$version/" "$file" | \
115+
do_or_dryrun aws s3 cp - "s3://install.aztec.network/$version/$(basename $file)"
116+
done
117117

118118
# Update alias to point to new version.
119-
# This has real impact outside of the version fence. i.e. if it's nightly dist tag, it affects nightly installs.
119+
# This has real impact outside of the version fence. i.e. if it's a nightly dist tag, it affects nightly installs.
120120
do_or_dryrun aws s3 cp - "s3://install.aztec.network/aliases/$(dist_tag)" <<< "$version"
121121
}
122122

123123
# This is not done by CI.
124124
# It's a manual process, as updating the root installer and alias index requires careful consideration.
125-
function release_aztec_up {
126-
# Update root scripts.
127-
do_or_dryrun aws s3 cp bin/0.0.1/aztec-install "s3://install.aztec.network/aztec-install"
125+
function release_root_installer {
126+
# Upload root aztec-install with VERSION defaulting to nightly (instead of local 0.0.1).
127+
sed "s/^VERSION=.*/VERSION=\${VERSION:-nightly}/" bin/0.0.1/aztec-install | \
128+
do_or_dryrun aws s3 cp - "s3://install.aztec.network/aztec-install"
128129
do_or_dryrun aws s3 cp bin/0.0.1/aztec-up "s3://install.aztec.network/aztec-up"
129130

130131
# Update alias list.
@@ -198,15 +199,14 @@ function install_on_mac_vm {
198199
export npm_config_registry=http://$host_ip:$verdaccio_port
199200
export INSTALL_URI=http://$host_ip:$http_port
200201
export NO_NEW_SHELL=1
201-
export NON_INTERACTIVE=1
202202
203203
touch \$HOME/.zshrc
204204
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.4/install.sh | bash
205205
. "\$HOME/.nvm/nvm.sh"
206206
207207
echo
208208
echo "Running aztec install script..."
209-
VERSION=0.0.1 bash <(curl -sL \$INSTALL_URI/0.0.1/aztec-install)
209+
bash <(curl -sL \$INSTALL_URI/0.0.1/aztec-install)
210210
211211
# Fake fresh shell.
212212
export PATH="\$HOME/.aztec/current/bin:\$HOME/.aztec/current/node_modules/.bin:\$HOME/.aztec/bin:\$PATH"

0 commit comments

Comments
 (0)