GitLab API - Get latest release version

I’m not sure if this is the right section so please bare with me!

Our projects have recently been migratd onto a self-hosted GitLabs instance, if it is any use then the projects are in Java. These applications contain an update alerter as many of us work in different timezones and are a reasonable sized team, anyway, GitHub allowed you to use api.project.url/releases/latest to return a JSON response for the latest release which included tag name, message, etc. I was wondering if there was something just like this with the GitLabs API?

Thank you!

I’m sure that someone can come up with a better solution but this works to parse the releases and return the versions. This requires the CLI tool of jq. This is for Linux and possibly macOS.

This will return the latest version release.

curl -s https://gitlab.com/api/v4/projects/<projectidhere>/releases/ | jq '.[]' | jq -r '.name' | head -1

You could then do something like this to get the release information.

VERSION=$(curl -s https://gitlab.com/api/v4/projects/<projectidhere>/releases/ | jq '.[]' | jq -r '.name' | head -1)
curl -s https://gitlab.com/api/v4/projects/<projectidhere>/releases/$VERSION

Hopefully GitLab incorporates something more along the lines of what GitHub has for getting the latest release

1 Like

FYI; this is what you can use today. This gets you the latest version of dav1d codec, as an example.

HOSTNAME=code.videolan.org
PROJECTID=198
curl -s https://$HOSTNAME/api/v4/projects/$PROJECTID/releases/ | jq '.[0].tag_name' -r

You can see the ID on the front page of the project.