Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve powershell install script #37

Merged
merged 1 commit into from
Jul 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 8 additions & 11 deletions install.ps1
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# Enable strict mode and exit on error
Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"

$repoOwner = "hathora"
$repoName = "ci"
$binaryName = "hathora"

# Get the latest release tag from GitHub
$latestRelease = (Invoke-WebRequest "https://api.github.com/repos/$repoOwner/$repoName/releases/latest" | ConvertFrom-Json).tag_name

# Detect the architecture
$arch = $env:PROCESSOR_ARCHITECTURE
if ($arch -eq "AMD64") {
Expand All @@ -17,17 +18,13 @@ if ($arch -eq "AMD64") {
}

# Set the download URL for the Windows binary based on the architecture
$downloadUrl = "https://github.com/$repoOwner/$repoName/releases/download/$latestRelease/$binaryName-windows-$arch"
$downloadUrl = "https://github.com/$repoOwner/$repoName/releases/latest/download/$binaryName-windows-$arch.exe"

# Set the install directory
$installDir = "$env:LOCALAPPDATA\Microsoft\WindowsApps"

# Download the binary
Write-Host "Downloading $binaryName for $arch..."
Invoke-WebRequest -Uri $downloadUrl -OutFile "$binaryName.exe"

# Install the binary
Write-Host "Installing $binaryName to $installDir..."
Move-Item -Path "$binaryName.exe" -Destination $installDir -Force
# Download and install the binary directly to the destination
Write-Host "Downloading and installing $binaryName for $arch to $installDir..."
Invoke-WebRequest -Uri $downloadUrl -OutFile "$installDir\$binaryName.exe"

Write-Host "Installation complete!"