Badge for latest GitHub pre-release excluding later non-pre-release releases
Are you experiencing an issue with...
shields.io
🐞 Description
I asked on StackOverflow but no answer, if not appropriate to ask here, apologies, please redirect:
How can I create a badge that will display the latest pre-release version, excluding later releases that are not marked pre-release?
The current behavior allows for "inclusion" of a pre-release, but I want to explicitly only get the latest pre-release, ignoring any later releases that are not pre-release.
E.g.


From example releases, expected that the badges list 2.7.11 as latest and 2.7.10-ga8a94550e6 as latest pre-release. (at time of writing).
Iterating over releases and finding pre-release by attribute seems possible.
🔗 Link to the badge
💡 Possible Solution
No response
Thanks for sharing your idea. I'm having a bit of déjà vu with this but can't find any precisely matching issues so will leave this open. I'm personally open to supporting this as it strikes me as enabling users to display information to the effect of "here's the latest stable version, and the latest unstable version".
However, my recollection of past discussion is that some other maintainers have expressed skepticism about the value of showing metrics/stats for explicit pre-release targets so would be curious to know what other maintainers think.
Thx, I'd add that the value is in consistency when there is a pre-release available, i.e. I use simplified github flow with main and develop, new work goes on develop, when ready goes to main.
While there are newer releases the badge works as expected, the moment I PR from develop to main the badge no longer works as expected, as in the pre-release and release versions are now the same.
I also tag the develop pre-release builds as develop in docker, so the docker badge does work as expected since I can say use develop tag, but the github release badge only looks for the latest version, not the latest pre-release only version.
Its a bit of an esoteric one.
I don't think you can construct this query with jsonpath either so dynamic json isn't an option for this.
I guess one concern with adding an only_prereleases (as well as include_prereleases) flag for one version badge is it becomes a legit feature request for all of them. We probably do need to consider it in that context.
I don't think you can construct this query with jsonpath either so dynamic json isn't an option for this.
Not sure which "jsonpath" is being referred to, but from stackoverflow solution:
wget https://api.github.com/repos/ptr727/PlexCleaner/releases
jq -r 'map(select(.prerelease)) | first | .tag_name'
Not sure which "jsonpath" is being referred to, but from stackoverflow solution:
That's a reference to the dynamic json badges we provide (https://shields.io/#your-badge) wherein you can include a jsonpath query as part of the badge url which we'll use to build out the badge against the specific json document; and the fact that won't work here (sure you already know this, but worth noting for any others that jq != jsonpath)
In my case I want my badges to support viewing both prerelease and stable releases depending on which one is viewed as a "higher" version.
@badgen Provides this feature: https://github.com/badgen/badgen.net/pull/485/files