mirror of
https://git.eden-emu.dev/eden-emu/eden
synced 2026-04-25 20:29:08 +02:00
[frontend] Change update checker to use new endpoints (#3879)
Related: [RFC3870](https://git.eden-emu.dev/eden-emu/eden/issues/3870) Nightly and stable releases are now served through `nightly.eden-emu.dev` and `stable.eden-emu.dev`, respectively. These are stored using Backblaze, and served and cached through the Cloudflare CDN. Ideally this will reduce costs, though I'll have to wait for my first invoice to be certain. These will serve as the new download locations going forward. Since we have full control over this API, we can make any adjustments we want as needed. For now, all it does is provide `tag_name`, `name`, and `body`, the latter of which will be used for the upcoming updater PR. Signed-off-by: crueter <crueter@eden-emu.dev> Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3879 Reviewed-by: CamilleLaVey <camillelavey99@gmail.com> Reviewed-by: MaranBr <maranbr@eden-emu.dev>
This commit is contained in:
parent
b3cc8723c1
commit
26ce96297c
4 changed files with 21 additions and 58 deletions
|
|
@ -35,17 +35,17 @@ set(GIT_DESC ${BUILD_VERSION})
|
||||||
# Generate cpp with Git revision from template
|
# Generate cpp with Git revision from template
|
||||||
# Also if this is a CI build, add the build name (ie: Nightly, Canary) to the scm_rev file as well
|
# Also if this is a CI build, add the build name (ie: Nightly, Canary) to the scm_rev file as well
|
||||||
|
|
||||||
# Auto-updater metadata! Must somewhat mirror GitHub API endpoint
|
# Auto-updater metadata! Must somewhat mirror GitHub/Forgejo API endpoint
|
||||||
|
|
||||||
|
set(BUILD_AUTO_UPDATE_API_PATH "/latest/release.json")
|
||||||
if (NIGHTLY_BUILD)
|
if (NIGHTLY_BUILD)
|
||||||
set(BUILD_AUTO_UPDATE_WEBSITE "https://git.eden-emu.dev")
|
set(BUILD_AUTO_UPDATE_WEBSITE "https://git.eden-emu.dev")
|
||||||
set(BUILD_AUTO_UPDATE_API "git.eden-emu.dev")
|
set(BUILD_AUTO_UPDATE_API "nightly.eden-emu.dev")
|
||||||
set(BUILD_AUTO_UPDATE_API_PATH "/api/v1/repos/")
|
|
||||||
set(BUILD_AUTO_UPDATE_REPO "eden-ci/nightly")
|
set(BUILD_AUTO_UPDATE_REPO "eden-ci/nightly")
|
||||||
set(REPO_NAME "Eden Nightly")
|
set(REPO_NAME "Eden Nightly")
|
||||||
else()
|
else()
|
||||||
set(BUILD_AUTO_UPDATE_WEBSITE "https://git.eden-emu.dev")
|
set(BUILD_AUTO_UPDATE_WEBSITE "https://git.eden-emu.dev")
|
||||||
set(BUILD_AUTO_UPDATE_API "git.eden-emu.dev")
|
set(BUILD_AUTO_UPDATE_API "stable.eden-emu.dev")
|
||||||
set(BUILD_AUTO_UPDATE_API_PATH "/api/v1/repos/")
|
|
||||||
set(BUILD_AUTO_UPDATE_REPO "eden-emu/eden")
|
set(BUILD_AUTO_UPDATE_REPO "eden-emu/eden")
|
||||||
set(REPO_NAME "Eden")
|
set(REPO_NAME "Eden")
|
||||||
endif()
|
endif()
|
||||||
|
|
|
||||||
|
|
@ -1726,9 +1726,8 @@ JNIEXPORT jstring JNICALL Java_org_yuzu_yuzu_1emu_NativeLibrary_getUpdateUrl(
|
||||||
jobject obj,
|
jobject obj,
|
||||||
jstring version) {
|
jstring version) {
|
||||||
const char* version_str = env->GetStringUTFChars(version, nullptr);
|
const char* version_str = env->GetStringUTFChars(version, nullptr);
|
||||||
const std::string url = fmt::format("{}/{}/releases/tag/{}",
|
const std::string url = fmt::format("{}/{}",
|
||||||
std::string{Common::g_build_auto_update_website},
|
std::string{Common::g_build_auto_update_api},
|
||||||
std::string{Common::g_build_auto_update_repo},
|
|
||||||
version_str);
|
version_str);
|
||||||
env->ReleaseStringUTFChars(version, version_str);
|
env->ReleaseStringUTFChars(version, version_str);
|
||||||
return env->NewStringUTF(url.c_str());
|
return env->NewStringUTF(url.c_str());
|
||||||
|
|
@ -1760,11 +1759,10 @@ JNIEXPORT jstring JNICALL Java_org_yuzu_yuzu_1emu_NativeLibrary_getUpdateApkUrl(
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string apk_filename = fmt::format("Eden-Android-{}-{}.apk", artifact_str, variant);
|
const std::string apk_filename = fmt::format("Eden-Android-{}-{}.apk", artifact_str, variant);
|
||||||
const std::string url = fmt::format("{}/{}/releases/download/{}/{}",
|
|
||||||
std::string{Common::g_build_auto_update_website},
|
const std::string url = fmt::format("{}/{}/{}",
|
||||||
std::string{Common::g_build_auto_update_repo},
|
std::string{Common::g_build_auto_update_api},
|
||||||
version_str,
|
version_str, apk_filename);
|
||||||
apk_filename);
|
|
||||||
|
|
||||||
env->ReleaseStringUTFChars(tag, version_str);
|
env->ReleaseStringUTFChars(tag, version_str);
|
||||||
env->ReleaseStringUTFChars(artifact, artifact_str);
|
env->ReleaseStringUTFChars(artifact, artifact_str);
|
||||||
|
|
|
||||||
|
|
@ -80,55 +80,24 @@ std::optional<std::string> UpdateChecker::GetResponse(std::string url, std::stri
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<UpdateChecker::Update> UpdateChecker::GetLatestRelease(bool include_prereleases) {
|
std::optional<UpdateChecker::Update> UpdateChecker::GetLatestRelease() {
|
||||||
#ifdef YUZU_BUNDLED_OPENSSL
|
#ifdef YUZU_BUNDLED_OPENSSL
|
||||||
const auto update_check_url = fmt::format("https://{}", Common::g_build_auto_update_api);
|
const auto update_check_url = fmt::format("https://{}", Common::g_build_auto_update_api);
|
||||||
#else
|
#else
|
||||||
const auto update_check_url = std::string{Common::g_build_auto_update_api};
|
const auto update_check_url = std::string{Common::g_build_auto_update_api};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
auto update_check_path = fmt::format("{}{}", std::string{Common::g_build_auto_update_api_path},
|
auto update_check_path = std::string{Common::g_build_auto_update_api_path};
|
||||||
std::string{Common::g_build_auto_update_repo});
|
|
||||||
try {
|
try {
|
||||||
if (include_prereleases) { // This can return either a prerelease or a stable release,
|
const auto response = UpdateChecker::GetResponse(update_check_url, update_check_path);
|
||||||
// whichever is more recent.
|
|
||||||
const auto update_check_tags_path = update_check_path + "/tags";
|
|
||||||
const auto update_check_releases_path = update_check_path + "/releases";
|
|
||||||
|
|
||||||
const auto tags_response = UpdateChecker::GetResponse(update_check_url, update_check_tags_path);
|
if (!response)
|
||||||
const auto releases_response = UpdateChecker::GetResponse(update_check_url, update_check_releases_path);
|
return {};
|
||||||
|
|
||||||
if (!tags_response || !releases_response)
|
const std::string latest_tag = nlohmann::json::parse(response.value()).at("tag_name");
|
||||||
return {};
|
const std::string latest_name = nlohmann::json::parse(response.value()).at("name");
|
||||||
|
|
||||||
const std::string latest_tag
|
|
||||||
= nlohmann::json::parse(tags_response.value()).at(0).at("name");
|
|
||||||
const std::string latest_name =
|
|
||||||
nlohmann::json::parse(releases_response.value()).at(0).at("name");
|
|
||||||
|
|
||||||
const bool latest_tag_has_release = releases_response.value().find(
|
|
||||||
fmt::format("\"{}\"", latest_tag))
|
|
||||||
!= std::string::npos;
|
|
||||||
|
|
||||||
// If there is a newer tag, but that tag has no associated release, don't prompt the
|
|
||||||
// user to update.
|
|
||||||
if (!latest_tag_has_release)
|
|
||||||
return {};
|
|
||||||
|
|
||||||
return Update{latest_tag, latest_name};
|
|
||||||
} else { // This is a stable release, only check for other stable releases.
|
|
||||||
update_check_path += "/releases/latest";
|
|
||||||
const auto response = UpdateChecker::GetResponse(update_check_url, update_check_path);
|
|
||||||
|
|
||||||
if (!response)
|
|
||||||
return {};
|
|
||||||
|
|
||||||
const std::string latest_tag = nlohmann::json::parse(response.value()).at("tag_name");
|
|
||||||
const std::string latest_name = nlohmann::json::parse(response.value()).at("name");
|
|
||||||
|
|
||||||
return Update{latest_tag, latest_name};
|
|
||||||
}
|
|
||||||
|
|
||||||
|
return Update{latest_tag, latest_name};
|
||||||
} catch (nlohmann::detail::out_of_range&) {
|
} catch (nlohmann::detail::out_of_range&) {
|
||||||
LOG_ERROR(Frontend,
|
LOG_ERROR(Frontend,
|
||||||
"Parsing JSON response from {}{} failed during update check: "
|
"Parsing JSON response from {}{} failed during update check: "
|
||||||
|
|
@ -147,12 +116,8 @@ std::optional<UpdateChecker::Update> UpdateChecker::GetLatestRelease(bool includ
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<UpdateChecker::Update> UpdateChecker::GetUpdate() {
|
std::optional<UpdateChecker::Update> UpdateChecker::GetUpdate() {
|
||||||
const bool is_prerelease = ((strstr(Common::g_build_version, "pre-alpha") != NULL) ||
|
|
||||||
(strstr(Common::g_build_version, "alpha") != NULL) ||
|
|
||||||
(strstr(Common::g_build_version, "beta") != NULL) ||
|
|
||||||
(strstr(Common::g_build_version, "rc") != NULL));
|
|
||||||
const std::optional<UpdateChecker::Update> latest_release_tag =
|
const std::optional<UpdateChecker::Update> latest_release_tag =
|
||||||
UpdateChecker::GetLatestRelease(is_prerelease);
|
UpdateChecker::GetLatestRelease();
|
||||||
|
|
||||||
if (!latest_release_tag)
|
if (!latest_release_tag)
|
||||||
goto empty;
|
goto empty;
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,6 @@ typedef struct {
|
||||||
} Update;
|
} Update;
|
||||||
|
|
||||||
std::optional<std::string> GetResponse(std::string url, std::string path);
|
std::optional<std::string> GetResponse(std::string url, std::string path);
|
||||||
std::optional<Update> GetLatestRelease(bool include_prereleases);
|
std::optional<Update> GetLatestRelease();
|
||||||
std::optional<Update> GetUpdate();
|
std::optional<Update> GetUpdate();
|
||||||
} // namespace UpdateChecker
|
} // namespace UpdateChecker
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue