-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathinstall.ps1
51 lines (45 loc) · 1.45 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
function abort($message) {
Write-Error -Message $message
exit 1
}
function message($message) {
Write-Information -Message $message -InformationAction Continue
}
function InstallWindows {
$WindowsArchitecture = (Get-CimInstance Win32_operatingsystem).OSArchitecture
$arch = if ($WindowsArchitecture.Contains("ARM")) {
if ($WindowsArchitecture.StartsWith("64")) {
"aarch64"
} else {
abort("arm is not supported")
}
} else {
if ($WindowsArchitecture.StartsWith("64")) {
"x86_64"
} else {
abort("32-bit is not supported")
}
}
message("Finding webman for windows $arch ...")
$latest = Invoke-WebRequest "https://api.github.com/repos/candrewlee14/webman/releases/latest" | ConvertFrom-Json
$asset = $latest.assets | Where-Object { $_.name -like "webman*windows*$arch*" }
$tmp = "$env:TEMP/webman.zip"
$binDir = "$env:TEMP/webman"
message("Retrieving $($asset.browser_download_url)")
Invoke-WebRequest -Uri $asset.browser_download_url -OutFile $tmp
Expand-Archive -Path $tmp -DestinationPath $binDir
$webman = Join-Path $binDir "webman.exe"
& $webman add webman --switch
Remove-Item -Path $tmp -Recurse
Remove-Item -Path $binDir -Recurse
}
function InstallOtherOS {
message("Installing webman via bash")
curl -s https://raw.githubusercontent.com/candrewlee14/webman/main/scripts/install.sh | bash
}
$isWin = $env:OS -like "windows*"
if ($isWin) {
InstallWindows
} else {
InstallOtherOS
}