Skip to content

Commit

Permalink
Extend configuration for update check to include version (#2780)
Browse files Browse the repository at this point in the history
Co-authored-by: José Valim <[email protected]>
Co-authored-by: Jonatan Kłosko <[email protected]>
  • Loading branch information
3 people authored Sep 18, 2024
1 parent 6573f02 commit 7ec3976
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 3 additions & 2 deletions lib/livebook/config.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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 """
Expand Down
5 changes: 3 additions & 2 deletions lib/livebook/update_check.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down

0 comments on commit 7ec3976

Please sign in to comment.