Skip to content

Commit

Permalink
only test on OTP >= 24
Browse files Browse the repository at this point in the history
  • Loading branch information
SteffenDE committed Aug 19, 2024
1 parent d7419b8 commit e2e7fea
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ jobs:
matrix:
include:
- elixir: 1.11.4
otp: 22.3
otp: 24.3

- elixir: 1.12.3
otp: 23.3
otp: 24.3

- elixir: 1.14.5
otp: 25.3.2.9

- elixir: 1.16.2
otp: 26.2
- elixir: 1.17.2
otp: 27.0
lint: true
installer: true

Expand Down
17 changes: 7 additions & 10 deletions lib/mix/tasks/phx.gen.release.ex
Original file line number Diff line number Diff line change
Expand Up @@ -195,17 +195,18 @@ defmodule Mix.Tasks.Phx.Gen.Release do
|> map_size() > 0
end

defp elixir_and_debian_vsn(elixir_vsn, otp_vsn, debian) do
@debian "bookworm"
defp elixir_and_debian_vsn(elixir_vsn, otp_vsn) do
url =
"https://hub.docker.com/v2/namespaces/hexpm/repositories/elixir/tags?name=#{elixir_vsn}-erlang-#{otp_vsn}-debian-#{debian}-"
"https://hub.docker.com/v2/namespaces/hexpm/repositories/elixir/tags?name=#{elixir_vsn}-erlang-#{otp_vsn}-debian-#{@debian}-"

fetch_body!(url)
|> Phoenix.json_library().decode!()
|> Map.fetch!("results")
|> Enum.find_value(:error, fn %{"name" => name} ->
if String.ends_with?(name, "-slim") do
elixir_vsn = name |> String.split("-") |> List.first()
%{"vsn" => vsn} = Regex.named_captures(~r/.*debian-#{debian}-(?<vsn>.*)-slim/, name)
%{"vsn" => vsn} = Regex.named_captures(~r/.*debian-#{@debian}-(?<vsn>.*)-slim/, name)
{:ok, elixir_vsn, vsn}
end
end)
Expand All @@ -220,17 +221,13 @@ defmodule Mix.Tasks.Phx.Gen.Release do

otp_vsn = otp_vsn()

# hex bob only builds on bookworm for erlang >= 24
otp_major_vsn = :erlang.system_info(:otp_release) |> List.to_integer()
debian = if otp_major_vsn >= 24, do: "bookworm", else: "bullseye"

vsns =
case elixir_and_debian_vsn(wanted_elixir_vsn, otp_vsn, debian) do
case elixir_and_debian_vsn(wanted_elixir_vsn, otp_vsn) do
{:ok, elixir_vsn, debian_vsn} ->
{:ok, elixir_vsn, debian_vsn}

:error ->
case elixir_and_debian_vsn("", otp_vsn, debian) do
case elixir_and_debian_vsn("", otp_vsn) do
{:ok, elixir_vsn, debian_vsn} ->
Logger.warning(
"Docker image for Elixir #{wanted_elixir_vsn} not found, defaulting to Elixir #{elixir_vsn}"
Expand All @@ -247,7 +244,7 @@ defmodule Mix.Tasks.Phx.Gen.Release do
{:ok, elixir_vsn, debian_vsn} ->
binding =
Keyword.merge(binding,
debian: debian,
debian: @debian,
debian_vsn: debian_vsn,
elixir_vsn: elixir_vsn,
otp_vsn: otp_vsn
Expand Down

0 comments on commit e2e7fea

Please sign in to comment.