Skip to content

Commit

Permalink
Ignore unstable(alfa/beta/rc) versions for stable releases
Browse files Browse the repository at this point in the history
  • Loading branch information
Eism committed Jun 29, 2023
1 parent 136baac commit 1ba4933
Show file tree
Hide file tree
Showing 11 changed files with 47 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
workflow_dispatch:
inputs:
mode:
description: 'Mode: stable, testing'
description: 'Mode: stable, testing(alpha, beta, rc)'
required: true
default: 'testing'
tag:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci_release_clear.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ on:
workflow_dispatch:
inputs:
mode:
description: 'Mode: stable, testing'
description: 'Mode: stable, testing(alpha, beta, rc)'
required: true
default: 'stable'
default: 'testing'

defaults:
run:
Expand Down
6 changes: 6 additions & 0 deletions SetupConfigure.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,20 @@ if(BUILD_MODE MATCHES "DEV")
set(MUSESCORE_UNSTABLE ON)
set(MUSESCORE_VERSION_LABEL "dev")
set(MUSESCORE_NAME_VERSION "${MUSESCORE_NAME} ${MUSESCORE_VERSION_MAJOR}")
set(MUSESCORE_ALLOW_UPDATE_ON_PRERELEASE OFF)
endif()

if(BUILD_MODE MATCHES "TESTING")
set(MUSESCORE_UNSTABLE OFF)
set(MUSESCORE_VERSION_LABEL "Testing")
set(MUSESCORE_NAME_VERSION "${MUSESCORE_NAME} ${MUSESCORE_VERSION_MAJOR}.${MUSESCORE_VERSION_MINOR} ${MUSESCORE_VERSION_LABEL}")
set(MUSESCORE_ALLOW_UPDATE_ON_PRERELEASE ON)
endif()

if(BUILD_MODE MATCHES "RELEASE")
set(MUSESCORE_UNSTABLE OFF)
set(MUSESCORE_NAME_VERSION "${MUSESCORE_NAME} ${MUSESCORE_VERSION_MAJOR}")
set(MUSESCORE_ALLOW_UPDATE_ON_PRERELEASE OFF)
endif()

if (MUSESCORE_UNSTABLE)
Expand Down Expand Up @@ -230,6 +233,9 @@ if (MUSESCORE_UNSTABLE)
add_definitions(-DMUSESCORE_UNSTABLE)
endif()

if (MUSESCORE_ALLOW_UPDATE_ON_PRERELEASE)
add_definitions(-DMUSESCORE_ALLOW_UPDATE_ON_PRERELEASE)
endif()

function(def_opt name val)
if (${val})
Expand Down
5 changes: 5 additions & 0 deletions src/framework/global/types/version.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,11 @@ void Version::setSuffix(const String& suffix)
m_suffixVersion = versionSuffix.second;
}

bool Version::preRelease() const
{
return !suffix().isEmpty();
}

mu::String Version::toString()
{
String res = String(u"%1.%2.%3").arg(m_major, m_minor, m_patch);
Expand Down
4 changes: 3 additions & 1 deletion src/framework/global/types/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,13 @@ class Version
int majorVersion() const;
int minorVersion() const;
int patchVersion() const;

String suffix() const;
int suffixVersion() const;

void setSuffix(const String& suffix);

bool preRelease() const;

String toString();

bool operator <(const Version& other) const;
Expand Down
4 changes: 2 additions & 2 deletions src/stubs/update/updateconfigurationstub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ bool UpdateConfigurationStub::isAppUpdatable() const
return false;
}

bool UpdateConfigurationStub::isTestingMode() const
bool UpdateConfigurationStub::allowUpdateOnPreRelease() const
{
return false;
}

void UpdateConfigurationStub::setIsTestingMode(bool)
void UpdateConfigurationStub::setAllowUpdateOnPreRelease(bool)
{
}

Expand Down
4 changes: 2 additions & 2 deletions src/stubs/update/updateconfigurationstub.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ class UpdateConfigurationStub : public IUpdateConfiguration
public:
bool isAppUpdatable() const override;

bool isTestingMode() const override;
void setIsTestingMode(bool isTesting) override;
bool allowUpdateOnPreRelease() const override;
void setAllowUpdateOnPreRelease(bool allow) override;

bool needCheckForUpdate() const override;
void setNeedCheckForUpdate(bool needCheck) override;
Expand Down
21 changes: 14 additions & 7 deletions src/update/internal/updateconfiguration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ using namespace mu::framework;
static const std::string module_name("update");

static const Settings::Key CHECK_FOR_UPDATE_KEY(module_name, "application/checkForUpdate");
static const Settings::Key CHECK_FOR_UPDATE_TESTING_MODE_KEY(module_name, "application/checkForUpdateTestingMode");
static const Settings::Key ALLOW_UPDATE_ON_PRERELEASE(module_name, "application/allowUpdateOnPreRelease");
static const Settings::Key SKIPPED_VERSION_KEY(module_name, "application/skippedVersion");

static const std::string PRIVACY_POLICY_URL_PATH("/about/desktop-privacy-policy");
Expand All @@ -56,22 +56,28 @@ void UpdateConfiguration::init()
{
settings()->setDefaultValue(CHECK_FOR_UPDATE_KEY, Val(isAppUpdatable()));

settings()->setDefaultValue(CHECK_FOR_UPDATE_TESTING_MODE_KEY, Val(false));
bool allowUpdateOnPreRelease = false;
#ifdef MUSESCORE_ALLOW_UPDATE_ON_PRERELEASE
allowUpdateOnPreRelease = true;
#else
allowUpdateOnPreRelease = false;
#endif
settings()->setDefaultValue(ALLOW_UPDATE_ON_PRERELEASE, Val(allowUpdateOnPreRelease));
}

bool UpdateConfiguration::isAppUpdatable() const
{
return true;
}

bool UpdateConfiguration::isTestingMode() const
bool UpdateConfiguration::allowUpdateOnPreRelease() const
{
return settings()->value(CHECK_FOR_UPDATE_TESTING_MODE_KEY).toBool();
return settings()->value(ALLOW_UPDATE_ON_PRERELEASE).toBool();
}

void UpdateConfiguration::setIsTestingMode(bool isTesting)
void UpdateConfiguration::setAllowUpdateOnPreRelease(bool allow)
{
settings()->setSharedValue(CHECK_FOR_UPDATE_TESTING_MODE_KEY, Val(isTesting));
settings()->setSharedValue(ALLOW_UPDATE_ON_PRERELEASE, Val(allow));
}

bool UpdateConfiguration::needCheckForUpdate() const
Expand All @@ -96,7 +102,8 @@ void UpdateConfiguration::setSkippedReleaseVersion(const std::string& version) c

std::string UpdateConfiguration::checkForUpdateUrl() const
{
return !isTestingMode() ? "https://updates.musescore.org/feed/latest.xml" : "https://updates.musescore.org/feed/latest.test.xml";
return !allowUpdateOnPreRelease() ? "https://updates.musescore.org/feed/latest.xml"
: "https://updates.musescore.org/feed/latest.test.xml";
}

mu::network::RequestHeaders UpdateConfiguration::checkForUpdateHeaders() const
Expand Down
4 changes: 2 additions & 2 deletions src/update/internal/updateconfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ class UpdateConfiguration : public IUpdateConfiguration, public async::Asyncable

bool isAppUpdatable() const override;

bool isTestingMode() const override;
void setIsTestingMode(bool isTesting) override;
bool allowUpdateOnPreRelease() const override;
void setAllowUpdateOnPreRelease(bool allow) override;

bool needCheckForUpdate() const override;
void setNeedCheckForUpdate(bool needCheck) override;
Expand Down
8 changes: 8 additions & 0 deletions src/update/internal/updateservice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,14 @@ mu::RetVal<ReleaseInfo> UpdateService::checkForUpdate()

Version current(MUVersion::fullVersion());
Version update(String::fromStdString(releaseInfo.val.version));

bool allowUpdateOnPreRelease = configuration()->allowUpdateOnPreRelease();
bool isPreRelease = update.preRelease();

if (!allowUpdateOnPreRelease && isPreRelease) {
return result;
}

if (update <= current) {
return result;
}
Expand Down
4 changes: 2 additions & 2 deletions src/update/iupdateconfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ class IUpdateConfiguration : MODULE_EXPORT_INTERFACE

virtual bool isAppUpdatable() const = 0;

virtual bool isTestingMode() const = 0;
virtual void setIsTestingMode(bool isTesting) = 0;
virtual bool allowUpdateOnPreRelease() const = 0;
virtual void setAllowUpdateOnPreRelease(bool allow) = 0;

virtual bool needCheckForUpdate() const = 0;
virtual void setNeedCheckForUpdate(bool needCheck) = 0;
Expand Down

0 comments on commit 1ba4933

Please sign in to comment.