-
-
Notifications
You must be signed in to change notification settings - Fork 65
/
update.ps1
41 lines (33 loc) · 1.34 KB
/
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
Import-Module au
$releases = 'https://github.com/microsoft/PowerToys/releases/latest'
function global:au_BeforeUpdate { Get-RemoteFiles -NoSuffix -Purge }
function global:au_GetLatest {
$download_page = Invoke-WebRequest -Uri $releases -UseBasicParsing
$re = "PowerToysSetup(.+)?.msi"
$url = $download_page.links | Where-Object href -match $re | Select-Object -First 1 -expand href
$version = (($download_page.Links | Where-Object href -Match "releases/tag" | Select-Object -First 1 -ExpandProperty href) -Split "/" | Select-Object -Last 1) -Replace "v"
$url = 'https://github.com' + $url
return @{
URL64 = $url
Version = $version
RemoteVersion = $version
FileType = 'msi'
}
}
function global:au_SearchReplace {
return @{
".\tools\chocolateyInstall.ps1" = @{
"(^[$]fileName\s*=\s*`"[$]toolsDir\\).*" = "`${1}$($Latest.FileName64)`""
"(^[$]version\s*=\s*)`".*`"" = "`${1}`"$($Latest.RemoteVersion)`""
}
".\legal\VERIFICATION.txt" = @{
"(?i)(listed on\s*)\<.*\>" = "`${1}<$releases>"
"(?i)(64-Bit.+)\<.*\>" = "`${1}<$($Latest.URL64)>"
"(?i)(checksum type:).*" = "`${1} $($Latest.ChecksumType64)"
"(?i)(checksum64:).*" = "`${1} $($Latest.Checksum64)"
}
}
}
if ($MyInvocation.InvocationName -ne '.') {
update -ChecksumFor None
}