Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(clementine) Fix version checks #2603

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 30 additions & 10 deletions automatic/clementine/update.ps1
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
Import-Module Chocolatey-AU

$releases = 'https://www.clementine-player.org/downloads'
$releases = 'https://api.github.com/repos/clementine-player/Clementine/releases'
$publicReleases = 'https://www.clementine-player.org/downloads'

function global:au_BeforeUpdate {
Get-RemoteFiles -Purge
Expand All @@ -14,7 +15,7 @@ function global:au_BeforeUpdate {
function global:au_SearchReplace {
@{
".\legal\VERIFICATION.txt" = @{
"(?i)(^\s*location on\:?\s*)\<.*\>" = "`${1}<$releases>"
"(?i)(^\s*location on\:?\s*)\<.*\>" = "`${1}<$publicReleases>"
"(?i)(\s*1\..+)\<.*\>" = "`${1}<$($Latest.URL32)>"
"(?i)(^\s*checksum\s*type\:).*" = "`${1} $($Latest.ChecksumType32)"
"(?i)(^\s*checksum(32)?\:).*" = "`${1} $($Latest.Checksum32)"
Expand All @@ -25,15 +26,34 @@ function global:au_SearchReplace {
}
}
function global:au_GetLatest {
$download_page = Invoke-WebRequest -Uri $releases -UseBasicParsing

$re = '\.exe$'
$url = $download_page.links | ? href -match $re | select -First 1 -expand href
$version = Split-Path (Split-Path $url) -Leaf
@{
URL32 = $url
Version = $version
$download_page = Invoke-RestMethod -Uri $releases
$streams = @{}
$download_page | ForEach-Object {
if ($_.prerelease -eq $True) {
$key = "pre"
$version = $_.tag_name -replace '-[^-]+$' -replace '([0-9]+)\.([0-9]+)\.([0-9]+)(rc[0-9]+)-([0-9]+)', '$1.$2.$3.$5-$4'
}
else {
$key = "stable"
$version = $_.tag_name -replace '-[^-]+$' -replace '-', '.'
}
$url = $_.assets | Where-Object { $_.name -match '\.exe$' } | Select-Object -First 1 -ExpandProperty browser_download_url
if ($url -and !$streams.ContainsKey($key)) {
$streams.Add($key, @{
Version = $version
URL32 = $url
})
}
}
return @{ Streams = $streams }

# $re = '\.exe$'
# $url = $download_page.links | ? href -match $re | select -First 1 -expand href
# $version = Split-Path (Split-Path $url) -Leaf
# @{
# URL32 = $url
# Version = $version
# }
}

update -ChecksumFor none