shields icon indicating copy to clipboard operation
shields copied to clipboard

Badge for latest GitHub pre-release excluding later non-pre-release releases

Open ptr727 opened this issue 3 years ago • 7 comments

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.

![GitHub Latest Pre-Release)](https://img.shields.io/github/v/release/ptr727/PlexCleaner?include_prereleases&label=pre-release&logo=github)  
![GitHub Latest Release)](https://img.shields.io/github/v/release/ptr727/PlexCleaner?logo=github)

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

GitHub Latest Pre-Release)
GitHub Latest Release)

💡 Possible Solution

No response

ptr727 avatar Apr 30 '22 13:04 ptr727

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.

calebcartwright avatar Apr 30 '22 16:04 calebcartwright

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.

ptr727 avatar Apr 30 '22 17:04 ptr727

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.

chris48s avatar May 01 '22 11:05 chris48s

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'

ptr727 avatar May 01 '22 15:05 ptr727

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)

calebcartwright avatar May 01 '22 15:05 calebcartwright

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.

AraHaan avatar Jun 30 '23 01:06 AraHaan

@badgen Provides this feature: https://github.com/badgen/badgen.net/pull/485/files

julian-alarcon avatar Sep 19 '23 15:09 julian-alarcon