Extend configuration for update check to include version (#2780)

Co-authored-by: José Valim <jose.valim@gmail.com>
Co-authored-by: Jonatan Kłosko <jonatanklosko@gmail.com>
This commit is contained in:
a-maze-d 2024-09-18 11:49:36 +02:00 committed by GitHub
parent 6573f0204e
commit 7ec3976b7a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 7 additions and 5 deletions

View file

@ -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

View file

@ -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 """

View file

@ -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,