Skip to content

Commit

Permalink
Add a update script for ghq
Browse files Browse the repository at this point in the history
  • Loading branch information
kai2nenobu committed Jun 16, 2019
1 parent 68dd69b commit dec60af
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions ghq/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/motemen/ghq/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.zip" } | Select-Object -First 1 -Expand browser_download_url
$url32 = $release.assets | Where-Object { $_.name -like "*_windows_386.zip" } | 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 -NoReadme -ChecksumFor none

0 comments on commit dec60af

Please sign in to comment.