Skip to content

Commit

Permalink
WinSparkle auto-updater integration
Browse files Browse the repository at this point in the history
WinSparkle is used to auto update MuseScore on Windows.
Add basic API calls to make it work.
Add winsparkle.dll and includes.
Generate appCast.xml and put to S3

* don't build winsparkle routines with local build
* fix interactions with global checkForUpdates option
* Mac now invalidates both Win and Mac appcast files
* fix scriptrecorder compilation + fix generating appCast for stable version
* Fix packaging WinSparkle
* change exe file name to MuseScore3.exe
* generate package GUID automatically to avoid installation collisions
* Use embedded update checker for UNSTABLE Windows builds
* comment WinSparkle appcast.xml deploy for unstable builds
  • Loading branch information
anatoly-os committed Nov 25, 2018
1 parent 6337218 commit 55043ec
Show file tree
Hide file tree
Showing 20 changed files with 352 additions and 108 deletions.
33 changes: 23 additions & 10 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ image: Visual Studio 2017
branches:
only:
- master
- 3.0alpha

# build cache to preserve files/folders between builds
cache:
Expand Down Expand Up @@ -57,15 +56,29 @@ artifacts:
name: musescore-binary
- path: update_win_nightly.xml
name: update_win_nightly.xml
- path: appcast.xml
name: appcast.xml

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: update_win_nightly.xml
- 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: update_win_nightly.xml

# uncomment in stable release
# - provider: S3
# access_key_id:
# secure: k68f3wMKIC5AzrfNMuC4kdPaxzvKdFVkRsietUKqc+E=
# secret_access_key:
# secure: IbpdpiHzGfMasaSA6uGrskE4xu9wE+HzElW7tIDOUww+ivHj+gN+mPgUHKCcV9Cn
# bucket: sparkle.musescore.org
# folder: testing/3/win/
# region: us-east-1
# set_public: true
# artifact: appcast.xml

52 changes: 36 additions & 16 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -157,16 +157,44 @@ if (APPLE)
find_library(CoreServicesFW NAMES CoreServices)
find_library(AppKit NAMES AppKit)
set(OsxFrameworks ${AudioToolboxFW} ${AudioUnitFW} ${CoreAudioFW} ${CoreMidiFW} ${SystemConfigurationFW} ${CoreServicesFW} ${AppKit})
if (BUILD_AUTOUPDATE)
find_package(Sparkle) #needed for SPARKLE_FOUND variable
if(SPARKLE_FOUND)
set(MAC_SPARKLE_ENABLED 1)
set(OsxFrameworks ${OsxFrameworks} ${SPARKLE_LIBRARY})
set(MAC_APPCAST_URL "https://sparkle.musescore.org/${MSCORE_RELEASE_CHANNEL}/3/macos/appcast.xml")
endif(SPARKLE_FOUND)
endif(BUILD_AUTOUPDATE)
endif (APPLE)

#
# Set up Windows arch variables/paths
#

if (BUILD_64 STREQUAL "ON")
SET (ARCH_TYPE "_x64")
SET (DEPENDENCIES_DIR "${PROJECT_SOURCE_DIR}/dependencies/libx64")
else (BUILD_64 STREQUAL "ON")
SET (ARCH_TYPE "_x86")
SET (DEPENDENCIES_DIR "${PROJECT_SOURCE_DIR}/dependencies/libx86")
endif (BUILD_64 STREQUAL "ON")

#
# Sparkle/WinSparkle routine
#
if (BUILD_AUTOUPDATE STREQUAL "ON")
if (APPLE)
find_package(Sparkle) #needed for SPARKLE_FOUND variable
if(SPARKLE_FOUND)
set(MAC_SPARKLE_ENABLED 1)
set(OsxFrameworks ${OsxFrameworks} ${SPARKLE_LIBRARY})
set(MAC_APPCAST_URL "https://sparkle.musescore.org/${MSCORE_RELEASE_CHANNEL}/3/macos/appcast.xml")
endif(SPARKLE_FOUND)
elseif (MSVC)
if (NOT MSCORE_UNSTABLE)
include(FindWinSparkle)
add_library(winsparkledll SHARED IMPORTED)
set_target_properties(winsparkledll PROPERTIES IMPORTED_IMPLIB ${WINSPARKLE_LIBRARY})
set(WIN_SPARKLE_ENABLED 1)
set(WIN_SPARKLE_APPCAST_URL "https://sparkle.musescore.org/${MSCORE_RELEASE_CHANNEL}/3/win/appcast.xml")
endif (NOT MSCORE_UNSTABLE)
else (APPLE)
message("Sparkle is not supported on your system.")
endif (APPLE)
endif(BUILD_AUTOUPDATE STREQUAL "ON")

#
# Check for gcc compiler >= 4.8
#
Expand Down Expand Up @@ -384,14 +412,6 @@ endif (BUILD_PULSEAUDIO)
## LAME
##

if (BUILD_64 STREQUAL "ON")
SET (ARCH_TYPE "_x64")
SET (DEPENDENCIES_DIR "${PROJECT_SOURCE_DIR}/dependencies/libx64")
else (BUILD_64 STREQUAL "ON")
SET (ARCH_TYPE "_x86")
SET (DEPENDENCIES_DIR "${PROJECT_SOURCE_DIR}/dependencies/libx86")
endif (BUILD_64 STREQUAL "ON")

if (APPLE OR MINGW)
if (BUILD_LAME)
include (FindLame)
Expand Down
22 changes: 22 additions & 0 deletions build/FindWinSparkle.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
find_path(WINSPARKLE_INCLUDE_DIR winsparkle.h PATHS ${PROJECT_SOURCE_DIR}/dependencies/include/winsparkle;)

set(CMAKE_FIND_LIBRARY_SUFFIXES ".lib")

find_library(WINSPARKLE_LIBRARY NAMES winsparkle PATHS ${DEPENDENCIES_DIR} NO_DEFAULT_PATH)

if (MINGW)
set(WINSPARKLE_INCLUDE_DIR "")
set(WINSPARKLE_LIBRARY "")
endif(MINGW)

message(STATUS ${WINSPARKLE_LIBRARY})

if (WINSPARKLE_INCLUDE_DIR AND WINSPARKLE_LIBRARY)
set(WINSPARKLE_FOUND TRUE)
endif (WINSPARKLE_INCLUDE_DIR AND WINSPARKLE_LIBRARY)

