Skip to content

⭐ Add Windows equivalent install script #81

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

Merged
merged 3 commits into from
Apr 30, 2025
Merged
Show file tree
Hide file tree
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
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@ curl -sSf https://raw.githubusercontent.com/rojo-rbx/rokit/main/scripts/install.

### Windows

#### Option 1

Run the automated installer script in PowerShell:

```sh
Invoke-RestMethod https://raw.githubusercontent.com/rojo-rbx/rokit/main/scripts/install.ps1 | Invoke-Expression
```

#### Option 2

Download and run<sup>\*</sup> `rokit.exe` from the [latest release][latest-release] page - this will automatically install Rokit.

<sup>\* Make sure to run `rokit.exe` **directly**, by double-clicking it in the File Explorer, for automatic installation to be triggered. <br/> If you would like to install Rokit from a terminal or shell such as PowerShell / CMD, run `rokit.exe self-install` instead.
Expand Down
94 changes: 94 additions & 0 deletions scripts/install.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
$PROGRAM_NAME = "rokit"
$REPOSITORY = "rojo-rbx/rokit"

$originalPath = Get-Location

Set-Location "$env:temp"

# Function to get release info from GitHub API
Function Get-ReleaseInfo {
param (
[string]$ApiUrl
)

$headers = @{
'X-GitHub-Api-Version' = '2022-11-28'
}

if ($env:GITHUB_PAT) {
$headers['Authorization'] = "token $env:GITHUB_PAT"
}

try {
$response = Invoke-RestMethod -Uri $ApiUrl -Headers $headers -ErrorAction Stop
return $response
}
catch {
throw "Failed to fetch release info: $_"
}
}

try {
if ($env:GITHUB_PAT) {
Write-Host "NOTE: Using provided GITHUB_PAT for authentication"
}

Write-Host "`n[1 / 3] Looking for latest $PROGRAM_NAME release"

$apiUrl = "https://api.github.com/repos/$REPOSITORY/releases/latest"
$releaseInfo = Get-ReleaseInfo -ApiUrl $apiUrl

$versionTag = $releaseInfo.tag_name
$numericVersion = $versionTag -replace '^v', ''

# Construct the download URL
$downloadUrl = "https://github.com/$REPOSITORY/releases/download/$versionTag/$PROGRAM_NAME-$numericVersion-windows-x86_64.zip"
Write-Host "[2 / 3] Downloading '$PROGRAM_NAME-$numericVersion-windows-x86_64.zip'"

# Grab the latest release asset
try {
Invoke-WebRequest $downloadUrl -OutFile rokit.zip -ErrorAction Stop
}
catch {
throw "Failed to download from $downloadUrl`: $_"
}

# Extract the archive
try {
Expand-Archive -Path rokit.zip -Force -ErrorAction Stop
}
catch {
throw "Failed to extract rokit.zip: $_"
}

# Run self-install
try {
if (Test-Path ".\rokit\rokit.exe") {
Write-Host "[3 / 3] Running $PROGRAM_NAME installation`n"
Start-Process -FilePath ".\rokit\rokit.exe" -ArgumentList "self-install" -Wait -NoNewWindow
}
else {
throw "rokit.exe not found in the extracted directory"
}
}
catch {
throw "Failed to run self-install: $_"
}

# Cleanup
try {
Remove-Item rokit.zip -ErrorAction SilentlyContinue
Remove-Item -Recurse -Path .\rokit -ErrorAction SilentlyContinue
}
catch {
Write-Warning "Cleanup failed: $_"
}
}
catch {
Write-Error "Installation failed: $_"
exit 1
}
finally {
# Return to original directory
Set-Location -Path $originalPath
}