Skip to content
This repository has been archived by the owner on Sep 12, 2024. It is now read-only.

Commit

Permalink
Merge pull request #26 from devklick/feature/#24-UpdatingGDMan
Browse files Browse the repository at this point in the history
#24 - Refactor install/update scripts
  • Loading branch information
devklick authored Aug 9, 2024
2 parents 6ee53fe + 2794c08 commit b6c745a
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 26 deletions.
25 changes: 16 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
<br/>
<br/>

> [!WARNING]
> This project is WIP
## Motivation

While working with Godot on Linux, I find it a chore having to download new versions,
Expand All @@ -22,10 +19,10 @@ I wanted a way to simply run a command and have all this happen behind the scene

And that's exactly what GDMan does!

## Installing GDMan
## Installing/Updating GDMan

GDMan can be installed either by manually carrying out a few simple steps or running
one of the install scripts.
one of the install scripts. The same process can be used for updating to the latest version.

<details>
<summary>Manual Install</summary>
Expand Down Expand Up @@ -96,10 +93,20 @@ Once you have GDMan installed, you should be able to invoke the following two co

- `gdman` - for managing versions of Godot
- `godot` - to run the currently-active version of Godot
<br/>
**Note that the latter will not exist until you first install a version of Godot via GDMan**
<br/>
**Note that on Windows, you may need to use `godot.lnk` rather than just `godot`**

**Note** that the latter will not exist until you first install a version of Godot via GDMan
<br/>
**Note** that on Windows, you may need to use `godot.lnk` rather than just `godot`

### Installation Locations

If you use the install scripts, GDMan will be installed in:

- (Windows) - `C:\Users\user\gdman`
- (Linux / macOS) - `/home/user/gdman`

Note that each version of Godot you install install using GDMan can be found
within the above directory, in a folder called `versions`.

## Installing versions of Godot

Expand Down
40 changes: 24 additions & 16 deletions install/install-unix.sh
Original file line number Diff line number Diff line change
@@ -1,35 +1,43 @@
#!/bin/bash

target_os=$1
zip_path="$HOME/Downloads/gdman.zip"
install_dir="$HOME/gdman"
t=$1
z="$HOME/Downloads/gdman.zip"
d="$HOME/gdman"

# Find the latest release for the target OS
echo "Finding latest version"
download_url=$(curl -s https://api.github.com/repos/devklick/GDMan/releases/latest | jq -r '.assets[] | select(.name | test("'${target_os}'")) | .browser_download_url')
echo "Found $download_url";
echo Finding latest version
r=$(curl -s https://api.github.com/repos/devklick/GDMan/releases/latest)
u=$(echo "$r" | jq -r --arg t "$t" '.assets[] | select(.name | test($t)) | .browser_download_url')
v=$(echo "$r" | jq -r '.tag_name')
echo Found $v;

# Download the zip file to the Downloads directory
echo "Downloading"
wget -q "$download_url" -O "$zip_path"
echo Downloading
wget -q "$u" -O "$z"

# Extract the contents of the zip file to the installation directory
echo "Extracting"
unzip -qq -o "$zip_path" -d "$install_dir"
echo Extracting
unzip -qq -o "$z" -d "$d"

# Remove the downloaded zip file
rm "$zip_path"
echo "Removing archive"
rm "$z"
echo Removing archive

# Add gdman directory to the PATH if not already present
if [[ ! ":$PATH:" == *":$install_dir:"* ]]; then
if [[ ! ":$PATH:" == *":$d:"* ]]; then
echo "Adding gdman directory to PATH"
export PATH="$install_dir:$PATH"
echo 'export PATH="'${install_dir}':$PATH"' >> "$HOME/.bashrc"
export PATH="$PATH:$d"
echo 'export PATH="$PATH:'${d}'"' >> "$HOME/.bashrc"

if [ -e "$HOME/.zshrc" ]; then
echo 'export PATH="'${install_dir}':$PATH"' >> "$HOME/.zshrc"
echo 'export PATH="$PATH:'${d}'"' >> "$HOME/.zshrc"
else
echo ".zshrc not found"
fi
fi

echo
echo GDMan $v installed successfully
echo For information on usage, invoke:
echo
echo gdman --help
31 changes: 30 additions & 1 deletion install/install-windows.ps1
Original file line number Diff line number Diff line change
@@ -1 +1,30 @@
$r=iwr -useb https://api.github.com/repos/devklick/GDMan/releases/latest | ConvertFrom-Json;$p=($r.assets | where {$_.name -like '*win-x64.zip'}).browser_download_url; Invoke-WebRequest $p -OutFile "$HOME\Downloads\gdman.zip"; Expand-Archive -LiteralPath "$HOME\Downloads\gdman.zip" -DestinationPath "$Env:AppData\gdman" -Force; Remove-Item -Path "$HOME\Downloads\gdman.zip"; $path=[environment]::GetEnvironmentVariable("PATH", "USER"); if ($PATH -notlike "*C:\Users\user\AppData\Roaming\gdman") { [environment]::SetEnvironmentVariable("PATH", "$path;$Env:AppData\gdman", "USER")}
$z = Join-Path -Path $env:USERPROFILE -ChildPath "Downloads\gdman.zip"
$d = Join-Path -Path $env:USERPROFILE -ChildPath "gdman"

Write-Host Finding latest version
$r = (iwr -useb https://api.github.com/repos/devklick/GDMan/releases/latest | ConvertFrom-Json)
$a = $r.assets | Where-Object { $_.name -match 'win-x64.zip' }
$u = $a | Select-Object -ExpandProperty browser_download_url
$v = $r.tag_name
Write-Host Found $v

Write-Host Downloading
Invoke-WebRequest -Uri $u -OutFile $z

Write-Host Extracting
Expand-Archive -Path $z -DestinationPath $d -Force

Remove-Item -Path $z
Write-Host Removing archive

if (-not ($env:PATH -split ";" -contains $d)) {
Write-Host Adding gdman directory to PATH
$env:PATH = "$env:PATH;$d"
[System.Environment]::SetEnvironmentVariable("PATH", $env:PATH, [System.EnvironmentVariableTarget]::User)
}

Write-Host
Write-Host GDMan $v installed successfully
Write-Host "For information on usage, invoke:"
Write-Host
Write-Host gdman --help

0 comments on commit b6c745a

Please sign in to comment.