-
Notifications
You must be signed in to change notification settings - Fork 0
/
UpdateCheck.ps1
57 lines (44 loc) · 1.99 KB
/
UpdateCheck.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
Param([string]$Path = '.')
function Check-GithubUpdate {
param (
[Parameter(Mandatory)][string]$Path,
[Parameter(Mandatory)][string]$Repo
)
$vpxItem = Get-Item -LiteralPath $Path -ErrorAction Stop
$vpxVer = 'v{0}' -f $vpxItem.VersionInfo.ProductVersion
$json = (Invoke-WebRequest -Uri ('https://api.github.com/repos/{0}/releases' -f $Repo)).Content | ConvertFrom-Json
$tag_name = @($json.tag_name)[0] -replace '-', '.'
@{
OnlineVersion = $tag_name
LocalVersion = $vpxVer
LocalPath = $Path
Assets = $json.assets.browser_download_url | Where-Object { $_ -match $tag_name }
}
}
### Visual Pinball X
Write-Host -ForegroundColor Cyan 'Visual Pinball X:'
$result = Check-GithubUpdate -Path (Join-Path -Path $Path -ChildPath 'VPinballX64.exe') -Repo 'vpinball/vpinball'
'Local version: {0} ({1})' -f $result.LocalVersion, $result.LocalPath
'Online version: {0}' -f $result.OnlineVersion
if ($result.LocalVersion -ne $result.OnlineVersion) {
Write-Host -ForegroundColor Yellow 'VPX Update available from https://github.com/vpinball/vpinball/releases :'
$result.Assets | Where-Object { $_ -like '*/VPinballX-*-Release-win-x64.*' }
'(Extract to "Visual Pinball" root directory)'
}
else {
Write-Host -ForegroundColor Green 'Latest version installed.'
}
''
### Visual PinMAME
Write-Host -ForegroundColor Cyan 'Visual PinMAME:'
$result = Check-GithubUpdate -Path (Join-Path -Path $Path -ChildPath 'VPinMAME\VPinMAME64.dll') -Repo 'vpinball/pinmame'
'Local version: {0} ({1})' -f $result.LocalVersion, $result.LocalPath
'Online version: {0}' -f $result.OnlineVersion
if ($result.LocalVersion -ne $result.OnlineVersion) {
Write-Host -ForegroundColor Yellow 'VPM Update available from https://github.com/vpinball/pinmame/releases :'
$result.Assets | Where-Object { $_ -like '*/VPinMAME-sc-*-win-x64.*' }
'(Extract to "VPinMAME" subdirectory)'
}
else {
Write-Host -ForegroundColor Green 'Latest version installed.'
}