Latest release and LTS versions from server (for use in CI)?

It has probably been asked before, but how can I programmatically and reliably get the latest stable julia version and latest lts stable version from an official server e.g. julialang.org or julialang.net using simple linux tools (e.g. curl and grep ?)

I don’t think the JSON release feed can help with that.

Any reason not to use juliaup, i.e. just juliaup add release, juliaup add lts?

1 Like

This is to use in ci in scripts, hence no juliaup available.

https://julialang-s3.julialang.org/juliaup/DBVERSION Then julialang-s3.julialang.org/juliaup/versiondb/versiondb-1.0.55-x86_64-unknown-linux-gnu.json

2 Likes

Thanks @xgdgsc.

In case it helps anyone, here is my solution:

function available_channels()
    juliaup = "https://julialang-s3.julialang.org/juliaup"
    for i ∈ 1:6
        buf = PipeBuffer()
        Downloads.download("$juliaup/DBVERSION", buf)
        dbversion = VersionNumber(readline(buf))
        dbversion.major == 1 || continue
        buf = PipeBuffer()
        Downloads.download("$juliaup/versiondb/versiondb-$dbversion-x86_64-unknown-linux-gnu.json", buf)
        json = JSON.parse(buf)
        haskey(json, "AvailableChannels") || continue
        return json["AvailableChannels"]
        sleep(10i)
    end
end

"""
julia> is_latest("lts")
julia> is_latest("release")
"""
function is_latest(variant)
    channels = available_channels()
    ver = VersionNumber(split(channels[variant]["Version"], '+') |> first)
    dev = occursin("DEV", string(VERSION))  # or length(VERSION.prerelease) < 2
    !dev && VersionNumber(ver.major, ver.minor, 0, ("",)) ≤ VERSION < VersionNumber(ver.major, ver.minor + 1)
end

################
import JSON, Downloads
@show is_latest("lts") is_latest("release")

EDIT: plain julia implementation using Downloads.

While this works now, I should say that we don’t treat the format of any of these files as a public API, i.e. we might change those at any point without warning as we update Juliaup.

What kind of CI system? There is a GitHub action that installs Juliaup, and we also have portable versions of Juliaup available that should make it very easy to get Juliaup onto a system. So my gut feeling is that the best solution would be 1) download and extract Juliaup, 2) call juliaup to add whatever Julia you need.

It’s github action, but I’m not going to pull juliaup for a few bytes, it feels like using a hammer to kill a mosquito.

Juliaup is extremly small, less than a handful of MB. GitHub - julia-actions/install-juliaup: GitHub Action that installs Juliaup (and uses Juliaup to install Julia) is the action to install it. I think you’ll get a much more stable and reliable solution if you use it rather than fiddling with unofficial file downloads that we might change at any time…