From 3a05e61814ad5346df249f7091f0994cc3b94c6e Mon Sep 17 00:00:00 2001 From: WarmUpTill Date: Wed, 23 Dec 2020 01:51:48 +0100 Subject: [PATCH] add windows installer (#88) --- .github/workflows/build.yml | 110 +++++++++++++----------------------- CI/windows/setup.iss.in | 64 +++++++++++++++++++++ CMakeLists.txt | 7 +++ 3 files changed, 110 insertions(+), 71 deletions(-) create mode 100644 CI/windows/setup.iss.in diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4a93931f..766c2d83 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -189,13 +189,14 @@ jobs: with: name: '${{ env.FILE_NAME }}' path: '*.tar.gz' - win64: - name: Windows 64-bit + windows: + name: Windows runs-on: [windows-latest] env: QT_VERSION: 5.10.1 CMAKE_GENERATOR: "Visual Studio 16 2019" CMAKE_SYSTEM_VERSION: "10.0.18363.657" + WINDOWS_DEPS_VERSION: '2017' steps: - name: Add msbuild to PATH uses: microsoft/setup-msbuild@v1.0.2 @@ -219,88 +220,55 @@ jobs: 7z x Qt_${{ env.QT_VERSION }}.7z -o"${{ github.workspace }}/cmbuild/QT" - name: 'Install prerequisite: Pre-built dependencies' run: | - curl -kLO https://cdn-fastly.obsproject.com/downloads/dependencies2017.zip -f --retry 5 -C - - 7z x dependencies2017.zip -o"${{ github.workspace }}/cmbuild/deps" + curl -kLO https://cdn-fastly.obsproject.com/downloads/dependencies${{ env.WINDOWS_DEPS_VERSION }}.zip -f --retry 5 -C - + 7z x dependencies${{ env.WINDOWS_DEPS_VERSION }}.zip -o"${{ github.workspace }}/cmbuild/deps" - name: Configure run: | - mkdir ./build - mkdir ./build64 - cd ./build64 - cmake -G"${{ env.CMAKE_GENERATOR }}" -A"x64" -DCMAKE_SYSTEM_VERSION="${{ env.CMAKE_SYSTEM_VERSION }}" -DBUILD_BROWSER=false -DCOMPILE_D3D12_HOOK=false -DDepsPath="${{ github.workspace }}/cmbuild/deps/win64" -DQTDIR="${{ github.workspace }}/cmbuild/QT/${{ env.QT_VERSION }}/msvc2017_64" -DCOPIED_DEPENDENCIES=FALSE -DCOPY_DEPENDENCIES=TRUE .. - - name: Build - run: msbuild /m /p:Configuration=RelWithDebInfo .\build64\obs-studio.sln - - name: Package - if: success() - run: | - $env:FILE_DATE=(Get-Date -UFormat "%F") - $env:FILE_NAME="${{ env.PLUGIN_NAME }}-${env:FILE_DATE}-${{ github.sha }}-win64.zip" - echo "FILE_NAME=${env:FILE_NAME}" >> ${env:GITHUB_ENV} - robocopy .\build64\rundir\RelWithDebInfo\obs-plugins\64bit\ .\build\obs-plugins\64bit ${{ env.LIB_NAME }}.* /E /XF .gitignore - robocopy .\build64\rundir\RelWithDebInfo\data\obs-plugins\${{ env.LIB_NAME }}\ .\build\data\obs-plugins\${{ env.LIB_NAME }}\ /E /XF .gitignore - 7z a ${env:FILE_NAME} .\build\* - - name: Publish - if: success() - uses: actions/upload-artifact@v2.2.1 - with: - name: '${{ env.FILE_NAME }}' - path: '*-win64.zip' - win32: - name: Windows 32-bit - runs-on: [windows-latest] - env: - QT_VERSION: 5.10.1 - CMAKE_GENERATOR: "Visual Studio 16 2019" - CMAKE_SYSTEM_VERSION: "10.0.18363.657" - steps: - - name: Add msbuild to PATH - uses: microsoft/setup-msbuild@v1.0.2 - - name: Checkout obs - uses: actions/checkout@v2.3.4 - with: - repository: obsproject/obs-studio - submodules: 'recursive' - - name: Checkout plugin - uses: actions/checkout@v2.3.4 - with: - path: UI/frontend-plugins/${{ env.PLUGIN_NAME }} - - name: Add plugin to obs cmake - shell: cmd - run: echo add_subdirectory(${{ env.PLUGIN_NAME }}) >> UI/frontend-plugins/CMakeLists.txt - - name: Fetch Git Tags - run: git fetch --prune --tags --unshallow - - name: 'Install prerequisite: QT' - run: | - curl -kLO https://cdn-fastly.obsproject.com/downloads/Qt_${{ env.QT_VERSION }}.7z -f --retry 5 -C - - 7z x Qt_${{ env.QT_VERSION }}.7z -o"${{ github.workspace }}/cmbuild/QT" - - name: 'Install prerequisite: Pre-built dependencies' - run: | - curl -kLO https://cdn-fastly.obsproject.com/downloads/dependencies2017.zip -f --retry 5 -C - - 7z x dependencies2017.zip -o"${{ github.workspace }}/cmbuild/deps" - - name: Configure - run: | - mkdir ./build + mkdir ./package mkdir ./build32 cd ./build32 - cmake -G"${{ env.CMAKE_GENERATOR }}" -A"Win32" -DCMAKE_SYSTEM_VERSION="${{ env.CMAKE_SYSTEM_VERSION }}" -DBUILD_BROWSER=false -DCOMPILE_D3D12_HOOK=false -DDepsPath="${{ github.workspace }}/cmbuild/deps/win32" -DQTDIR="${{ github.workspace }}/cmbuild/QT/${{ env.QT_VERSION }}/msvc2017" -DCOPIED_DEPENDENCIES=FALSE -DCOPY_DEPENDENCIES=TRUE .. + cmake -G"${{ env.CMAKE_GENERATOR }}" -A"Win32" -DCMAKE_SYSTEM_VERSION="${{ env.CMAKE_SYSTEM_VERSION }}" -DBUILD_BROWSER=false -DBUILD_CAPTIONS=false -DCOMPILE_D3D12_HOOK=false -DDepsPath="${{ github.workspace }}/cmbuild/deps/win32" -DQTDIR="${{ github.workspace }}/cmbuild/QT/${{ env.QT_VERSION }}/msvc2017" -DCOPIED_DEPENDENCIES=FALSE -DCOPY_DEPENDENCIES=TRUE .. + cd .. + mkdir ./build64 + cd ./build64 + cmake -G"${{ env.CMAKE_GENERATOR }}" -A"x64" -DCMAKE_SYSTEM_VERSION="${{ env.CMAKE_SYSTEM_VERSION }}" -DBUILD_BROWSER=false -DBUILD_CAPTIONS=false -DCOMPILE_D3D12_HOOK=false -DDepsPath="${{ github.workspace }}/cmbuild/deps/win64" -DQTDIR="${{ github.workspace }}/cmbuild/QT/${{ env.QT_VERSION }}/msvc2017_64" -DCOPIED_DEPENDENCIES=FALSE -DCOPY_DEPENDENCIES=TRUE .. - name: Build - run: msbuild /m /p:Configuration=RelWithDebInfo .\build32\obs-studio.sln + run: | + msbuild /m /p:Configuration=RelWithDebInfo .\build32\obs-studio.sln + msbuild /m /p:Configuration=RelWithDebInfo .\build64\obs-studio.sln - name: Package if: success() run: | $env:FILE_DATE=(Get-Date -UFormat "%F") - $env:FILE_NAME="${{ env.PLUGIN_NAME }}-${env:FILE_DATE}-${{ github.sha }}-win32.zip" + $env:FILE_NAME="${{ env.PLUGIN_NAME }}-${env:FILE_DATE}-${{ github.sha }}-windows" echo "FILE_NAME=${env:FILE_NAME}" >> ${env:GITHUB_ENV} - robocopy .\build32\rundir\RelWithDebInfo\obs-plugins\32bit\ .\build\obs-plugins\32bit ${{ env.LIB_NAME }}.* /E /XF .gitignore - robocopy .\build32\rundir\RelWithDebInfo\data\obs-plugins\${{ env.LIB_NAME }}\ .\build\data\obs-plugins\${{ env.LIB_NAME }}\ /E /XF .gitignore - 7z a ${env:FILE_NAME} .\build\* - - name: Publish + robocopy .\build32\rundir\RelWithDebInfo\obs-plugins\32bit\ .\package\obs-plugins\32bit ${{ env.LIB_NAME }}.* /E /XF .gitignore + robocopy .\build64\rundir\RelWithDebInfo\obs-plugins\64bit\ .\package\obs-plugins\64bit ${{ env.LIB_NAME }}.* /E /XF .gitignore + robocopy .\build64\rundir\RelWithDebInfo\data\obs-plugins\${{ env.LIB_NAME }}\ .\package\data\obs-plugins\${{ env.LIB_NAME }}\ /E /XF .gitignore + exit 0 + - name: Publish zip if: success() uses: actions/upload-artifact@v2.2.1 with: name: '${{ env.FILE_NAME }}' - path: '*-win32.zip' + path: package/* + - name: "Package Installer (Prereqs)" + run: | + curl "-kL" "https://github.com/Xaymar/msvc-redist-helper/releases/download/0.1/msvc-redist-helper-64.exe" "-f" "--retry" "5" "-o" "msvc-redist-helper-64.exe" + curl "-kL" "https://github.com/Xaymar/msvc-redist-helper/releases/download/0.1/msvc-redist-helper-32.exe" "-f" "--retry" "5" "-o" "msvc-redist-helper-32.exe" + curl "-kL" "https://files.jrsoftware.org/is/6/innosetup-6.0.3.exe" "-f" "--retry" "5" "-o" "inno.exe" + .\inno.exe /VERYSILENT /SP- /SUPPRESSMSGBOXES /NORESTART + - name: "Package Installer (Compile)" + run: | + & 'C:\Program Files (x86)\Inno Setup 6\ISCC.exe' /Qp ".\build64\UI\frontend-plugins\${{ env.PLUGIN_NAME }}\CI\windows\setup.iss" + - name: Publish installer + if: success() + uses: actions/upload-artifact@v2.2.0 + with: + name: '${{ env.FILE_NAME }}-installer' + path: build64/UI/frontend-plugins/SceneSwitcher/CI/windows/Output/*.exe release: - needs: [macos64, ubuntu64, win64, win32] + needs: [macos64, ubuntu64, windows] name: 'Create Release' runs-on: [ubuntu-latest] steps: @@ -318,8 +286,8 @@ jobs: mkdir -p ${{ env.PLUGIN_NAME }}/Linux ${{ env.PLUGIN_NAME }}/MacOs ${{ env.PLUGIN_NAME }}/Windows tar xf artifacts/${{ env.PLUGIN_NAME }}*-linux64.tar.gz/${{ env.PLUGIN_NAME }}*-linux64.tar.gz -C ${{ env.PLUGIN_NAME }}/Linux/ mv artifacts/${{ env.PLUGIN_NAME }}*-macos.pkg/${{ env.PLUGIN_NAME }}*-macos.pkg ${{ env.PLUGIN_NAME }}/MacOs/${{ env.PLUGIN_NAME }}.pkg - unzip -o artifacts/${{ env.PLUGIN_NAME }}*-win32.zip/${{ env.PLUGIN_NAME }}*-win32.zip -d ${{ env.PLUGIN_NAME }}/Windows/ - unzip -o artifacts/${{ env.PLUGIN_NAME }}*-win64.zip/${{ env.PLUGIN_NAME }}*-win64.zip -d ${{ env.PLUGIN_NAME }}/Windows/ + mv ./artifacts/${{ env.PLUGIN_NAME }}*-windows/* ${{ env.PLUGIN_NAME }}/Windows/ + mv ./artifacts/${{ env.PLUGIN_NAME }}*-windows-installer/*.exe ${{ env.PLUGIN_NAME }}/Windows/ rm ${{ env.PLUGIN_NAME }}/Windows/obs-plugins/32bit/advanced-scene-switcher.pdb rm ${{ env.PLUGIN_NAME }}/Windows/obs-plugins/64bit/advanced-scene-switcher.pdb cp plugin/${{ env.PLUGIN_NAME }}/CI/release/README.txt ${{ env.PLUGIN_NAME }}/ diff --git a/CI/windows/setup.iss.in b/CI/windows/setup.iss.in new file mode 100644 index 00000000..af0b50a9 --- /dev/null +++ b/CI/windows/setup.iss.in @@ -0,0 +1,64 @@ +; Script generated by the Inno Setup Script Wizard. +; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! + +#define MyAppName "Advanced Scene Switcher" +#define MyAppVersion "@GIT_SHA1@" +#define MyAppURL "https://github.com/WarmUpTill/SceneSwitcher" + +[Setup] +; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications. +; (To generate a new GUID, click Tools | Generate GUID inside the IDE.) +AppId={{A4ADDF26-4426-4D2E-B26A-C7C878DA8FC9} +AppName={#MyAppName} +AppVersion={#MyAppVersion} +AppPublisherURL={#MyAppURL} +AppSupportURL={#MyAppURL} +AppUpdatesURL={#MyAppURL} +DefaultDirName={code:GetDirName} +DefaultGroupName={#MyAppName} +AllowNoIcons=yes +; Uncomment the following line to run in non administrative install mode (install for current user only.) +;PrivilegesRequired=lowest +OutputBaseFilename=AdvancedSceneSwitcherSetup +Compression=lzma +SolidCompression=yes +WizardStyle=modern +ArchitecturesInstallIn64BitMode=x64 + +[Languages] +Name: "english"; MessagesFile: "compiler:Default.isl" + +[Files] +Source: "@ISS_MSVC_REDIST_HELPER_DIR@\msvc-redist-helper-64.exe"; DestDir: "{app}"; DestName: "msvc-redist-helper.exe"; Flags: ignoreversion dontcopy; Check: Is64BitInstallMode +Source: "@ISS_MSVC_REDIST_HELPER_DIR@\msvc-redist-helper-32.exe"; DestDir: "{app}"; DestName: "msvc-redist-helper.exe"; Flags: ignoreversion dontcopy; Check: not Is64BitInstallMode +Source: "@ISS_PLUGIN_FILES_DIR@\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs +; NOTE: Don't use "Flags: ignoreversion" on any shared system files + +[Icons] +Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}" + +[Code] +// credit where it's due: +// following function comes from https://github.com/Xaymar/obs-studio_amf-encoder-plugin/blob/master/%23Resources/Installer.in.iss#L45 +function GetDirName(Value: string): string; +var + InstallPath: string; +begin + // initialize default path, which will be returned when the following registry + // key queries fail due to missing keys or for some different reason + Result := ExpandConstant('{pf}\obs-studio'); + // query the first registry value; if this succeeds, return the obtained value + if RegQueryStringValue(HKLM32, 'SOFTWARE\OBS Studio', '', InstallPath) then + Result := InstallPath +end; + +procedure CurStepChanged(CurStep: TSetupStep); +var + ResultCode: Integer; +begin + if (CurStep=ssPostInstall) then + begin + ExtractTemporaryFile('msvc-redist-helper.exe'); + Exec(ExpandConstant('{tmp}\msvc-redist-helper.exe'), '2019', '', SW_HIDE, ewWaitUntilTerminated, ResultCode); + end; +end; diff --git a/CMakeLists.txt b/CMakeLists.txt index 7628da73..080f6517 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,6 +7,13 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/") include(GetGitRevisionDescription) get_git_head_revision(GIT_REFSPEC GIT_SHA1) configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/version.cpp.in" "${CMAKE_CURRENT_BINARY_DIR}/src/version.cpp" @ONLY) +if(WIN32) + get_filename_component(ISS_PLUGIN_FILES_DIR "${CMAKE_BINARY_DIR}\\..\\package" ABSOLUTE) + file(TO_NATIVE_PATH "${ISS_PLUGIN_FILES_DIR}" ISS_PLUGIN_FILES_DIR) + get_filename_component(ISS_MSVC_REDIST_HELPER_DIR "${CMAKE_PACKAGE_PREFIX}\\.." ABSOLUTE) + file(TO_NATIVE_PATH "${ISS_MSVC_REDIST_HELPER_DIR}" ISS_MSVC_REDIST_HELPER_DIR) + configure_file("${CMAKE_CURRENT_SOURCE_DIR}/CI/windows/setup.iss.in" "${CMAKE_CURRENT_BINARY_DIR}/CI/windows/setup.iss" @ONLY) +endif() if(BUILD_OUT_OF_TREE) # out of tree builds