asdf-elixir
asdf-elixir copied to clipboard
Add a simple latest-stable script to bin directory
Currently asdf latest --all using a fallback call returns main-otp-25 which we definitely can't consider as stable. However we can easily add a one line script using code like:
echo $(curl --silent https://api.github.com/repos/elixir-lang/elixir/releases/latest | jq -r .name)-otp-$(asdf current erlang | sed -r "s/^erlang\s+([0-9]+).*$/\1/")
# or
echo $(asdf list-all elixir | grep -Pv "^0|rc|otp|main|master" | tail -n 1)-otp-$(asdf current erlang | sed -r "s/^erlang\s+([0-9]+).*$/\1/"
# 1.14.1-otp-25
The first part simply fetches latest release name using Github API, curl and jq. The second is even simpler as it uses only asdf current and sed. Alternatively in first part the second example uses only asdf and grep.
Also we can use Github API, curl, jq and sed to fetch latest Erlang version like:
echo $(curl --silent https://api.github.com/repos/erlang/otp/releases/latest | jq -r .name | sed -r "s/^OTP ([0-9]+).*$/\1/")
# 25
in case we to protect script in case erlang plugin is not installed
Note: Those code sample are the first ones coming to my mind and most probably there are even more simple ones.