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

retroshare: update version, livecheck, add Rosetta #184638

Merged
merged 2 commits into from
Sep 8, 2024

Conversation

krehel
Copy link
Member

@krehel krehel commented Sep 7, 2024

Important: Do not tick a checkbox if you haven’t performed its action. Honesty is indispensable for a smooth review process.

In the following questions <cask> is the token of the cask you're submitting.

After making any changes to a cask, existing or new, verify:

Additionally, if adding a new cask:

  • Named the cask according to the token reference.
  • Checked the cask was not already refused (add your cask's name to the end of the search field).
  • brew audit --cask --new <cask> worked successfully.
  • HOMEBREW_NO_INSTALL_FROM_API=1 brew install --cask <cask> worked successfully.
  • brew uninstall --cask <cask> worked successfully.

Please tell me @samford there's a better way to do this 🙏

@BrewTestBot BrewTestBot added the missing zap Cask is missing a zap stanza, please add one. label Sep 7, 2024
@krehel
Copy link
Member Author

krehel commented Sep 7, 2024

Can break up the regex using /x if needed as this is going to fail the check

@krehel krehel added the livecheck Issues or PRs related to livecheck label Sep 7, 2024
Copy link
Member

@samford samford left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like 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 directly links to the latest release's dmg file(s), so we could 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 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 can lead to breakages over time.

If that sounds reasonable, I can push a commit:

Commit diff
diff --git a/Casks/r/retroshare.rb b/Casks/r/retroshare.rb
index 0818a37f8c3..8d3e9e9af78 100644
--- a/Casks/r/retroshare.rb
+++ b/Casks/r/retroshare.rb
@@ -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
 
-- 
2.46.0

@krehel
Copy link
Member Author

krehel commented Sep 7, 2024

I am ok with this @samford! Your expertise appreciated as I didn't really like this, but wanted to fix in the most direct way possible.

This has actually been broken for quite some time and no one has complained, so I think any fix is good here.

>  cask-analytics retroshare
30 days: 1 (#7340)
90 days: 4 (#6959)
365 days: 38 (#5331)

krehel and others added 2 commits September 7, 2024 15:34
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.
@bevanjkay bevanjkay merged commit 5ac7e30 into master Sep 8, 2024
8 checks passed
@bevanjkay bevanjkay deleted the retroshare-livecheck branch September 8, 2024 12:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
livecheck Issues or PRs related to livecheck missing zap Cask is missing a zap stanza, please add one.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants