Fix update notice for versioned releases
Some checks failed
Release App / release-app (push) Has been cancelled

This commit is contained in:
2026-04-24 15:06:07 +03:00
parent 891fc73e25
commit 2e79f2b00b
4 changed files with 14 additions and 218 deletions

View File

@@ -13,6 +13,13 @@ namespace telegram_tui {
namespace {
std::string trim_release_tag_prefix(const std::string &value) {
if (!value.empty() && (value[0] == 'v' || value[0] == 'V')) {
return value.substr(1);
}
return value;
}
bool is_truthy_env_value(const std::string &value) {
return value == "1" || value == "true" || value == "TRUE" || value == "yes" ||
value == "YES" || value == "on" || value == "ON";
@@ -50,7 +57,7 @@ std::string run_command_capture(const std::string &command) {
std::optional<std::string> fetch_update_notice() {
static constexpr const char *kLatestReleaseApiUrl =
"https://git.mshq.dev/api/v1/repos/AxiFisk/shinoa/releases/tags/latest";
"https://git.mshq.dev/api/v1/repos/AxiFisk/shinoa/releases/latest";
if (std::string(TELEGRAM_TUI_BUILD_COMMIT).empty()) {
return std::nullopt;
@@ -64,6 +71,11 @@ std::optional<std::string> fetch_update_notice() {
try {
const json release = json::parse(response, nullptr, true, true);
const std::string latest_tag = trim_release_tag_prefix(safe_string(release, "tag_name"));
if (!latest_tag.empty() && latest_tag == TELEGRAM_TUI_PROJECT_VERSION) {
return std::nullopt;
}
const std::string target_commit = safe_string(release, "target_commitish");
if (target_commit.empty()) {
return std::nullopt;

View File

@@ -1,5 +1,6 @@
#pragma once
#define TELEGRAM_TUI_PROJECT_VERSION "@PROJECT_VERSION@"
#define TELEGRAM_TUI_BUILD_COMMIT "@TELEGRAM_TUI_BUILD_COMMIT@"
#define TELEGRAM_TUI_BUILD_VERSION "@TELEGRAM_TUI_BUILD_VERSION@"
#define TELEGRAM_TUI_BUILD_API_ID "@TELEGRAM_TUI_BUILD_API_ID@"