-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathcheck-update.ps1
48 lines (43 loc) · 1.22 KB
/
check-update.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
$output = & "${env:SCOOP_HOME}\bin\checkver.ps1" -Dir bucket 6>&1
$app = $null
$newver = $null
$curver = $null
$updatables = @("__NONE__")
foreach ($line in $output) {
if ($curver -ne $null) {
if ($line -match '^ autoupdate available$') {
$updatables += "$app"
$app = $null
$newver = $null
$curver = $null
} else {
Write-Host "Unexpected output: $line"
exit 1
}
continue
}
if ($newver -ne $null) {
if ($line -match '\(scoop version is ([-\w\d.]+)\)') {
$curver = $Matches.1
} elseif ($line -match '^([\w-]+): $') {
$app = $Matches.1
$newver = $null
} else {
Write-Host "Unexpected output: $line"
exit 1
}
continue
}
if ($app -ne $null) {
$newver = $line
continue
}
if ($line -match '^([\w-]+): $') {
$app = $Matches.1
continue
}
Write-Host "Unexpected output: $line"
exit 1
}
$json = (ConvertTo-JSON -Compress $updatables)
"apps<<EOF`n$json`nEOF`n" | Out-File -NoNewline -Encoding utf8 -Append $env:GITHUB_OUTPUT