How to get latest Haproxy version string via curl?

TLDR: How to get latest HAproxy release version using curl? Without web scraping.

I have my own opinionated and minimalistic Ansible collection to install dozens of various “devops” tools and services. GitHub - den-is/ansible-collection-tools: Minimalistic ansible collection to deploy 70+ common devops tools · GitHub

I have to constantly update versions with help of a simple bash script and automation. 99% of cases are solved except for HAProxy.

Examples for other products:

  • Golang
    • curl -s "https://go.dev/dl/?mode=json" | jq -r '.[0].version'
      
  • Hashicorp products
    • curl -s 'https://api.releases.hashicorp.com/v1/releases/terraform/latest' | jq -r '.version'
      
  • Kubernetes
    • curl -Ls 'https://dl.k8s.io/release/stable.txt'
      
  • Github releases
    • curl -s 'https://api.github.com/repos/kubernetes/kubernetes/releases/latest' | jq -r '.tag_name'
      
  • Helm
    • curl -s "https://get.helm.sh/helm4-latest-version"
      

So … It would be really nice to have some URL to fetch the latest, Stable or LTS, version of Haproxy using a simple curl request. Maybe there already is such a thing, I was not able to find. Without “hacks” such as haproxy.org page src parsing, etc. I think the above examples are very clear.

You can find json files on the webserve for specific release trains:

https://www.haproxy.org/download/3.4/src/releases.json

You may also just use the external service endoflife.date :

https://endoflife.date/haproxy

Using their API you can use the one liner:

curl -s "https://endoflife.date/api/v1/products/haproxy/releases/latest" | \
jq '.["result"]["latest"]["name"]'