diff --git a/.github/scripts/.package.zsh b/.github/scripts/.package.zsh index cb6313e..076d897 100755 --- a/.github/scripts/.package.zsh +++ b/.github/scripts/.package.zsh @@ -180,18 +180,13 @@ ${_usage_host:-}" if (( _loglevel > 1 || ${+CI} )) _tarflags="v${_tarflags}" if (( package )) { - if [[ ! -f ${project_root}/build_macos/installer-macos.generated.pkgproj ]] { - log_error 'Packages project file not found. Run the build script or the CMake build and install procedures first.' + if [[ ! -f ${project_root}/release/${config}/${product_name}.pkg ]] { + log_error 'Installer Package not found. Run the build script or the CMake build and install procedures first.' return 2 } - check_packages - log_group "Packaging ${product_name}..." pushd ${project_root} - packagesbuild \ - --build-folder ${project_root}/release/${config} \ - ${project_root}/build_macos/installer-macos.generated.pkgproj if (( codesign )) { read_codesign_installer diff --git a/.github/scripts/utils.zsh/check_packages b/.github/scripts/utils.zsh/check_packages deleted file mode 100644 index 76652c3..0000000 --- a/.github/scripts/utils.zsh/check_packages +++ /dev/null @@ -1,62 +0,0 @@ -if (( ! ${+commands[packagesbuild]} )) { - autoload -Uz log_group log_info log_status mkcd - - if (( ! ${+commands[curl]} )) { - log_error 'curl not found. Please install curl.' - return 2 - } - - if (( ! ${+project_root} )) { - log_error "'project_root' not set. Please set before running ${0}." - return 2 - } - - local -a curl_opts=() - if (( ${+CI} )) { - curl_opts+=(--show-error --silent) - } else { - curl_opts+=(--progress-bar) - } - curl_opts+=(--location -O) - - log_group 'Installing Packages.app...' - - local version - local base_url - local hash - IFS=';' read -r version base_url hash <<< \ - "$(jq -r '.tools.packages | {version, baseUrl, hash} | join(";")' buildspec.json)" - - mkdir -p ${project_root}/.deps && pushd ${project_root}/.deps - curl ${curl_opts} "${base_url}/Packages.dmg" - - local checksum="$(sha256sum Packages.dmg | cut -d " " -f 1)" - - if [[ ${hash} != ${checksum} ]] { - log_error "Checksum mismatch of Packages.dmg download. -Expected : ${hash} -Actual : ${checksum}" - return 2 - } - - hdiutil attach -readonly -noverify -noautoopen -plist Packages.dmg > .result.plist - local -i num_entities=$(( $(plutil -extract system-entities raw -- .result.plist) - 1 )) - local keys - local mount_point - for i ({0..${num_entities}}) { - keys=($(plutil -extract system-entities.${i} raw -- .result.plist)) - if [[ ${keys} == *mount-point* ]] { - mount_point=$(plutil -extract system-entities.${i}.mount-point raw -- .result.plist) - break - } - } - rm .result.plist - - log_status 'Installing Packages.app requires elevated privileges!' - - sudo installer -pkg ${mount_point}/packages/Packages.pkg -target / && rehash - hdiutil detach ${mount_point} &> /dev/null && log_status 'Packages.dmg image unmounted.' - popd - - log_group -} diff --git a/.github/workflows/pr-pull.yaml b/.github/workflows/pr-pull.yaml index 2c99fe3..b3fc057 100644 --- a/.github/workflows/pr-pull.yaml +++ b/.github/workflows/pr-pull.yaml @@ -6,7 +6,7 @@ on: paths-ignore: - '**.md' branches: [master, main] - types: [ opened, synchronize, reopened, labeled, unlabeled ] + types: [ opened, synchronize, reopened ] permissions: contents: read concurrency: diff --git a/cmake/common/compiler_common.cmake b/cmake/common/compiler_common.cmake index da4e144..8ac423f 100644 --- a/cmake/common/compiler_common.cmake +++ b/cmake/common/compiler_common.cmake @@ -3,7 +3,7 @@ include_guard(GLOBAL) # Set C and C++ language standards to C17 and C++17 -if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.17) +if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.21) set(CMAKE_C_STANDARD 17) else() set(CMAKE_C_STANDARD 11) diff --git a/cmake/macos/helpers.cmake b/cmake/macos/helpers.cmake index b0a8ce4..37b92bf 100644 --- a/cmake/macos/helpers.cmake +++ b/cmake/macos/helpers.cmake @@ -79,7 +79,8 @@ function(set_target_properties_plugin target) CONFIGURATIONS Release DESTINATION . OPTIONAL) - configure_file(cmake/macos/resources/create-package.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/create-package.cmake") + configure_file(cmake/macos/resources/distribution.in "${CMAKE_CURRENT_BINARY_DIR}/distribution" @ONLY) + configure_file(cmake/macos/resources/create-package.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/create-package.cmake" @ONLY) install(SCRIPT "${CMAKE_CURRENT_BINARY_DIR}/create-package.cmake") endfunction() diff --git a/cmake/macos/resources/create-package.cmake.in b/cmake/macos/resources/create-package.cmake.in index b30a8a3..a2f1b11 100644 --- a/cmake/macos/resources/create-package.cmake.in +++ b/cmake/macos/resources/create-package.cmake.in @@ -1,7 +1,35 @@ -set(CMAKE_PROJECT_NAME ${CMAKE_PROJECT_NAME}) -set(CMAKE_PROJECT_VERSION ${CMAKE_PROJECT_VERSION}) -set(MACOS_BUNDLEID ${MACOS_BUNDLEID}) -set(UUID_PACKAGE ${UUID_PACKAGE}) -set(UUID_INSTALLER ${UUID_INSTALLER}) -configure_file(cmake/macos/resources/installer-macos.pkgproj.in - "${CMAKE_CURRENT_BINARY_DIR}/installer-macos.generated.pkgproj") +make_directory("$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/package/Library/Application Support/obs-studio/plugins") + +if(EXISTS "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/@CMAKE_PROJECT_NAME@.plugin" AND NOT IS_SYMLINK "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/@CMAKE_PROJECT_NAME@.plugin") + file(INSTALL DESTINATION "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/package/Library/Application Support/obs-studio/plugins" + TYPE DIRECTORY FILES "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/@CMAKE_PROJECT_NAME@.plugin" USE_SOURCE_PERMISSIONS) + + if(CMAKE_INSTALL_CONFIG_NAME MATCHES "^([Rr][Ee][Ll][Ee][Aa][Ss][Ee])$" OR CMAKE_INSTALL_CONFIG_NAME MATCHES "^([Mm][Ii][Nn][Ss][Ii][Zz][Ee][Rr][Ee][Ll])$") + if(EXISTS "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/@CMAKE_PROJECT_NAME@.plugin.dSYM" AND NOT IS_SYMLINK "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/@CMAKE_PROJECT_NAME@.plugin.dSYM") + file(INSTALL DESTINATION "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/package/Library/Application Support/obs-studio/plugins" TYPE DIRECTORY FILES "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/@CMAKE_PROJECT_NAME@.plugin.dSYM" USE_SOURCE_PERMISSIONS) + endif() + endif() +endif() + +make_directory("$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/temp") + +execute_process( + COMMAND /usr/bin/pkgbuild + --identifier '@MACOS_BUNDLEID@' + --version '@CMAKE_PROJECT_VERSION@' + --root "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/package" + "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/temp/@CMAKE_PROJECT_NAME@.pkg" + COMMAND_ERROR_IS_FATAL ANY + ) + +execute_process( + COMMAND /usr/bin/productbuild + --distribution "@CMAKE_CURRENT_BINARY_DIR@/distribution" + --package-path "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/temp" + "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/@CMAKE_PROJECT_NAME@.pkg" + COMMAND_ERROR_IS_FATAL ANY) + +if(EXISTS "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/@CMAKE_PROJECT_NAME@.pkg") + file(REMOVE_RECURSE "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/temp") + file(REMOVE_RECURSE "$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/package") +endif() diff --git a/cmake/macos/resources/distribution.in b/cmake/macos/resources/distribution.in new file mode 100644 index 0000000..016043b --- /dev/null +++ b/cmake/macos/resources/distribution.in @@ -0,0 +1,33 @@ + + + + + @CMAKE_PROJECT_NAME@ + + + + + + + #@CMAKE_PROJECT_NAME@.pkg + + +