-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.ps1
60 lines (46 loc) · 1.79 KB
/
install.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# Define an array of GitHub repos in the format "owner/repo"
$repos = @(
"user/repo"
)
# Function to download and extract the latest release from a repo
function Download-And-Extract-LatestRelease {
param (
[string]$repo
)
Write-Host "Processing $repo..."
# Construct the URL for the latest release
$url = "https://api.github.com/repos/$repo/releases/latest"
Write-Host "Fetching release info from: $url"
# Get the latest release information
$response = Invoke-RestMethod -Uri $url
$zipballUrl = $response.zipball_url
if (-not $zipballUrl) {
Write-Host "Failed to get the latest release for $repo"
return
}
Write-Host "Download URL: $zipballUrl"
# Download the latest release
$zipPath = "latest.zip"
Invoke-WebRequest -Uri $zipballUrl -OutFile $zipPath
if (-not (Test-Path -Path $zipPath)) {
Write-Host "Failed to download the latest release for $repo"
return
}
# Extract the release into a temporary directory
$tempDir = New-Item -ItemType Directory -Path (Join-Path $env:TEMP "extract_$repo")
Expand-Archive -Path $zipPath -DestinationPath $tempDir -Force
# Move the contents of the extracted folder to the current directory
$extractedDir = Get-ChildItem -Path $tempDir -Directory | Select-Object -First 1
if ($extractedDir -ne $null) {
Get-ChildItem -Path $extractedDir.FullName | Move-Item -Destination . -Force
}
# Remove the temporary directory and the zip file after extraction
Remove-Item -Path $tempDir -Recurse -Force
Remove-Item -Path $zipPath -Force
Write-Host "Completed $repo"
}
# Iterate through each repo and process it
foreach ($repo in $repos) {
Download-And-Extract-LatestRelease -repo $repo
}
Write-Host "All repositories processed."