update install scripts
This commit is contained in:
parent
0dae705a20
commit
c041d51c59
17
install.ps1
17
install.ps1
|
@ -8,6 +8,7 @@ $REPO = "moritz-hoelting/shulkerscript-cli"
|
|||
$PROGRAM_DISPLAY_NAME = "Shulkerscript CLI"
|
||||
$LATEST_RELEASE_URL = "https://api.github.com/repos/$REPO/releases/latest"
|
||||
$BIN_NAME = "shulkerscript"
|
||||
$CRATE_NAME = "shulkerscript-cli"
|
||||
$INSTALL_PATH = Join-Path $env:USERPROFILE "AppData\Local\Programs\$BIN_NAME"
|
||||
$PATH_REGISTRY = "Registry::HKEY_CURRENT_USER\Environment"
|
||||
|
||||
|
@ -28,7 +29,7 @@ if ($ARCH -eq 'AMD64') {
|
|||
$ARCH = 'i686'
|
||||
} else {
|
||||
Write-Host "Unsupported architecture: $ARCH" -ForegroundColor Red
|
||||
exit 1
|
||||
return "Error"
|
||||
}
|
||||
|
||||
# Fetch the latest release data from GitHub
|
||||
|
@ -37,7 +38,7 @@ try {
|
|||
}
|
||||
catch {
|
||||
Write-Host "Failed to fetch latest release data." -ForegroundColor Red
|
||||
exit 1
|
||||
return "Error"
|
||||
}
|
||||
|
||||
# Get the latest version number
|
||||
|
@ -52,7 +53,7 @@ if (Get-Command $BIN_NAME -ErrorAction Ignore) {
|
|||
|
||||
if ($INSTALLED_VERSION -eq $CLEAN_LATEST_VERSION) {
|
||||
Write-Host "$PROGRAM_DISPLAY_NAME is already up to date."
|
||||
exit 0
|
||||
return
|
||||
}
|
||||
else {
|
||||
Write-Host "A new version is available. Upgrading..."
|
||||
|
@ -66,9 +67,9 @@ else {
|
|||
# Use cargo-binstall if available
|
||||
if (Get-Command cargo-binstall -ErrorAction SilentlyContinue) {
|
||||
Write-Host "cargo-binstall is available. Installing/upgrading using cargo-binstall..."
|
||||
cargo-binstall --git "https://github.com/$REPO" --force --locked --no-confirm $BIN_NAME
|
||||
cargo-binstall --git "https://github.com/$REPO" --force --locked --no-confirm $CRATE_NAME
|
||||
Remove-Old-Version
|
||||
exit 0
|
||||
return
|
||||
}
|
||||
|
||||
# Get the download url of the latest release
|
||||
|
@ -78,13 +79,13 @@ if ([string]::IsNullOrEmpty($DOWNLOAD_URL)) {
|
|||
# if there is no prebuilt binary, try to build from source
|
||||
if (Get-Command cargo -ErrorAction SilentlyContinue) {
|
||||
Write-Host "No prebuilt binary available for your platform. Building from source..."
|
||||
cargo install --git "https://github.com/$REPO" --force --locked
|
||||
cargo install --force --locked $CRATE_NAME
|
||||
Remove-Old-Version
|
||||
exit 0
|
||||
return
|
||||
}
|
||||
else {
|
||||
Write-Host "No prebuilt binary available for your platform. Please install Rust and Cargo using https://rustup.rs and try again."
|
||||
exit 1
|
||||
return "Error"
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ REPO="moritz-hoelting/shulkerscript-cli"
|
|||
PROGRAM_DISPLAY_NAME="Shulkerscript CLI"
|
||||
LATEST_RELEASE_URL="https://api.github.com/repos/$REPO/releases/latest"
|
||||
BIN_NAME="shulkerscript"
|
||||
CRATE_NAME="shulkerscript-cli"
|
||||
INSTALL_PATH="$HOME/bin/$BIN_NAME"
|
||||
|
||||
function removeOldVersion() {
|
||||
|
@ -48,7 +49,7 @@ fi
|
|||
# Use cargo-binstall if available
|
||||
if which cargo-binstall &> /dev/null; then
|
||||
echo "Found cargo-binstall. Installing/upgrading using cargo-binstall..."
|
||||
cargo-binstall --git "https://github.com/$REPO" --force --locked --no-confirm $BIN_NAME
|
||||
cargo-binstall --git "https://github.com/$REPO" --force --locked --no-confirm $CRATE_NAME
|
||||
|
||||
# Remove old version
|
||||
removeOldVersion
|
||||
|
@ -62,7 +63,7 @@ if [ -z "$DOWNLOAD_URL" ]; then
|
|||
# if there is no prebuilt binary, try to build from source
|
||||
if which cargo &> /dev/null; then
|
||||
echo "No prebuilt binary available for your platform. Building from source..."
|
||||
cargo install --git "https://github.com/$REPO" --force --locked
|
||||
cargo install --force --locked $CRATE_NAME
|
||||
removeOldVersion
|
||||
exit 0
|
||||
else
|
||||
|
|
Loading…
Reference in New Issue