diff --git a/README.md b/README.md index b154fd8..9347171 100644 --- a/README.md +++ b/README.md @@ -98,47 +98,36 @@ The artifacts are uploaded both as workflow artifacts and automatically added to For reproducible installs, prefer a release tag (or commit SHA) instead of the mutable `main` branch. Replace every `` placeholder below with the same release tag, including the `v` prefix (for example `v1.3.0`). -The examples download the script first so you can review it before executing. +The commands below stream the script directly into the shell / PowerShell, so no temporary script download is required. You can additionally set `SORT_IT_NOW_VERSION=` to instruct the install scripts to download that specific release. - Linux / macOS install: ```bash - curl -fsSLo /tmp/sort-it-now-install-unix.sh \ - https://raw.githubusercontent.com/JosunLP/sort-it-now//scripts/install-unix.sh - chmod +x /tmp/sort-it-now-install-unix.sh - SORT_IT_NOW_VERSION= /tmp/sort-it-now-install-unix.sh + curl -fsSL https://raw.githubusercontent.com/JosunLP/sort-it-now//scripts/install-unix.sh | SORT_IT_NOW_VERSION= bash ``` - Linux / macOS uninstall: ```bash - curl -fsSLo /tmp/sort-it-now-uninstall-unix.sh \ - https://raw.githubusercontent.com/JosunLP/sort-it-now//scripts/uninstall-unix.sh - chmod +x /tmp/sort-it-now-uninstall-unix.sh - /tmp/sort-it-now-uninstall-unix.sh + curl -fsSL https://raw.githubusercontent.com/JosunLP/sort-it-now//scripts/uninstall-unix.sh | bash ``` -- Windows install (PowerShell): +- Windows install (PowerShell, run as Administrator for the default destination under `%ProgramFiles%`): ```powershell - $version = "" - $script = Join-Path $env:TEMP "sort-it-now-install-windows.ps1" - irm "https://raw.githubusercontent.com/JosunLP/sort-it-now/$version/scripts/install-windows.ps1" -OutFile $script - $env:SORT_IT_NOW_VERSION = $version - & $script + $env:SORT_IT_NOW_VERSION=""; irm "https://raw.githubusercontent.com/JosunLP/sort-it-now//scripts/install-windows.ps1" | iex ``` - Windows uninstall (PowerShell): ```powershell - $version = "" - $script = Join-Path $env:TEMP "sort-it-now-uninstall-windows.ps1" - irm "https://raw.githubusercontent.com/JosunLP/sort-it-now/$version/scripts/uninstall-windows.ps1" -OutFile $script - & $script + irm "https://raw.githubusercontent.com/JosunLP/sort-it-now//scripts/uninstall-windows.ps1" | iex ``` -Both installer scripts also continue to work locally from an extracted release bundle. Set `INSTALL_DIR` (Unix) or `-Destination` (PowerShell) to override the default target. +If you prefer to review the script before execution, you can still download it manually first. + +Both installer scripts also continue to work locally from an extracted release bundle. Set `INSTALL_DIR` (Unix) or `-Destination` (PowerShell, for example `"$env:LOCALAPPDATA\Programs\sort-it-now"` for a per-user install) to override the default target. ### Archive Installation Scripts diff --git a/scripts/install-unix.sh b/scripts/install-unix.sh index ed89094..8d9c0ef 100644 --- a/scripts/install-unix.sh +++ b/scripts/install-unix.sh @@ -8,10 +8,10 @@ OWNER="${SORT_IT_NOW_GITHUB_OWNER:-JosunLP}" REPO="${SORT_IT_NOW_GITHUB_REPO:-sort-it-now}" REQUESTED_VERSION="${SORT_IT_NOW_VERSION:-latest}" SCRIPT_SOURCE="${BASH_SOURCE[0]:-}" -SCRIPT_DIR="$PWD" +SCRIPT_DIR="" DOWNLOAD_TMP_DIR="" -if [[ -n "$SCRIPT_SOURCE" && -e "$SCRIPT_SOURCE" ]]; then +if [[ -n "$SCRIPT_SOURCE" && -f "$SCRIPT_SOURCE" ]]; then SCRIPT_DIR="$(cd "$(dirname "$SCRIPT_SOURCE")" && pwd)" fi @@ -155,8 +155,12 @@ download_and_install_latest_release() { INSTALL_DIR="$INSTALL_DIR" bash "$bundle_dir/install.sh" } -BINARY_PATH="$SCRIPT_DIR/$APP_NAME" -if [[ -f "$BINARY_PATH" ]]; then +BINARY_PATH="" +if [[ -n "$SCRIPT_DIR" ]]; then + BINARY_PATH="$SCRIPT_DIR/$APP_NAME" +fi + +if [[ -n "$BINARY_PATH" && -f "$BINARY_PATH" ]]; then install_local_binary "$BINARY_PATH" else download_and_install_latest_release diff --git a/scripts/install-windows.ps1 b/scripts/install-windows.ps1 index 66a6c27..0112389 100644 --- a/scripts/install-windows.ps1 +++ b/scripts/install-windows.ps1 @@ -6,8 +6,9 @@ $ErrorActionPreference = "Stop" $Owner = if ($env:SORT_IT_NOW_GITHUB_OWNER) { $env:SORT_IT_NOW_GITHUB_OWNER } else { "JosunLP" } $Repo = if ($env:SORT_IT_NOW_GITHUB_REPO) { $env:SORT_IT_NOW_GITHUB_REPO } else { "sort-it-now" } $RequestedVersion = if ($env:SORT_IT_NOW_VERSION) { $env:SORT_IT_NOW_VERSION } else { "latest" } -$scriptDir = if ($MyInvocation.MyCommand.Path) { Split-Path -Parent $MyInvocation.MyCommand.Path } else { (Get-Location).Path } -$binaryPath = Join-Path $scriptDir "sort_it_now.exe" +$scriptPath = $MyInvocation.MyCommand.Path +$scriptDir = if ($scriptPath) { Split-Path -Parent $scriptPath } else { $null } +$binaryPath = if ($scriptDir) { Join-Path $scriptDir "sort_it_now.exe" } else { $null } function Test-IsAdministrator { $currentIdentity = [Security.Principal.WindowsIdentity]::GetCurrent() @@ -202,7 +203,7 @@ function Install-FromRelease { } } -if (Test-Path $binaryPath) { +if ($binaryPath -and (Test-Path $binaryPath)) { Install-LocalBinary -BinaryPath $binaryPath -TargetDirectory $Destination -ReadmeSource (Join-Path $scriptDir "README.md") } else {