CI: Update macOS packaging to use Xcode archiving and extraction

This commit is contained in:
PatTheMav 2023-03-29 04:04:06 +02:00 committed by Ryan Foster
parent a0000412fa
commit 84057ba93d
3 changed files with 43 additions and 16 deletions

View file

@ -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}"

View file

@ -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

View file

@ -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}
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"
mkdir -p "${FILE_NAME//.dmg/}/OBS.app"
ditto OBS.app "${FILE_NAME//.dmg/}/OBS.app"
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
DMG_NAME=$(/usr/bin/find "${BUILD_DIR}" -type f -name "obs-studio-*.dmg" -depth 1 | sort -rn | head -1)
if [ "${DMG_NAME}" ]; then
mv "${DMG_NAME}" "${BUILD_DIR}/${FILE_NAME}"
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
}
notarize_obs() {