From 6f2d96b4e98503b8ad66b84555c8e7dc6324c20c Mon Sep 17 00:00:00 2001 From: lasconic Date: Tue, 17 Jul 2018 16:08:03 +0200 Subject: [PATCH] fix #267644: Add auto updater to MuseScore development versions --- .appveyor.yml | 11 +++++++++++ Makefile | 3 +++ Makefile.mingw | 1 + Makefile.osx | 5 +++++ build/appveyor/after_build.bat | 25 ++++++++++++++++++++++++- build/appveyor/build_script.bat | 4 ++-- build/config.h.in | 1 + build/travis/job2_AppImage/build.sh | 1 + build/travis/job_macos/script.sh | 27 ++++++++++++++++++++++++++- mscore/updatechecker.cpp | 15 ++++++--------- mtest/libmscore/utils/tst_utils.cpp | 7 +++++++ 11 files changed, 87 insertions(+), 13 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index eef90cec1f..e7ca409881 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -48,3 +48,14 @@ after_build: artifacts: - path: $(ARTIFACT_NAME) +deploy: + provider: S3 + access_key_id: + secure: k68f3wMKIC5AzrfNMuC4kdPaxzvKdFVkRsietUKqc+E= + secret_access_key: + secure: IbpdpiHzGfMasaSA6uGrskE4xu9wE+HzElW7tIDOUww+ivHj+gN+mPgUHKCcV9Cn + bucket: update.musescore.org + region: us-east-1 + set_public: true + artifact: C:\MuseScore\update_win_nightly.xml + diff --git a/Makefile b/Makefile index 43713bbb72..67dcbbd488 100644 --- a/Makefile +++ b/Makefile @@ -24,6 +24,7 @@ CPUS := $(shell getconf _NPROCESSORS_ONLN 2>/dev/null || getconf NPROCESSOR PREFIX = "/usr/local" VERSION = "3.0b-${REVISION}" #VERSION = 3.0.0 +BUILD_NUMBER="" # Override SUFFIX and LABEL when multiple versions are installed to avoid conflicts. SUFFIX=""# E.g.: SUFFIX="dev" --> "mscore" becomes "mscoredev" @@ -54,6 +55,7 @@ release: -DCMAKE_INSTALL_PREFIX="${PREFIX}" \ -DMSCORE_INSTALL_SUFFIX="${SUFFIX}" \ -DMUSESCORE_LABEL="${LABEL}" \ + -DCMAKE_BUILD_NUMBER="${BUILD_NUMBER}" \ -DBUILD_LAME="${BUILD_LAME}" \ -DBUILD_PULSEAUDIO="${BUILD_PULSEAUDIO}" \ -DBUILD_JACK="${BUILD_JACK}" \ @@ -80,6 +82,7 @@ debug: -DCMAKE_INSTALL_PREFIX="${PREFIX}" \ -DMSCORE_INSTALL_SUFFIX="${SUFFIX}" \ -DMUSESCORE_LABEL="${LABEL}" \ + -DCMAKE_BUILD_NUMBER="${BUILD_NUMBER}" \ -DBUILD_LAME="${BUILD_LAME}" \ -DBUILD_PULSEAUDIO="${BUILD_PULSEAUDIO}" \ -DBUILD_JACK="${BUILD_JACK}" \ diff --git a/Makefile.mingw b/Makefile.mingw index 8e9d105a1e..749447ef1e 100644 --- a/Makefile.mingw +++ b/Makefile.mingw @@ -22,6 +22,7 @@ REVISION = $(shell type mscore\revision.h) VERSION = 3.0b-${REVISION} #VERSION = 3.0.0 +BUILD_NUMBER="" CPUS = %NUMBER_OF_PROCESSORS% BUILD_FOR_WINSTORE="OFF" # Override with "ON" to enable. diff --git a/Makefile.osx b/Makefile.osx index db6077bc17..bcbea6d12d 100644 --- a/Makefile.osx +++ b/Makefile.osx @@ -21,6 +21,7 @@ REVISION = `cat mscore/revision.h` VERSION = "3.0b-${REVISION}" #VERSION = 3.0.0 +BUILD_NUMBER = "" PREFIX=../applebuild XCODEPROJ = mscore.xcodeproj @@ -35,6 +36,7 @@ release: mkdir build.release; \ cd build.release; \ cmake -DCMAKE_INSTALL_PREFIX="${PREFIX}" -DCMAKE_BUILD_TYPE=RELEASE \ + -DCMAKE_BUILD_NUMBER="${BUILD_NUMBER}" \ .. -G Xcode; \ xcodebuild -project ${XCODEPROJ} -target lrelease; \ $(FORMATTER_START) xcodebuild -project ${XCODEPROJ} -configuration Release -target ALL_BUILD $(FORMATTER_END); \ @@ -43,6 +45,7 @@ debug: mkdir build.debug; \ cd build.debug; \ cmake -DCMAKE_INSTALL_PREFIX="${PREFIX}" -DCMAKE_BUILD_TYPE=DEBUG \ + -DCMAKE_BUILD_NUMBER="${BUILD_NUMBER}" \ .. -G Xcode; \ xcodebuild -project ${XCODEPROJ} -target lrelease; \ $(FORMATTER_START) xcodebuild -project ${XCODEPROJ} -configuration Debug -target ALL_BUILD $(FORMATTER_END); \ @@ -51,6 +54,7 @@ xcode: mkdir build.xcode; \ cd build.xcode; \ cmake -DCMAKE_INSTALL_PREFIX=../build.xcode/mscore/Debug -DCMAKE_BUILD_TYPE=DEBUG \ + -DCMAKE_BUILD_NUMBER="${BUILD_NUMBER}" \ .. -G Xcode; \ xcodebuild -project ${XCODEPROJ} -target lrelease; @@ -81,6 +85,7 @@ ci: revision mkdir build.release; \ cd build.release; \ cmake -DCMAKE_INSTALL_PREFIX="${PREFIX}" -DCMAKE_BUILD_TYPE=RELEASE \ + -DCMAKE_BUILD_NUMBER="${BUILD_NUMBER}" \ .. -G Xcode; \ xcodebuild -project ${XCODEPROJ} -target lrelease; \ $(FORMATTER_START) xcodebuild -project ${XCODEPROJ} -configuration Release -target install $(FORMATTER_END); diff --git a/build/appveyor/after_build.bat b/build/appveyor/after_build.bat index 8cdf175b62..ef5f6f6702 100644 --- a/build/appveyor/after_build.bat +++ b/build/appveyor/after_build.bat @@ -19,7 +19,7 @@ for /f "delims=" %%f in ('dir /a-d /b /s "%dSource%\*.dll" "%dSource%\*.exe"') d ) :: Create msi package -mingw32-make -f Makefile.mingw package +mingw32-make -f Makefile.mingw package BUILD_NUMBER=%APPVEYOR_BUILD_NUMBER% :: find the MSI file without the hardcoded version for /r %%i in (build.release\*.msi) do ( SET FILEPATH=%%i ) @@ -56,6 +56,29 @@ SET BUILD_DATE=%Date:~10,4%-%Date:~4,2%-%Date:~7,2%-%hh%%time:~3,2% SET ARTIFACT_NAME=MuseScoreNightly-%BUILD_DATE%-%APPVEYOR_REPO_BRANCH%-%MSversion%.7z 7z a C:\MuseScore\%ARTIFACT_NAME% C:\MuseScore\MuseScoreNightly +:: create update file for S3 +SET SHORT_DATE=%Date:~10,4%-%Date:~4,2%-%Date:~7,2% +SET input=C:\MuseScore\CMakeLists.txt +FOR /f tokens^=2^ delims^=^" %%A IN ('findstr /C:"SET(MUSESCORE_VERSION_MAJOR" %input%') DO set VERSION_MAJOR=%%A +FOR /f tokens^=2^ delims^=^" %%A IN ('findstr /C:"SET(MUSESCORE_VERSION_MINOR" %input%') DO set VERSION_MINOR=%%A +FOR /f tokens^=2^ delims^=^" %%A IN ('findstr /C:"SET(MUSESCORE_VERSION_PATCH" %input%') DO set VERSION_PATCH=%%A +SET MUSESCORE_VERSION=%VERSION_MAJOR%.%VERSION_MINOR%.%VERSION_PATCH%.%APPVEYOR_BUILD_NUMBER% + + +@echo off + +( +echo ^ +echo ^%MUSESCORE_VERSION%^ +echo ^%MSversion%^ +echo ^nightly^ +echo ^%SHORT_DATE%^ +echo ^MuseScore %MUSESCORE_VERSION% %MSversion%^ +echo ^https://ftp.osuosl.org/pub/musescore-nightlies/windows/%ARTIFACT_NAME%^ +echo ^https://ftp.osuosl.org/pub/musescore-nightlies/windows/^ +echo ^ +)>"update_win_nightly.xml" + :UPLOAD SET SSH_IDENTITY=C:\MuseScore\build\appveyor\resources\osuosl_nighlies_rsa_nopp diff --git a/build/appveyor/build_script.bat b/build/appveyor/build_script.bat index 3e8f11ec73..3cc637ff63 100644 --- a/build/appveyor/build_script.bat +++ b/build/appveyor/build_script.bat @@ -1,2 +1,2 @@ -mingw32-make -f Makefile.mingw release -mingw32-make -f Makefile.mingw install +mingw32-make -f Makefile.mingw release BUILD_NUMBER=%APPVEYOR_BUILD_NUMBER% +mingw32-make -f Makefile.mingw install BUILD_NUMBER=%APPVEYOR_BUILD_NUMBER% diff --git a/build/config.h.in b/build/config.h.in index 16fb38136d..b2e0041404 100644 --- a/build/config.h.in +++ b/build/config.h.in @@ -38,6 +38,7 @@ #define INSTALL_NAME "${Mscore_INSTALL_NAME}" #define INSTPREFIX "${CMAKE_INSTALL_PREFIX}" #define VERSION "${MUSESCORE_VERSION_FULL}" +#define BUILD_NUMBER "${CMAKE_BUILD_NUMBER}" #cmakedefine AEOLUS #cmakedefine ZERBERUS diff --git a/build/travis/job2_AppImage/build.sh b/build/travis/job2_AppImage/build.sh index 3a4c779068..52c63e9dfb 100755 --- a/build/travis/job2_AppImage/build.sh +++ b/build/travis/job2_AppImage/build.sh @@ -39,6 +39,7 @@ then # Build is marked UNSTABLE inside CMakeLists.txt then # This is a nightly build makefile_overrides="PREFIX='MuseScoreNightly-$date-$branch-$revision' \ SUFFIX='-portable-nightly' \ + BUILD_NUMBER='${TRAVIS_BUILD_NUMBER}' \ LABEL='Portable Nightly Build'" cp -f build/travis/resources/splash-nightly.png mscore/data/splash.png else diff --git a/build/travis/job_macos/script.sh b/build/travis/job_macos/script.sh index aa634cb665..a73d73bd4c 100755 --- a/build/travis/job_macos/script.sh +++ b/build/travis/job_macos/script.sh @@ -23,7 +23,7 @@ else python build/add-mc-keys.py $MC_CONSUMER_KEY $MC_CONSUMER_SECRET fi -make -f Makefile.osx ci +make -f Makefile.osx ci BUILD_NUMBER=${TRAVIS_BUILD_NUMBER} if [ "$(grep '^[[:blank:]]*set( *MSCORE_UNSTABLE \+TRUE *)' CMakeLists.txt)" ] then # Build is marked UNSTABLE inside CMakeLists.txt build/package_mac $BRANCH-$REVISION @@ -53,4 +53,29 @@ scp -C -i $SSH_INDENTITY build/travis/job_macos/web/nightly.xml musescore-nightl # trigger distribution ssh -i $SSH_INDENTITY musescore-nightlies@ftp-osl.osuosl.org "~/trigger-musescore-nightlies" +# send nightly update to S3 +VERSION_MAJOR=$(grep 'SET(MUSESCORE_VERSION_MAJOR' CMakeLists.txt | cut -d \" -f2) +VERSION_MINOR=$(grep 'SET(MUSESCORE_VERSION_MINOR' CMakeLists.txt | cut -d \" -f2) +VERSION_PATCH=$(grep 'SET(MUSESCORE_VERSION_PATCH' CMakeLists.txt | cut -d \" -f2) +BUILD_NUMBER=${TRAVIS_BUILD_NUMBER} +MUSESCORE_VERSION=${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}.${BUILD_NUMBER} +SHORT_DATE="$(date -u +%Y-%m-%d)" + +if [ "$(grep '^[[:blank:]]*set( *MSCORE_UNSTABLE \+TRUE *)' CMakeLists.txt)" ] +then +echo " +${MUSESCORE_VERSION} +${REVISION} +nightly +${SHORT_DATE} +MuseScore ${MUSESCORE_VERSION} ${REVISION} +https://ftp.osuosl.org/pub/musescore-nightlies/macosx/$DMGFILE +https://ftp.osuosl.org/pub/musescore-nightlies/macosx/ +" >> update_mac_nightly.xml +ARTIFACTS_AWS_REGION=us-east-1 +ARTIFACTS_S3_BUCKET=update.musescore.org +ARTIFACTS_CACHE_CONTROL='public, max-age=315360000' +ARTIFACTS_PATHS=update_mac_nightly.xml +artifacts upload +fi diff --git a/mscore/updatechecker.cpp b/mscore/updatechecker.cpp index 5e63e080cd..24cdf611f9 100644 --- a/mscore/updatechecker.cpp +++ b/mscore/updatechecker.cpp @@ -146,21 +146,18 @@ void UpdateChecker::check(QString currentVersion, bool m) #if defined(Q_OS_MAC) os = "mac"; #endif - if (qApp->applicationName() == "MuseScore3") { //avoid nightly cymbals - if (MuseScore::unstable()) - release = "pre"; - else - release = "stable"; + if (MuseScore::unstable()) { + release = "nightly"; + _currentVersion = QString("%1.%2").arg(currentVersion).arg(BUILD_NUMBER); } else { - release = "nightly"; + release = "stable"; + _currentVersion = currentVersion; } if (MScore::debugMode) qDebug("release type: %s", release.toLatin1().constData()); - if (!os.isEmpty() && !release.isEmpty() && release != "nightly") { - _currentVersion = currentVersion; + if (!os.isEmpty() && !release.isEmpty()) manager->get(QNetworkRequest(QUrl("http://update.musescore.org/update_" + os +"_" + release +".xml"))); - } } UpdateCheckerBase::UpdateCheckerBase(QObject* parent) diff --git a/mtest/libmscore/utils/tst_utils.cpp b/mtest/libmscore/utils/tst_utils.cpp index ff0eead0ed..49aff5956e 100644 --- a/mtest/libmscore/utils/tst_utils.cpp +++ b/mtest/libmscore/utils/tst_utils.cpp @@ -57,7 +57,14 @@ void TestUtils::tst_compareVersion() QVERIFY(compareVersion("2.0", "2.1") == true); QVERIFY(compareVersion("2.1.1.2", "2.0") == false); QVERIFY(compareVersion("2.0", "2.1.1.3") == true); + QVERIFY(compareVersion("2.1", "2.1.1.3") == true); + QVERIFY(compareVersion("2.2.0.3", "2.1.1.3") == false); + QVERIFY(compareVersion("2.1.0.3", "2.1.1.3") == true); + QVERIFY(compareVersion("2.1.0.0", "2.1.1.3") == true); QVERIFY(compareVersion("2.1.1.2", "2.1.1.3") == true); + QVERIFY(compareVersion("2.1.1.9", "2.1.1.10") == true); + QVERIFY(compareVersion("2.1.1.9", "2.1.1.100") == true); + QVERIFY(compareVersion("2.1.1.99", "2.1.1.100") == true); QVERIFY(compareVersion("test", "2.1") == true); QVERIFY(compareVersion("test1", "test") == false); }