Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a simple latest-stable script to bin directory #118

Open
Eiji7 opened this issue Oct 25, 2022 · 0 comments
Open

Add a simple latest-stable script to bin directory #118

Eiji7 opened this issue Oct 25, 2022 · 0 comments

Comments

@Eiji7
Copy link

Eiji7 commented Oct 25, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant