diff --git a/CMakeModules/GenerateSCMRev.cmake b/CMakeModules/GenerateSCMRev.cmake index a905a9563a..40c64fea1e 100644 --- a/CMakeModules/GenerateSCMRev.cmake +++ b/CMakeModules/GenerateSCMRev.cmake @@ -34,6 +34,11 @@ set(GIT_DESC ${BUILD_VERSION}) # Generate cpp with Git revision from template +# TODO(crueter): Stable releases feed. +set(BUILD_AUTO_UPDATE_STABLE_REPO "eden-emu/eden") +set(BUILD_AUTO_UPDATE_STABLE_API "git.eden-emu.dev") +set(BUILD_AUTO_UPDATE_STABLE_API_PATH "/api/v1/repos/") + set(BUILD_AUTO_UPDATE_API_PATH "/latest/release.json") if (NIGHTLY_BUILD) set(BUILD_AUTO_UPDATE_WEBSITE "https://git.eden-emu.dev") diff --git a/src/common/net/net.cpp b/src/common/net/net.cpp index ba7e78f5cd..acf54f873f 100644 --- a/src/common/net/net.cpp +++ b/src/common/net/net.cpp @@ -22,7 +22,8 @@ namespace Common::Net { -std::vector Release::GetAssets() const { +std::vector Release::GetPlatformAssets() const { + // FIXME(crueter): use search strings based on platform's assets, or a fallback name if not #ifdef _WIN32 static constexpr const std::string prefix = "Eden-Windows"; #elif defined(__APPLE__) @@ -35,7 +36,6 @@ std::vector Release::GetAssets() const { #endif std::vector suffixes; - std::vector assets; // TODO(crueter): Need better handling for this as a whole. #ifdef NIGHTLY_BUILD @@ -63,7 +63,7 @@ std::vector Release::GetAssets() const { #ifdef _WIN32 #ifdef ARCHITECTURE_x86_64 make_asset(QT_TR_NOOP("Standard"), "-amd64-msvc-standard.zip"), - make_asset(QT_TR_NOOP("MinGW"), "-mingw-amd64-gcc-standard.zip"), + // make_asset(QT_TR_NOOP("MinGW"), "-mingw-amd64-gcc-standard.zip"), make_asset(QT_TR_NOOP("PGO"), "-mingw-amd64-clang-pgo.zip") #elif defined(ARCHITECTURE_arm64) make_asset(QT_TR_NOOP("Standard"), "-mingw-arm64-clang-standard.zip"), @@ -133,9 +133,28 @@ std::optional Release::FromJson(const nlohmann::json& json, const std:: const auto fallback_html = fmt::format("{}/tag/{}", release_base, rel.tag); rel.html_url = json.value("html_url", fallback_html); - const auto base_download_url = fmt::format("/{}/releases/download/{}", repo, rel.tag); + // This is our own "fake" API. + if (json.contains("base")) { + const auto base = json.value("base", fmt::format("https://{}", Common::g_build_auto_update_api)); + rel.base_download_url = fmt::format("{}/{}", base, rel.tag); - rel.base_download_url = base_download_url; + // Assets are easy :) + rel.assets = json.value("assets", std::vector{}); + } else { + const auto base_download_url = fmt::format("/{}/releases/download/{}", repo, rel.tag); + + rel.base_download_url = base_download_url; + + // assets are a bit more complex here. :( + std::vector assets; + const nlohmann::json& arr = json["assets"]; + for (const auto &obj : arr) { + const auto url = obj.value("browser_download_url", std::string{}); + assets.emplace_back(url); + } + + rel.assets = assets; + } return rel; } @@ -227,6 +246,7 @@ std::optional MakeRequest(const std::string& url, const std::string std::vector GetReleases() { const auto body = GetReleasesBody(); + if (!body) { LOG_WARNING(Common, "Failed to get stable releases"); return {}; @@ -238,9 +258,7 @@ std::vector GetReleases() { } std::optional GetLatestRelease() { - const auto releases_path = - fmt::format("{}/{}/releases/latest", Common::g_build_auto_update_api_path, - Common::g_build_auto_update_repo); + const auto releases_path = Common::g_build_auto_update_api_path; const auto url = fmt::format("https://{}", Common::g_build_auto_update_api); const auto body = MakeRequest(url, releases_path); diff --git a/src/common/net/net.h b/src/common/net/net.h index ea0ea8912a..b07caabe20 100644 --- a/src/common/net/net.h +++ b/src/common/net/net.h @@ -26,12 +26,14 @@ typedef struct Release { std::string html_url; std::string host; + std::vector assets; + u64 id; u64 published; bool prerelease; // Get the relevant list of assets for the current platform. - std::vector GetAssets() const; + std::vector GetPlatformAssets() const; static std::optional FromJson(const nlohmann::json& json, const std::string &host, const std::string& repo); static std::optional FromJson(const std::string_view& json, const std::string &host, const std::string& repo); diff --git a/src/yuzu/updater/update_dialog.cpp b/src/yuzu/updater/update_dialog.cpp index d009d2750e..addbff6101 100644 --- a/src/yuzu/updater/update_dialog.cpp +++ b/src/yuzu/updater/update_dialog.cpp @@ -36,7 +36,7 @@ UpdateDialog::UpdateDialog(const Common::Net::Release& release, QWidget* parent) ui->body->setMarkdown(QString::fromStdString(text)); // TODO(crueter): Find a way to set default - const auto assets = release.GetAssets(); + const auto assets = release.GetPlatformAssets(); if (assets.empty()) { ui->groupBox->setHidden(true); @@ -45,7 +45,7 @@ UpdateDialog::UpdateDialog(const Common::Net::Release& release, QWidget* parent) }); } else { u32 i = 0; - for (const Common::Net::Asset& a : release.GetAssets()) { + for (const Common::Net::Asset& a : release.GetPlatformAssets()) { QRadioButton* r = new QRadioButton(tr(a.name.c_str()), this); if (i == 0) r->setChecked(true); ++i;