diff --git a/CI/include/build_support_macos.sh b/CI/include/build_support_macos.sh index 97f9f6b52e69cc..b197df3bcf0261 100644 --- a/CI/include/build_support_macos.sh +++ b/CI/include/build_support_macos.sh @@ -120,6 +120,7 @@ read_codesign_ident() { step "Set up code signing..." read -p "${COLOR_ORANGE} + Apple developer identity: ${COLOR_RESET}" CODESIGN_IDENT fi + CODESIGN_IDENT_SHORT=$(echo "${CODESIGN_IDENT}" | /usr/bin/sed -En "s/.+\((.+)\)/\1/p") } ############################################################################## @@ -149,7 +150,6 @@ read_codesign_pass() { step "Update notarization keychain..." - CODESIGN_IDENT_SHORT=$(echo "${CODESIGN_IDENT}" | /usr/bin/sed -En "s/.+\((.+)\)/\1/p") echo -n "${COLOR_ORANGE}" /usr/bin/xcrun notarytool store-credentials "OBS-Codesign-Password" --apple-id "${CODESIGN_IDENT_USER}" --team-id "${CODESIGN_IDENT_SHORT}" --password "${CODESIGN_IDENT_PASS}" echo -n "${COLOR_RESET}" diff --git a/CI/macos/02_build_obs.sh b/CI/macos/02_build_obs.sh index 5a1e5687aa93b7..81f6f38b98687c 100755 --- a/CI/macos/02_build_obs.sh +++ b/CI/macos/02_build_obs.sh @@ -27,7 +27,25 @@ build_obs() { if [ "${PRESET}" != "macos-ci-${ARCH}" ]; then export NSUnbufferedIO=YES - set -o pipefail && cmake --build --preset macos-${ARCH} --parallel 2>&1 | xcbeautify + : "${PACKAGE:=}" + case "${GITHUB_EVENT_NAME}" in + push) if [[ ${GITHUB_REF_NAME} =~ [0-9]+.[0-9]+.[0-9]+(-(rc|beta).+)? ]]; then PACKAGE=1; fi ;; + pull_request) PACKAGE=1 ;; + esac + + pushd "build_${ARCH}" > /dev/null + + if [[ "${PACKAGE}" && "${CODESIGN_IDENT:--}" != '-' ]]; then + set -o pipefail && xcodebuild -archivePath "obs-studio.xcarchive" -scheme obs-studio -destination "generic/platform=macOS,name=Any Mac'" archive 2>&1 | xcbeautify + set -o pipefail && xcodebuild -exportArchive -archivePath "obs-studio.xcarchive" -exportOptionsPlist "exportOptions.plist" -exportPath "." 2>&1 | xcbeautify + else + set -o pipefail && xcodebuild -scheme obs-studio -destination "generic/platform=macOS,name=Any Mac" -configuration RelWithDebInfo 2>&1 | xcbeautify + + mkdir OBS.app + ditto UI/RelWithDebInfo/OBS.app OBS.app + fi + + popd > /dev/null unset NSUnbufferedIO else diff --git a/CI/macos/03_package_obs.sh b/CI/macos/03_package_obs.sh index 0b29b687bed5b4..82ecdee4efba18 100755 --- a/CI/macos/03_package_obs.sh +++ b/CI/macos/03_package_obs.sh @@ -19,27 +19,36 @@ package_obs() { status "Create macOS disk image" trap "caught_error 'package app'" ERR - info "/!\\ CPack will use an AppleScript to create the disk image, this will lead to a Finder window opening to adjust window settings. /!\\" - ensure_dir "${CHECKOUT_DIR}" step "Package OBS..." BUILD_DIR="build_${ARCH}" + root_dir="$(pwd)" + pushd "${BUILD_DIR}" > /dev/null > /dev/null - cpack -C ${BUILD_CONFIG:-RelWithDebInfo} - popd > /dev/null - DMG_NAME=$(/usr/bin/find "${BUILD_DIR}" -type f -name "obs-studio-*.dmg" -depth 1 | sort -rn | head -1) + mkdir -p "${FILE_NAME//.dmg/}/.background" + cp "${root_dir}/cmake/macos/resources/background.tiff" "${FILE_NAME//.dmg/}/.background/" + cp "${root_dir}/cmake/macos/resources/AppIcon.icns" "${FILE_NAME//.dmg/}/.VolumeIcon.icns" + ln -s /Applications "${FILE_NAME//.dmg/}/Applications" - if [ "${DMG_NAME}" ]; then - mv "${DMG_NAME}" "${BUILD_DIR}/${FILE_NAME}" + mkdir -p "${FILE_NAME//.dmg/}/OBS.app" + ditto OBS.app "${FILE_NAME//.dmg/}/OBS.app" - step "Codesign OBS disk image..." - /usr/bin/codesign --force --sign "${CODESIGN_IDENT:--}" "${BUILD_DIR}/${FILE_NAME}" - else - error "ERROR No suitable OBS disk image generated" - fi + hdiutil create -volname "${FILE_NAME//.dmg/}" -srcfolder "${FILE_NAME//.dmg/}" -ov -fs APFS -format UDRW temp.dmg + hdiutil attach -noverify -readwrite temp.dmg + osascript package.applescript "${FILE_NAME//.dmg/}" + hdiutil detach "/Volumes/${FILE_NAME//.dmg/}" + hdiutil convert -format ULMO -o "${FILE_NAME}" temp.dmg + + rm temp.dmg + + step "Codesign OBS disk image..." + /usr/bin/codesign --force --sign "${CODESIGN_IDENT:--}" "${FILE_NAME}" + + rm -rf "${FILE_NAME//.dmg/}" + popd > /dev/null } notarize_obs() {