Skip to content

Commit

Permalink
retroshare: update version format, livecheck
Browse files Browse the repository at this point in the history
Upstream doesn't mark unstable versions as pre-release (e.g.,
v0.6.6-RC2 was the "latest" release in the past), so `GithubLatest`
is out. `GithubReleases` works but the first-party download page
(https://retroshare.cc/downloads.html) directly links to the latest
release's dmg file(s), so we can avoid the `strategy` block if we
check that instead.

The download page lists the version as 0.6.7a instead of the tag
version, so it seems like we should be using the filename version
instead of the tag version (0.6.7.2) as `version.csv.first`.

At this rate, we may want to consider simply capturing the entire
suffix (`0c03e93a4-01-03-2024-MacOS-10.15.7-Qt-5.15.11`) instead of
extracting the individual parts. Either way technically works but
there have been a number of changes to the suffix format over time
and strictly matching a specific format will lead to breakages over
time.
  • Loading branch information
samford committed Sep 7, 2024
1 parent 090cb1e commit 43bb369
Showing 1 changed file with 13 additions and 25 deletions.
38 changes: 13 additions & 25 deletions Casks/r/retroshare.rb
Original file line number Diff line number Diff line change
@@ -1,38 +1,26 @@
cask "retroshare" do
version "0.6.7.2,0.6.7a,0c03e93a4-01-03-2024,10.15.7,5.15.11"
version "0.6.7a,0c03e93a4-01-03-2024-MacOS-10.15.7-Qt-5.15.11,0.6.7.2"
sha256 "6757a0bffba36fd85515117edba7e821bb3105500f8a282be942abeee3373230"

url "https://github.com/RetroShare/RetroShare/releases/download/v#{version.csv.first}/RetroShare-#{version.csv.second}-#{version.csv.third}-MacOS-#{version.csv.fourth}-Qt-#{version.csv.fifth}.dmg",
url "https://github.com/RetroShare/RetroShare/releases/download/v#{version.csv.third || version.csv.first}/RetroShare-#{version.csv.first}#{"-#{version.csv.second}" if version.csv.second.present?}.dmg",
verified: "github.com/RetroShare/RetroShare/"
name "RetroShare"
desc "Friend-2-Friend and secure decentralised communication platform"
homepage "https://retroshare.cc/"

# The tag version can differ from the filename version, so we include both in
# the `version` when necessary.
livecheck do
url :url
regex(/
Retroshare[._-]
(\d+(?:\.\d+)+[a-z]?)[._-]
([\h-]+)[._-]
MacOS[._-]
(\d+(?:\.\d+)+)[._-]
Qt[._-]
(\d+(?:\.\d+)+)\.dmg$
/xi)
strategy :github_releases do |json, regex|
json.map do |release|
next if release["draft"] || release["prerelease"]

tag_version = release["tag_name"][/^v?(\d+(?:\.\d+)+)$/i, 1]
next if tag_version.blank?

release["assets"]&.map do |asset|
match = asset["name"]&.match(regex)
next if match.blank?

"#{tag_version},#{match[1]},#{match[2]},#{match[3]},#{match[4]}"
url "https://retroshare.cc/downloads.html"
regex(%r{/v?(\d+(?:\.\d+)+)/Retroshare[._-]v?(\d+(?:\.\d+)+[a-z]?)+(?:[._-]([^"' >]*?))?\.dmg}i)
strategy :page_match do |page, regex|
page.scan(regex).map do |match|
if match[2] && (match[0] != match[1])
"#{match[1]},#{match[2]},#{match[0]}"
else
"#{match[1]},#{match[2]},"
end
end.flatten
end
end
end

Expand Down

0 comments on commit 43bb369

Please sign in to comment.