From 7ec3976b7af50d62e79df690a3f8d8042f5d5482 Mon Sep 17 00:00:00 2001 From: a-maze-d Date: Wed, 18 Sep 2024 11:49:36 +0200 Subject: [PATCH] Extend configuration for update check to include version (#2780) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: José Valim Co-authored-by: Jonatan Kłosko --- config/config.exs | 2 +- lib/livebook/config.ex | 5 +++-- lib/livebook/update_check.ex | 5 +++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/config/config.exs b/config/config.exs index 8cb179ed8..529ea8e65 100644 --- a/config/config.exs +++ b/config/config.exs @@ -38,7 +38,7 @@ config :livebook, shutdown_callback: nil, teams_auth?: false, teams_url: "https://teams.livebook.dev", - github_release_repo: "livebook-dev/livebook", + github_release_info: %{repo: "livebook-dev/livebook", version: Mix.Project.config()[:version]}, update_instructions_url: nil, within_iframe: false diff --git a/lib/livebook/config.ex b/lib/livebook/config.ex index 616fa99e3..7af8edff8 100644 --- a/lib/livebook/config.ex +++ b/lib/livebook/config.ex @@ -424,8 +424,9 @@ defmodule Livebook.Config do @doc """ Returns the GitHub org/repo where the releases are created. """ - def github_release_repo() do - Application.get_env(:livebook, :github_release_repo) + @spec github_release_info() :: %{repo: String.t(), version: String.t()} + def github_release_info() do + Application.get_env(:livebook, :github_release_info) end @doc """ diff --git a/lib/livebook/update_check.ex b/lib/livebook/update_check.ex index 3c4fb8ef0..19bea07db 100644 --- a/lib/livebook/update_check.ex +++ b/lib/livebook/update_check.ex @@ -128,7 +128,8 @@ defmodule Livebook.UpdateCheck do end defp fetch_latest_version() do - url = "https://api.github.com/repos/#{Livebook.Config.github_release_repo()}/releases/latest" + repo = Livebook.Config.github_release_info().repo + url = "https://api.github.com/repos/#{repo}/releases/latest" headers = [{"accept", "application/vnd.github.v3+json"}] case Livebook.Utils.HTTP.request(:get, url, headers: headers) do @@ -146,7 +147,7 @@ defmodule Livebook.UpdateCheck do end defp new_version(release) do - current_version = Livebook.Config.app_version() + current_version = Livebook.Config.github_release_info().version with %{ "tag_name" => "v" <> version,