Skip to content

Commit

Permalink
Add an update script for pet
Browse files Browse the repository at this point in the history
  • Loading branch information
kai2nenobu committed Jun 16, 2019
1 parent 39b4568 commit 076ec43
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions pet/update.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import-module au

function global:au_GetLatest {
## Find a latest release and extract installer URL from GitHub Releases
$releases = 'https://api.github.com/repos/knqyf263/pet/releases'
$releases_info = Invoke-RestMethod -Uri $releases
foreach ($release in $releases_info) {
if (-not $release.prerelease) {
$version = $release.tag_name -replace "^v",""
$url64 = $release.assets | Where-Object { $_.name -like "*_windows_amd64.tar.gz" } | Select-Object -First 1 -Expand browser_download_url
$url32 = $release.assets | Where-Object { $_.name -like "*_windows_386.tar.gz" } | Select-Object -First 1 -Expand browser_download_url
return @{
Version = $version
URL64 = $url64
URL32 = $url32
}
}
}
}

function global:au_BeforeUpdate { Get-RemoteFiles -Purge -NoSuffix }

function global:au_SearchReplace {
@{
".\legal\VERIFICATION.txt" = @{
"(?i)(\s+x32:).*" = "`${1} $($Latest.URL32)"
"(?i)(\s+x64:).*" = "`${1} $($Latest.URL64)"
"(?i)(checksum32:).*" = "`${1} $($Latest.Checksum32)"
"(?i)(checksum64:).*" = "`${1} $($Latest.Checksum64)"
}
}
}

Update-Package -ChecksumFor none

0 comments on commit 076ec43

Please sign in to comment.