From 8dd32d4a8c36b82a6943206bdc20a18440706e99 Mon Sep 17 00:00:00 2001 From: CodeYan01 <65320293+CodeYan01@users.noreply.github.com> Date: Tue, 18 Feb 2025 14:25:08 +0800 Subject: [PATCH] Add Windows installer --- .github/actions/package-plugin/action.yaml | 4 +++ .github/scripts/Package-Windows.ps1 | 21 +++++++++++- buildspec.json | 5 ++- cmake/common/bootstrap.cmake | 1 + cmake/windows/helpers.cmake | 13 ++++++++ .../resources/installer-Windows.iss.in | 32 +++++++++++++++++++ 6 files changed, 74 insertions(+), 2 deletions(-) create mode 100644 cmake/windows/resources/installer-Windows.iss.in diff --git a/.github/actions/package-plugin/action.yaml b/.github/actions/package-plugin/action.yaml index 11fdccf..77894a1 100644 --- a/.github/actions/package-plugin/action.yaml +++ b/.github/actions/package-plugin/action.yaml @@ -110,4 +110,8 @@ runs: Configuration = '${{ inputs.config }}' } + if ( '${{ inputs.package }}' -eq 'true' ) { + $PackageArgs += @{BuildInstaller = $true} + } + .github/scripts/Package-Windows.ps1 @PackageArgs diff --git a/.github/scripts/Package-Windows.ps1 b/.github/scripts/Package-Windows.ps1 index 0425807..0b1bbfe 100644 --- a/.github/scripts/Package-Windows.ps1 +++ b/.github/scripts/Package-Windows.ps1 @@ -3,7 +3,8 @@ param( [ValidateSet('x64')] [string] $Target = 'x64', [ValidateSet('Debug', 'RelWithDebInfo', 'Release', 'MinSizeRel')] - [string] $Configuration = 'RelWithDebInfo' + [string] $Configuration = 'RelWithDebInfo', + [switch] $BuildInstaller = $false ) $ErrorActionPreference = 'Stop' @@ -67,6 +68,24 @@ function Package { } Compress-Archive -Force @CompressArgs Log-Group + + if ( ( $BuildInstaller ) ) { + $IsccFile = "${ProjectRoot}/build_${Target}/installer-Windows.iss" + + if ( ! ( Test-Path -Path $IsccFile ) ) { + throw 'InnoSetup install script not found. Run the build script or the CMake build and install procedures first.' + } + + Log-Information 'Creating InnoSetup installer...' + Push-Location -Stack BuildTemp + Ensure-Location -Path "${ProjectRoot}/release" + Copy-Item -Path ${Configuration} -Destination Package -Recurse + Invoke-External iscc ${IsccFile} /O"${ProjectRoot}/release" /F"${OutputName}-Installer" + Remove-Item -Path Package -Recurse + Pop-Location -Stack BuildTemp + + Log-Group + } } Package diff --git a/buildspec.json b/buildspec.json index aa0646c..d07f43f 100644 --- a/buildspec.json +++ b/buildspec.json @@ -41,5 +41,8 @@ "version": "0.1.0", "author": "Ian Rodriguez", "website": "https://github.com/CodeYan01/media-playlist-source", - "email": "ianlemuelr@gmail.com" + "email": "ianlemuelr@gmail.com", + "uuids": { + "windowsApp": "22B0D7BD-767F-45FD-901C-4D6EAB4EF875" + } } diff --git a/cmake/common/bootstrap.cmake b/cmake/common/bootstrap.cmake index 3a526a0..4989969 100644 --- a/cmake/common/bootstrap.cmake +++ b/cmake/common/bootstrap.cmake @@ -51,6 +51,7 @@ string(JSON _author GET ${buildspec} author) string(JSON _email GET ${buildspec} email) string(JSON _version GET ${buildspec} version) string(JSON _bundleId GET ${buildspec} platformConfig macos bundleId) +string(JSON _windowsAppUUID GET ${buildspec} uuids windowsApp) set(PLUGIN_AUTHOR ${_author}) set(PLUGIN_WEBSITE ${_website}) diff --git a/cmake/windows/helpers.cmake b/cmake/windows/helpers.cmake index 1510cd8..98a6453 100644 --- a/cmake/windows/helpers.cmake +++ b/cmake/windows/helpers.cmake @@ -54,6 +54,19 @@ function(set_target_properties_plugin target) list(FILTER target_ui_files INCLUDE REGEX ".+\\.(ui|qrc)") source_group(TREE "${CMAKE_CURRENT_SOURCE_DIR}" PREFIX "UI Files" FILES ${target_ui_files}) + set(valid_uuid FALSE) + check_uuid(${_windowsAppUUID} valid_uuid) + if(NOT valid_uuid) + message(FATAL_ERROR "Specified Windows package UUID is not a valid UUID value: ${_windowsAppUUID}") + else() + set(UUID_APP ${_windowsAppUUID}) + endif() + + configure_file( + cmake/windows/resources/installer-Windows.iss.in + "${CMAKE_CURRENT_BINARY_DIR}/installer-Windows.generated.iss" + ) + configure_file(cmake/windows/resources/resource.rc.in "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}.rc") target_sources(${CMAKE_PROJECT_NAME} PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}.rc") endfunction() diff --git a/cmake/windows/resources/installer-Windows.iss.in b/cmake/windows/resources/installer-Windows.iss.in new file mode 100644 index 0000000..16d214e --- /dev/null +++ b/cmake/windows/resources/installer-Windows.iss.in @@ -0,0 +1,32 @@ +#define MyAppName "@CMAKE_PROJECT_NAME@" +#define MyAppVersion "@CMAKE_PROJECT_VERSION@" +#define MyAppPublisher "@PLUGIN_AUTHOR@" +#define MyAppURL "@PLUGIN_WEBSITE@" + +[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={{@UUID_APP@} +AppName={#MyAppName} +AppVersion={#MyAppVersion} +AppPublisher={#MyAppPublisher} +AppPublisherURL={#MyAppURL} +AppSupportURL={#MyAppURL} +AppUpdatesURL={#MyAppURL} +DefaultDirName={commonappdata}\obs-studio\plugins\{#MyAppName} +DefaultGroupName={#MyAppName} +OutputBaseFilename={#MyAppName}-{#MyAppVersion}-Windows-Installer +Compression=lzma +SolidCompression=yes +DirExistsWarning=no + +[Languages] +Name: "english"; MessagesFile: "compiler:Default.isl" + +[Files] +Source: "..\release\Package\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs +; NOTE: Don't use "Flags: ignoreversion" on any shared system files + +[Icons] +Name: "{group}\{cm:ProgramOnTheWeb,{#MyAppName}}"; Filename: "{#MyAppURL}"