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