How to reliably & programmatically get the latest version number of Discourse?

As I might for many open-source projects, I was looking for GitHub releases. Someone had the same idea as me and also discovered that Discourse doesn’t have GitHub Releases (anymore).

My next attempt was to use git tags on GitHub, which would be the next best thing. As of today, the latest tag on GitHub is v3.6.0.beta2. Taking a peak at the admin page of my own Discourse instance, I am running v3.6.0.beta3. This means that not only is the latest Discourse release not tagged on GitHub, Discourse itself (the software) must not be using GitHub tags as the way to know when there’s a new release.

I remembered that my install is running on Docker, so I decided to follow that rabbit hole over to where the Discourse images are hosted on Docker Hub. There’s a couple of naming conventions being used as tags there (such as 2.0.20251113-0018-web-only-stable), none that seem to correlated to the v.X.Y.Z format Discourse uses publicly.


So, does anyone have a recommendation on how to do this?

The version which is used for display is defined Discourse::VERSION::String which is a hard coded constant:

1 Like

I guess you are running beta3-latest, which means one version during the development of beta3. The final version of beta3 has not yet been released, so the tag represents the latest released beta. But you probably use latest, which is not based on the beta releases.

Have you read the topic about the new versioning strategy?

2 Likes

I didn’t use anything. Discourse tells me when there’s updates, and I click the button to install them in the UI. I’m trying to figure out where Discourse gets that info.

Thank you. I did come across that but that would require me to git clone on a regular basis and inspect that file, which isn’t light weight.

The first link doesn’t help me get the latest version(s) (in fact, seems like there’s even more to get now) but this second link is good to know. Looks like the versioning scheme will be changing completely. Thanks for the link.

I thought the explanation that notifications are sent once a new beta is released might be helpful for you. When you update after the notification for the 3.6.0.beta3 release, while your forum is based on “latest”, you will get 3.6.0.beta4-latest.

I need some sort of URL where I can use a programming language (or say curl) to check what the latest version(s) is. Typically this is some sort of feed and has a response with structured language such as JSON, XML, YAML, etc.

You can use the version check that’s in the Discourse code.

https://api.discourse.org/api/version_check?installed_version=X

where X is a known version on the branch that you want to get information about.

If you just want to get the latest 5 beta version numbers, simply use an old version like
https://api.discourse.org/api/version_check?installed_version=3.1.0.beta1

If you want the latest stable, omit the installed_version parameter
https://api.discourse.org/api/version_check

Alternatively, retrieve https://github.com/discourse/discourse/blob/main/lib/version.rb and look for the STRING = line.

STRING = "3.6.0.beta3-latest"

(For beta use https://github.com/discourse/discourse/blob/beta/lib/version.rb, for stable use https://github.com/discourse/discourse/blob/stable/lib/version.rb)

4 Likes

This. This is exactly what I was looking for but my Google-fu was failing me. Thank you!

This API shows v3.6.0 beta 2 as the latest (the as GitHub tags) and not beta 3 which is what my forum is running. I don’t understand how that happen but that’s a different problem. :laughing:

Thank you for the help.

2 Likes

The data provided by api.discourse.org is taken from the GitHub tags, so you can use either. They’ll always give the same result.

That’s because you’re running the pre-release version of beta3:

The -latest suffix is the indicator that it’s a pre-release on the latest branch of Discourse, and does not correspond to a specific commit.

2 Likes