diff --git a/_data/elixir-versions.yml b/_data/elixir-versions.yml index 93d640300..f8a2d9538 100644 --- a/_data/elixir-versions.yml +++ b/_data/elixir-versions.yml @@ -3,6 +3,7 @@ stable: v1_17 v1_17: name: v1.17 minimum_otp: 25.0 + recommended_otp: 27.1.2 otp_versions: [27, 26, 25] version: 1.17.3 diff --git a/install.bat b/install.bat new file mode 100755 index 000000000..476b69e4d --- /dev/null +++ b/install.bat @@ -0,0 +1,164 @@ +@echo off +REM See latest version at: +REM https://github.com/elixir-lang/elixir-lang.github.com/blob/main/install.bat + +setlocal EnableDelayedExpansion + +set "otp_version=latest" +set "elixir_version=latest" +set "force=false" + +goto :main + +:usage +echo Usage: install.bat [arguments] [options] +echo. +echo Arguments: +echo. +echo elixir@VERSION Install specific Elixir version. The version can be X.Y.Z, latest, or main +echo otp@VERSION Install specific Erlang/OTP version. The version can be X.Y.Z or latest +echo. +echo By default, elixir@latest and otp@latest are installed. +echo. +echo Options: +echo. +echo -f, --force Forces installation even if it was previously installed +echo -h, --help Prints this help +echo. +echo Examples: +echo. +echo install.bat +echo install.bat elixir@1.16.3 otp@26.2.5.4 +echo install.bat elixir@main +echo. +goto :eof + +:main +for %%i in (%*) do ( + set arg=%%i + + if "!arg:~0,7!" == "elixir@" ( + set "elixir_version=!arg:~7!" + ) else if "!arg:~0,4!" == "otp@" ( + set "otp_version=!arg:~4!" + ) else if "!arg!" == "-f" ( + set "force=true" + ) else if "!arg!" == "--force" ( + set "force=true" + ) else if "!arg!" == "-h" ( + call :usage + exit /b 0 + ) else if "!arg!" == "--help" ( + call :usage + exit /b 0 + ) else ( + echo error: unknown argument !arg! + exit /b 1 + ) +) + +if "!otp_version!" == "latest" ( + set "url=https://github.com/erlef/otp_builds/releases/latest" + for /f "tokens=2 delims= " %%a in ('curl -fsS --head "!url!" ^| findstr /I "^location:"') do set url=%%a + set "otp_version=!url:*releases/tag/OTP-=!" +) + +if "!elixir_version!" == "latest" ( + set "url=https://github.com/elixir-lang/elixir/releases/latest" + for /f "tokens=2 delims= " %%a in ('curl -fsS --head "!url!" ^| findstr /I "^location:"') do set url=%%a + set "elixir_version=!url:*releases/tag/v=!" +) + +for /f "tokens=1 delims=." %%A in ("!otp_version!") do set "elixir_otp_release=%%A" +for /f "tokens=1,2 delims=." %%A in ("!elixir_version!") do set "elixir_major_minor=%%A.%%B" +if "%elixir_major_minor%" == "1.15" ( + if %elixir_otp_release% GEQ 26 set "elixir_otp_release=26" +) else if "%elixir_major_minor%" == "1.16" ( + if %elixir_otp_release% GEQ 26 set "elixir_otp_release=26" +) else if "%elixir_major_minor%" == "1.14" ( + if %elixir_otp_release% GEQ 25 set "elixir_otp_release=25" +) + +set "root_dir=%USERPROFILE%\.elixir-install" +set "tmp_dir=%root_dir%\tmp" +mkdir %tmp_dir% 2>nul +set "otp_dir=%root_dir%\installs\otp\%otp_version%" +set "elixir_dir=%root_dir%\installs\elixir\%elixir_version%-otp-%elixir_otp_release%" + +call :install_otp +if %errorlevel% neq 0 exit /b 1 + +set /p="checking OTP... "&2 + exit 1 + ;; + esac + done + + root_dir="$HOME/.elixir-install" + tmp_dir="$root_dir/tmp" + mkdir -p "$tmp_dir" + + if [ "${otp_version}" = latest ]; then + url=$(curl -fsS --head https://github.com/erlef/otp_builds/releases/latest | grep -i '^location:' | awk '{print $2}' | tr -d '\r\n') + tag=$(basename "$url") + otp_version="${tag#OTP-}" + fi + + if [ "${elixir_version}" = latest ]; then + url=$(curl -fsS --head https://github.com/elixir-lang/elixir/releases/latest | grep -i '^location:' | awk '{print $2}' | tr -d '\r\n') + tag=$(basename "$url") + elixir_version="${tag#v}" + fi + + case "${otp_version}" in + master|maint*) + branch_version=$(curl -fsS https://raw.githubusercontent.com/erlang/otp/refs/heads/${otp_version}/OTP_VERSION | tr -d '\n') + elixir_otp_release="${branch_version%%.*}" + ;; + *) + elixir_otp_release="${otp_version%%.*}" + ;; + esac + + case "$elixir_version" in + 1.14.*) + [ "${elixir_otp_release}" -ge 25 ] && elixir_otp_release=25 + ;; + 1.15.*|1.16.*) + [ "${elixir_otp_release}" -ge 26 ] && elixir_otp_release=26 + ;; + *) + [ "${elixir_otp_release}" -ge 27 ] && elixir_otp_release=27 + ;; + esac + + otp_dir="$root_dir/installs/otp/$otp_version" + elixir_dir="${root_dir}/installs/elixir/${elixir_version}-otp-${elixir_otp_release}" + + install_otp & + install_elixir & + wait + + printf "checking OTP... " + export PATH="$otp_dir/bin:$PATH" + erl -noshell -eval 'io:put_chars(erlang:system_info(otp_release) ++ " ok\n"), halt().' + + printf "checking Elixir... " + "$elixir_dir/bin/elixir" -e 'IO.puts(System.version() <> " ok")' + + export PATH="$elixir_dir/bin:$PATH" +cat<