Skip to content

Commit 92fefaf

Browse files
authored
feat(foundryup): add foundryup self-update (#9609)
* feat(foundryup):: add self-update Signed-off-by: 9547 <[email protected]> * renmae to --update Signed-off-by: 9547 <[email protected]> * download to tmp file first Signed-off-by: 9547 <[email protected]> --------- Signed-off-by: 9547 <[email protected]>
1 parent e7a0693 commit 92fefaf

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

foundryup/foundryup

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ FOUNDRY_DIR=${FOUNDRY_DIR:-"$BASE_DIR/.foundry"}
66
FOUNDRY_VERSIONS_DIR="$FOUNDRY_DIR/versions"
77
FOUNDRY_BIN_DIR="$FOUNDRY_DIR/bin"
88
FOUNDRY_MAN_DIR="$FOUNDRY_DIR/share/man/man1"
9+
FOUNDRY_BIN_URL="https://raw.githubusercontent.com/foundry-rs/foundry/master/foundryup/foundryup"
10+
FOUNDRY_BIN_PATH="$FOUNDRY_BIN_DIR/foundryup"
911

1012
FOUNDRYUP_JOBS=""
1113

@@ -30,6 +32,7 @@ main() {
3032
-P|--pr) shift; FOUNDRYUP_PR=$1;;
3133
-C|--commit) shift; FOUNDRYUP_COMMIT=$1;;
3234
-j|--jobs) shift; FOUNDRYUP_JOBS=$1;;
35+
-U|--update) shift; update;;
3336
--arch) shift; FOUNDRYUP_ARCH=$1;;
3437
--platform) shift; FOUNDRYUP_PLATFORM=$1;;
3538
-h|--help)
@@ -260,6 +263,7 @@ OPTIONS:
260263
-r, --repo Build and install from a remote GitHub repo (uses default branch if no other options are set)
261264
-p, --path Build and install a local repository
262265
-j, --jobs Number of CPUs to use for building Foundry (default: all CPUs)
266+
-U, --update Update foundryup to the latest version
263267
--arch Install a specific architecture (supports amd64 and arm64)
264268
--platform Install a specific platform (supports win32, linux, and darwin)
265269
EOF
@@ -300,6 +304,21 @@ use() {
300304
fi
301305
}
302306

307+
update() {
308+
say "updating foundryup..."
309+
310+
# Download to a temporary file first
311+
tmp_file="$(mktemp)"
312+
ensure download "$FOUNDRY_BIN_URL" "$tmp_file"
313+
314+
# Replace the current foundryup with the downloaded file
315+
ensure mv "$tmp_file" "$FOUNDRY_BIN_PATH"
316+
ensure chmod +x "$FOUNDRY_BIN_PATH"
317+
318+
say "successfully updated foundryup"
319+
exit 0
320+
}
321+
303322
say() {
304323
printf "foundryup: %s\n" "$1"
305324
}

0 commit comments

Comments
 (0)