Skip to content

Commit

Permalink
Merge pull request #53 from kambala-decapitator/macos-sign-notarize
Browse files Browse the repository at this point in the history
[macOS] sign & notarize
  • Loading branch information
chewitt authored Feb 22, 2024
2 parents ccace84 + 4f8f98b commit 222a1e6
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 0 deletions.
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,11 @@ elseif(APPLE)
foreach(qtModule in Pdf Svg)
file(REMOVE_RECURSE \"${bundleContentsDir}/Frameworks/Qt\\\${qtModule}.framework\")
endforeach()
# codesign
execute_process(COMMAND \"${CMAKE_SOURCE_DIR}/dmg_osx/codesign.sh\"
WORKING_DIRECTORY \"${bundleContentsDir}\"
)
")
install(SCRIPT ${qtDeployScript})
elseif(LINUX)
Expand All @@ -164,6 +169,7 @@ set(CPACK_PACKAGE_NAME "${projectDisplayName}")
set(CPACK_PACKAGE_VENDOR "LibreELEC")
if(APPLE)
set(CPACK_PACKAGE_FILE_NAME "LibreELEC.USB-SD.Creator.macOS")
set(CPACK_POST_BUILD_SCRIPTS "${CMAKE_SOURCE_DIR}/dmg_osx/notarize.cmake")

set(CPACK_GENERATOR DragNDrop)
set(CPACK_DMG_BACKGROUND_IMAGE "${CMAKE_SOURCE_DIR}/dmg_osx/background.png")
Expand Down
26 changes: 26 additions & 0 deletions dmg_osx/codesign.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env bash

# working directory - .app/Contents

if [ -z "$CODE_SIGN_IDENTITY" ] ; then
echo 'skip signing - no code sign identity provided in CODE_SIGN_IDENTITY'
exit 0
fi

function sign {
codesign --verbose=4 --force --timestamp --options=runtime --sign "$CODE_SIGN_IDENTITY" "$1"
}


echo 'sign frameworks'
for framework in Frameworks/*.framework ; do
sign "$framework"
done

echo 'sign dylibs'
for lib in $(find PlugIns -type f -iname '*.dylib') ; do
sign "$lib"
done

echo 'sign app bundle'
sign ..
30 changes: 30 additions & 0 deletions dmg_osx/notarize.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
set(dmgPath "${CPACK_PACKAGE_FILES}")

if(NOT DEFINED ENV{CODE_SIGN_IDENTITY})
message("skip dmg signing & notarization - no code sign identity provided in CODE_SIGN_IDENTITY")
return()
endif()
message("sign dmg")
execute_process(COMMAND
codesign --verbose=4 --force --sign "$ENV{CODE_SIGN_IDENTITY}" "${dmgPath}"
)

if(NOT DEFINED ENV{ASC_API_KEY} OR NOT DEFINED ENV{ASC_API_KEY_ID} OR NOT DEFINED ENV{ASC_API_KEY_ISSUER} OR NOT DEFINED ENV{ASC_TEAM_ID})
message("skip dmg notarization - ASC_API_KEY / ASC_API_KEY_ID / ASC_API_KEY_ISSUER / ASC_TEAM_ID not provided")
return()
endif()
message("notarize dmg")
execute_process(COMMAND
xcrun notarytool submit
--verbose
--key "$ENV{ASC_API_KEY}"
--key-id "$ENV{ASC_API_KEY_ID}"
--issuer "$ENV{ASC_API_KEY_ISSUER}"
--team-id "$ENV{ASC_TEAM_ID}"
--wait
--timeout 30m
"${dmgPath}"
)
execute_process(COMMAND
xcrun stapler staple "${dmgPath}"
)

0 comments on commit 222a1e6

Please sign in to comment.