From 33c741aaf3e7e4f16b336ca81213e68b5adbd3a7 Mon Sep 17 00:00:00 2001 From: Sam Ford <1584702+samford@users.noreply.github.com> Date: Sun, 19 Nov 2023 16:54:55 -0500 Subject: [PATCH] wine-stable: update livecheck --- Casks/w/wine-stable.rb | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/Casks/w/wine-stable.rb b/Casks/w/wine-stable.rb index 74dc604512..4559fc5cf8 100644 --- a/Casks/w/wine-stable.rb +++ b/Casks/w/wine-stable.rb @@ -11,28 +11,22 @@ cask "wine-stable" do desc "Compatibility layer to run Windows applications" homepage "https://wiki.winehq.org/MacOS" - # NOTE: This approach involves multiple requests and should be avoided - # whenever possible. If upstream starts reliably providing `wine-stable` zip - # files in every release, we should switch to `url :url` with - # `strategy :github_latest`. + # Not every GitHub release provides a `wine-stable` file, so we check multiple + # recent releases instead of only the "latest" release. livecheck do - url "https://github.com/Gcenx/macOS_Wine_builds/releases?q=prerelease%3Afalse" - regex(%r{/v?(\d+(?:\.\d+)+)/wine-stable[._-][^"' >]*?\.t}i) - strategy :page_match do |page, regex| - # Collect the release tags on the page - tags = page.scan(%r{href=["']?[^"' >]*?/releases/tag/([^"' >]*?)["' >]}i)&.flatten&.uniq + url :url + regex(/^v?(\d+(?:[.-]\d+)+)$/i) + strategy :github_releases do |json, regex| + file_regex = /^wine-stable[._-].*?$/i - max_reqs = 6 - tags.each_with_index do |tag, i| - break if i >= max_reqs + json.map do |release| + next if release["draft"] || release["prerelease"] + next unless release["assets"]&.any? { |asset| asset["name"]&.match?(file_regex) } - # Fetch the assets list HTML for the tag and match within it - assets_page = Homebrew::Livecheck::Strategy.page_content( - @url.sub(%r{/releases/?.+}, "/releases/expanded_assets/#{tag}"), - ) - matches = assets_page[:content]&.scan(regex)&.map { |match| match[0] } + match = release["tag_name"].match(regex) + next if match.blank? - break matches if matches.present? + match[1] end end end