2020-10-24 17:08:40 +08:00
#!/bin/bash -xe
2020-10-17 23:05:10 +08:00
2021-04-05 02:24:22 +08:00
lipo \
-create \
build/bin/SolveSpace.app/Contents/Resources/libomp.dylib \
build-arm64/bin/SolveSpace.app/Contents/Resources/libomp.dylib \
-output \
build/bin/SolveSpace.app/Contents/Resources/libomp.dylib
2021-02-08 08:07:21 +08:00
lipo \
-create \
build/bin/SolveSpace.app/Contents/MacOS/SolveSpace \
build-arm64/bin/SolveSpace.app/Contents/MacOS/SolveSpace \
-output \
build/bin/SolveSpace.app/Contents/MacOS/SolveSpace
lipo \
-create \
build/bin/SolveSpace.app/Contents/MacOS/solvespace-cli \
build-arm64/bin/SolveSpace.app/Contents/MacOS/solvespace-cli \
-output \
build/bin/SolveSpace.app/Contents/MacOS/solvespace-cli
2020-10-17 23:05:10 +08:00
cd build
2021-04-05 01:15:00 +08:00
openmp = "bin/SolveSpace.app/Contents/Resources/libomp.dylib"
2020-10-19 17:24:37 +08:00
app = "bin/SolveSpace.app"
2020-10-17 23:05:10 +08:00
dmg = "bin/SolveSpace.dmg"
bundle_id = "com.solvespace.solvespace"
2020-10-20 15:39:26 +08:00
if [ " $CI " = "true" ] ; then
# get the signing certificate (this is the Developer ID:Application: Your Name, exported to a p12 file, then converted to base64, e.g.: cat ~/Desktop/certificate.p12 | base64 | pbcopy)
echo $MACOS_CERTIFICATE_P12 | base64 --decode > certificate.p12
2020-10-17 23:05:10 +08:00
2020-10-20 15:39:26 +08:00
# create a keychain
security create-keychain -p secret build.keychain
security default-keychain -s build.keychain
security unlock-keychain -p secret build.keychain
2020-10-17 23:05:10 +08:00
2020-10-20 15:39:26 +08:00
# import the key
2020-10-20 20:14:49 +08:00
security import certificate.p12 -k build.keychain -P " ${ MACOS_CERTIFICATE_PASSWORD } " -T /usr/bin/codesign
2020-10-17 23:05:10 +08:00
2020-10-20 15:39:26 +08:00
security set-key-partition-list -S apple-tool:,apple: -s -k secret build.keychain
2020-10-17 23:05:10 +08:00
2020-10-20 15:39:26 +08:00
# check if all is good
security find-identity -v
fi
2020-10-17 23:05:10 +08:00
2020-10-26 10:38:32 +08:00
# sign openmp
codesign -s " ${ MACOS_DEVELOPER_ID } " --timestamp --options runtime -f --deep " ${ openmp } "
2020-10-19 17:24:37 +08:00
# sign the .app
codesign -s " ${ MACOS_DEVELOPER_ID } " --timestamp --options runtime -f --deep " ${ app } "
# create the .dmg from the signed .app
hdiutil create -srcfolder " ${ app } " " ${ dmg } "
2020-10-17 23:05:10 +08:00
# sign the .dmg
2020-10-18 16:50:02 +08:00
codesign -s " ${ MACOS_DEVELOPER_ID } " --timestamp --options runtime -f --deep " ${ dmg } "
2020-10-17 23:05:10 +08:00
2023-09-13 04:04:56 +08:00
if ! command -v xcrun >/dev/null || ! xcrun --find notarytool >/dev/null; then
echo "Notarytool is not present in the system. Notarization has failed."
exit 1
fi
# Submit the package for notarization
notarization_output = $(
xcrun notarytool submit " ${ dmg } " \
2024-04-21 22:38:02 +08:00
--apple-id "hello@koenschmeets.nl" \
2023-09-13 04:04:56 +08:00
--password "@env:MACOS_APPSTORE_APP_PASSWORD" \
--team-id "8X77K9NDG3" \
--wait 2>& 1)
if [ $? -eq 0 ] ; then
# Extract the operation ID from the output
operation_id = $( echo " $notarization_output " | awk '/RequestUUID/ {print $NF}' )
echo " Notarization submitted. Operation ID: $operation_id "
exit 0
else
echo " Notarization failed. Error: $notarization_output "
exit 1
fi
fi
2020-10-17 23:05:10 +08:00
# staple
2021-06-24 22:47:49 +08:00
xcrun stapler staple " ${ dmg } "