-
Notifications
You must be signed in to change notification settings - Fork 6
/
update.ps1
26 lines (22 loc) · 916 Bytes
/
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
import-module au
$domain = 'https://github.com'
$releases = "$domain/Genymobile/scrcpy/releases"
function global:au_SearchReplace {
@{
".\tools\chocolateyInstall.ps1" = @{
"(?i)(^\s*url\s*=\s*)('.*')" = "`$1'$($Latest.URL32)'"
"(?i)(^\s*checksum\s*=\s*)('.*')" = "`$1'$($Latest.Checksum32)'"
}
}
}
# 'https://github.com/Genymobile/scrcpy/releases/download/v1.25/scrcpy-win64-v1.25.zip'
function global:au_GetLatest {
$regex = 'scrcpy-win64-v\d+.\d+(.\d+)?.zip$'
$download_page = Invoke-WebRequest -Uri $releases -UseBasicParsing #1
$sublink = $download_page.links | ? href -match $regex | select -First 1 -expand href #2
$url = ($domain, $sublink) -join ''
$token = $url -split 'scrcpy-win64-v' | select -First 1 -Skip 1 #3
$version = $token -split '.zip' | select -Last 1 -Skip 1 #3
return @{ Version = $version; URL32 = $url }
}
update -ChecksumFor 32