scalacenter / scaladex

The Scala Package Index
https://index.scala-lang.org
BSD 3-Clause "New" or "Revised" License
195 stars 76 forks source link

Fix latest-by-scala-version badge summary to prefer releases #1330

Closed rtyley closed 5 months ago

rtyley commented 6 months ago

I just noticed that the versions shown in the Scaladex badges for content-api-firehose-client don't match - one is showing the stable release number (1.0.12 👍), and the other is showing a pre-release (less good):

image

The JVM badge shows a latest-by-scala-version summary I introduced with https://github.com/scalacenter/scaladex/pull/660, but it looks like I missed out logic which is present in the other badge - preferring to show releases, and only showing pre-releases if they are the only available version!

This PR fixes the behaviour on the latest-by-scala-version badge to match the behaviour of the other badge - it does this with a new PreferReleases ordering for SemanticVersions. I did have a look to see if I could refactor the logic used by the first badge to also make use of this ordering, but it would have required a bigger refactoring:

https://github.com/scalacenter/scaladex/blob/9c07f4f13e1053d8f4f3179d6f338f566be8bf22/modules/server/src/main/scala/scaladex/server/route/Badges.scala#L159-L162

rtyley commented 5 months ago

Thanks! I can confirm that the badges on this sample project now show the correct release version:

https://index.scala-lang.org/rtyley/sample-project-using-gha-scala-library-release-workflow/badges

image

...even though there are 'higher' number preview releases:

https://index.scala-lang.org/rtyley/sample-project-using-gha-scala-library-release-workflow/artifacts/core?pre-releases=true#

image