Make Livebook version accessible at compile time (#2280)

Co-authored-by: José Valim <jose.valim@dashbit.co>
This commit is contained in:
Jonatan Kłosko 2023-10-17 19:17:09 +02:00 committed by GitHub
parent b5092c1f9f
commit 5d78db66e5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 11 additions and 9 deletions

View file

@ -613,10 +613,12 @@ defmodule Livebook.Config do
end
end
@app_version Mix.Project.config()[:version]
@doc """
Returns the current version of running Livebook.
"""
def app_version, do: Application.spec(:livebook, :vsn) |> List.to_string()
def app_version(), do: @app_version
defp parse_connection_config!(config) do
{node, cookie} = split_at_last_occurrence(config, ":")

View file

@ -85,7 +85,7 @@ defmodule Livebook.Hubs.TeamClient do
derived_key = Teams.derive_key(team.teams_key)
headers = [
{"x-lb-version", to_string(Application.spec(:livebook, :vsn))},
{"x-lb-version", Livebook.Config.app_version()},
{"x-user", to_string(team.user_id)},
{"x-org", to_string(team.org_id)},
{"x-org-key", to_string(team.org_key_id)},

View file

@ -149,7 +149,7 @@ defmodule Livebook.Teams.Requests do
token = "#{team.user_id}:#{team.org_id}:#{team.org_key_id}:#{team.session_token}"
[
{"x-lb-version", to_string(Application.spec(:livebook, :vsn))},
{"x-lb-version", Livebook.Config.app_version()},
{"authorization", "Bearer " <> token}
]
end

View file

@ -73,7 +73,7 @@ defmodule LivebookCLI do
IO.puts(:erlang.system_info(:system_version))
IO.puts("Elixir " <> System.build_info()[:build])
version = Application.spec(:livebook, :vsn)
version = Livebook.Config.app_version()
IO.puts("\nLivebook #{version}")
end
end

View file

@ -141,9 +141,9 @@ defmodule LivebookWeb.AppHelpers do
defp zta_options(), do: @zta_options
defp docker_tag_options() do
for image <- Livebook.Config.docker_images(), do: {image.tag, image.name}
end
@docker_tag_options for image <- Livebook.Config.docker_images(), do: {image.tag, image.name}
defp docker_tag_options(), do: @docker_tag_options
@doc """
Renders Docker deployment instruction for an app.

View file

@ -94,7 +94,7 @@ defmodule LivebookWeb.LayoutHelpers do
</span>
</.link>
<span class="text-gray-300 text-xs font-normal font-sans mx-2.5 pt-3 cursor-default">
v<%= Application.spec(:livebook, :vsn) %>
v<%= Livebook.Config.app_version() %>
</span>
</div>
<.sidebar_link title="Home" icon="home-6-line" to={~p"/"} current={@current_page} />

View file

@ -60,7 +60,7 @@ defmodule LivebookWeb.SettingsLive do
<% end %>
</.labeled_text>
<.labeled_text label="Livebook">
v<%= Application.spec(:livebook, :vsn) %>
v<%= Livebook.Config.app_version() %>
</.labeled_text>
<.labeled_text label="Elixir">
v<%= System.version() %>