if (WINSPARKLE_FOUND)
message (STATUS "Found WinSparkle: ${WINSPARKLE_LIBRARY}")
else (WINSPARKLE_FOUND)
message (FATAL_ERROR "Could not find: WinSparkle")
endif (WINSPARKLE_FOUND)
12 changes: 7 additions & 5 deletions build/Packaging.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ SET(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE.GPL")
SET(CPACK_PACKAGE_VERSION_MAJOR "${MUSESCORE_VERSION_MAJOR}")
SET(CPACK_PACKAGE_VERSION_MINOR "${MUSESCORE_VERSION_MINOR}")
SET(CPACK_PACKAGE_VERSION_PATCH "${MUSESCORE_VERSION_PATCH}")
SET(CPACK_PACKAGE_VERSION "${MUSESCORE_VERSION_MAJOR}.${MUSESCORE_VERSION_MINOR}.${MUSESCORE_VERSION_PATCH}")
SET(CPACK_PACKAGE_VERSION_BUILD "${CMAKE_BUILD_NUMBER}")
SET(CPACK_PACKAGE_VERSION "${MUSESCORE_VERSION_MAJOR}.${MUSESCORE_VERSION_MINOR}.${MUSESCORE_VERSION_PATCH}.${CPACK_PACKAGE_VERSION_BUILD}")
SET(CPACK_PACKAGE_INSTALL_DIRECTORY "MuseScore ${MUSESCORE_VERSION_MAJOR}.${MUSESCORE_VERSION_MINOR}")
SET(MSCORE_OUTPUT_NAME "${MUSESCORE_NAME}${MUSESCORE_VERSION_MAJOR}")

set(git_date_string "")
if (MSCORE_UNSTABLE)
Expand Down Expand Up @@ -60,8 +62,8 @@ IF(MINGW OR MSVC)

file(TO_CMAKE_PATH $ENV{PROGRAMFILES} PROGRAMFILES)
SET(CPACK_WIX_ROOT "${PROGRAMFILES}/WiX Toolset v3.11")
SET(CPACK_WIX_PRODUCT_GUID "36F8DD90-CE12-11E4-8830-0800200C9A66")
SET(CPACK_WIX_UPGRADE_GUID "6CF17D7E-4CF1-42CF-A23A-B52F7E883D51")
SET(CPACK_WIX_PRODUCT_GUID "00000000-0000-0000-0000-000000000000")
SET(CPACK_WIX_UPGRADE_GUID "4975850F-912F-47AE-AF2C-65C592188FCE")
SET(CPACK_WIX_LICENSE_RTF "${PROJECT_SOURCE_DIR}/LICENSE.rtf")
SET(CPACK_WIX_PRODUCT_ICON "${PROJECT_SOURCE_DIR}/mscore/data/mscore.ico")
SET(CPACK_WIX_UI_BANNER "${PROJECT_SOURCE_DIR}/build/packaging/installer_banner_wix.bmp")
Expand All @@ -71,8 +73,8 @@ IF(MINGW OR MSVC)
SET(CPACK_WIX_EXTENSIONS "WixUtilExtension")

SET(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/build/packaging" ${CMAKE_MODULE_PATH}) # Use custom version of NSIS.InstallOptions.ini
SET(CPACK_PACKAGE_EXECUTABLES "${MUSESCORE_NAME}" "${MUSESCORE_NAME_VERSION}") # exe name, label
SET(CPACK_CREATE_DESKTOP_LINKS "${MUSESCORE_NAME}" "${MUSESCORE_NAME_VERSION}") #exe name, label
SET(CPACK_PACKAGE_EXECUTABLES "${MSCORE_OUTPUT_NAME}" "${MUSESCORE_NAME_VERSION}") # exe name, label
SET(CPACK_CREATE_DESKTOP_LINKS "${MSCORE_OUTPUT_NAME}" "${MUSESCORE_NAME_VERSION}") #exe name, label

SET(CPACK_PACKAGE_FILE_NAME "${MUSESCORE_NAME}-${MUSESCORE_VERSION_FULL}${git_date_string}")
ELSE(MINGW OR MSVC)
Expand Down
43 changes: 32 additions & 11 deletions build/appveyor/after_build.bat
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
:: Print ccache statistics
ccache.exe -s

CD C:\MuseScore

REM the code is used to generate MS version for both nightly and stable releases
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%

:: Test MuseScore stability
IF "%UNSTABLE%" == "" (
IF "%NIGHTLY_BUILD%" == "" (
goto :STABLE_LABEL
) ELSE (
goto :UNSTABLE_LABEL
Expand All @@ -18,8 +27,15 @@ for /f "delims=" %%f in ('dir /a-d /b /s "%dSource%\*.dll" "%dSource%\*.exe"') d
"C:\Program Files (x86)\Windows Kits\8.1\bin\x64\signtool.exe" sign /f "C:\MuseScore\build\appveyor\resources\musescore.p12" /t http://timestamp.verisign.com/scripts/timstamp.dll /p "%CERTIFICATE_PASSWORD%" "%%f"
)

:: generate unique GUID
bash -c "uuidgen -c" > uuid.txt
SET /p PACKAGE_UUID=<uuid.txt
bash -c "sed -i 's/00000000-0000-0000-0000-000000000000/%PACKAGE_UUID%/' ../Packaging.cmake"

call C:\MuseScore\msvc_build.bat package 64 %APPVEYOR_BUILD_NUMBER%

CD C:\MuseScore

:: find the MSI file without the hardcoded version
for /r %%i in (msvc.build_x64\*.msi) do ( SET FILEPATH=%%i )
echo on
Expand All @@ -36,6 +52,17 @@ echo off
:: prepare upload
XCOPY %FILEPATH% C:\MuseScore /Y /Q
SET ARTIFACT_NAME=%FILENAME%

@echo off
REM WinSparkle staff. Generate appcast.xml
REM ------------------------------------------
bash C:\MuseScore\build\appveyor\winsparkle_appcast_generator.sh "C:\MuseScore\%ARTIFACT_NAME%" "https://ftp.osuosl.org/pub/musescore-nightlies/windows/%ARTIFACT_NAME%" "%MUSESCORE_VERSION%" "%MSREVISION%"
REM ------------------------------------------
@echo on
type C:\MuseScore\appcast.xml

SET /p MSCORE_RELEASE_CHANNEL=<MSCORE_RELEASE_CHANNEL.xml

goto :UPLOAD

:UNSTABLE_LABEL
Expand All @@ -52,27 +79,21 @@ SET hh0=%time:~0,2%
SET /a hh1=%hh0%+100
SET hh=%hh1:~1,2%
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
SET ARTIFACT_NAME=MuseScoreNightly-%BUILD_DATE%-%APPVEYOR_REPO_BRANCH%-%MSREVISION%.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 ^<update^>
echo ^<version^>%MUSESCORE_VERSION%^</version^>
echo ^<revision^>%MSversion%^</revision^>
echo ^<revision^>%MSREVISION%^</revision^>
echo ^<releaseType^>nightly^</releaseType^>
echo ^<date^>%SHORT_DATE%^</date^>
echo ^<description^>MuseScore %MUSESCORE_VERSION% %MSversion%^</description^>
echo ^<description^>MuseScore %MUSESCORE_VERSION% %MSREVISION%^</description^>
echo ^<downloadUrl^>https://ftp.osuosl.org/pub/musescore-nightlies/windows/%ARTIFACT_NAME%^</downloadUrl^>
echo ^<infoUrl^>https://ftp.osuosl.org/pub/musescore-nightlies/windows/^</infoUrl^>
echo ^</update^>
Expand All @@ -95,7 +116,7 @@ IF DEFINED ENCRYPT_SECRET_SSH (
ssh -oStrictHostKeyChecking=no -i %SSH_IDENTITY% musescore-nightlies@ftp-osl.osuosl.org "~/trigger-musescore-nightlies"
rem notify IRC channel
pip install irc
python build/appveyor/irccat.py "%APPVEYOR_REPO_BRANCH%-%MSversion% (Win) compiled successfully https://ftp.osuosl.org/pub/musescore-nightlies/windows/%ARTIFACT_NAME%"
python build/appveyor/irccat.py "%APPVEYOR_REPO_BRANCH%-%MSREVISION% (Win) compiled successfully https://ftp.osuosl.org/pub/musescore-nightlies/windows/%ARTIFACT_NAME%"
)


Expand Down
11 changes: 4 additions & 7 deletions build/appveyor/before_build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,18 @@ CD include
CD C:\MuseScore

:: is MuseScore stable? Check here, no grep in PATH later on
for /f "delims=" %%i in ('grep "^[[:blank:]]*set( *MSCORE_UNSTABLE \+TRUE *)" C:\MuseScore\CMakeLists.txt') do set UNSTABLE=%%i
for /f "delims=" %%i in ('grep "^[[:blank:]]*set( *MSCORE_UNSTABLE \+TRUE *)" C:\MuseScore\CMakeLists.txt') do set NIGHTLY_BUILD=%%i

:: add stable keys for musescore.com
IF "%UNSTABLE%" == "" (
IF "%NIGHTLY_BUILD%" == "" (
python build/add-mc-keys.py %MC_CONSUMER_KEY% %MC_CONSUMER_SECRET%
)

:: get revision number
SET PATH=C:\Qt\5.9\msvc2017_64\bin;%PATH%
call C:\MuseScore\msvc_build.bat revision
::git rev-parse --short=7 HEAD > mscore/revision.h
SET /p MSversion=<mscore\revision.h

:: CMake refuses to generate MinGW Makefiles if sh.exe is in the PATH (C:\Program Files\Git\usr\bin)
SET PATH=C:\Qt\5.9\msvc2017_64\bin;C:\Program Files (x86)\CMake\bin;C:\Program Files\7-Zip;C:\ccache\bin;C:\Tools\curl\bin;%WIX%\bin;C:\Windows\system32;C:\Windows
git rev-parse --short=7 HEAD > mscore/revision.h
SET /p MSREVISION=<mscore\revision.h

:: set ccache dir
SET CCACHE_DIR=C:\ccache\cache
34 changes: 34 additions & 0 deletions build/appveyor/winsparkle_appcast_generator.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# $1 - artifact name
# $2 - artifact ftp path
# $3 - MuseScore version
# $4 - Revision hash

export MSCORE_RELEASE_CHANNEL=$(grep '^[[:blank:]]*set *( *MSCORE_RELEASE_CHANNEL' CMakeLists.txt | awk -F \" '{print $2}')
RSS_DATE="$(LANG=C date +'%a, %d %b %Y %H:%M:%S %z')"
FILESIZE="$(wc -c $1 | awk '{print $1}')"
APPCAST_URL="https://sparkle.musescore.org/$MSCORE_RELEASE_CHANNEL/3/win/appcast.xml"
GIT_LOG=$(C:/MuseScore/build/travis/job_macos/generateGitLog.sh)

echo ${MSCORE_RELEASE_CHANNEL} >> MSCORE_RELEASE_CHANNEL.txt

#use dummy values for now
echo "<rss xmlns:sparkle=\"http://www.andymatuschak.org/xml-namespaces/sparkle\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" version=\"2.0\">
<channel>
<title>MuseScore development channel</title>
<link>
${APPCAST_URL}
</link>
<description>Most recent changes with links to updates.</description>
<language>en</language>
<item>
<title>MuseScore $3 $4</title>
<description>
<![CDATA[
${GIT_LOG}
]]>
</description>
<pubDate>${RSS_DATE}</pubDate>
<enclosure url=\"$2\" sparkle:version=\"$3\" length=\"${FILESIZE}\" type=\"application/octet-stream\"/>
</item>
</channel>
</rss>" >> appcast.xml
3 changes: 2 additions & 1 deletion build/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@
#define INSTPREFIX "${CMAKE_INSTALL_PREFIX}"
#define VERSION "${MUSESCORE_VERSION_FULL}"
#define BUILD_NUMBER "${CMAKE_BUILD_NUMBER}"
#define WIN_SPARKLE_APPCAST_URL "${WIN_SPARKLE_APPCAST_URL}"


#cmakedefine WIN_SPARKLE_ENABLED
#cmakedefine MAC_SPARKLE_ENABLED
#cmakedefine AEOLUS
#cmakedefine ZERBERUS
Expand Down
2 changes: 1 addition & 1 deletion build/package_mac
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ then
else
LONG_NAME=MuseScore
LONGER_NAME="MuseScore 3"
VERSION=3.0
VERSION=3.0.0
fi


Expand Down
6 changes: 3 additions & 3 deletions build/packaging/WIX.template.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
<?define VShortVersion="3" ?>
<?define ProdName="$(var.CPACK_PACKAGE_NAME) $(var.VShortVersion)" ?>
<?define ShortProdName="$(var.CPACK_PACKAGE_NAME)$(var.VShortVersion)" ?>
<?define ExeName="$(var.CPACK_PACKAGE_NAME).exe" ?>
<?define ExeName="$(var.ShortProdName).exe" ?>
<?define ExeKey="$(var.ShortProdName).exe" ?>
<?define ExeId="CM_FP_bin.$(var.CPACK_PACKAGE_NAME).exe" ?>
<?define ExeId="CM_FP_bin.$(var.ShortProdName).exe" ?>
<?define RegistryRoot="HKMU" ?> <!--HKCU / HKLM-->

<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
Expand Down Expand Up @@ -59,7 +59,7 @@
</UI>
<Property Id="WIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT" Value="Launch $(var.ProdName)"/>
<Property Id="WIXUI_EXITDIALOGOPTIONALCHECKBOX" Value="1"/>
<Property Id="WixShellExecTarget" Value="[#CM_FP_bin.$(var.CPACK_PACKAGE_NAME).exe]" />
<Property Id="WixShellExecTarget" Value="[#CM_FP_bin.$(var.ShortProdName).exe]" />
<CustomAction Id="LaunchApplication" BinaryKey="WixCA" DllEntry="WixShellExec" Impersonate="yes" />


Expand Down
Loading

0 comments on commit 55043ec

Please sign in to comment.