2022-08-26 15:45:49 +02:00
#!/usr/bin/python3
2023-01-19 10:33:49 +01:00
# SPDX-License-Identifier: LicenseRef-EliasSteurerTachiom OR AGPL-3.0-only
2023-08-24 16:17:48 +02:00
from build_config import BuildConfig
from util import run
2022-11-02 12:15:34 +01:00
from sys import stdout
stdout . reconfigure ( encoding = ' utf-8 ' )
2022-08-26 15:45:49 +02:00
2023-08-24 16:02:43 +02:00
2022-08-26 15:45:49 +02:00
def sign ( build_config : BuildConfig ) :
print ( " Run codedesign " )
2023-08-24 16:17:48 +02:00
# run("codesign -f -s 'Developer ID Application: Elias Steurer (V887LHYKRH)' --verbose --force --timestamp --options 'runtime' -f --entitlements '../../ScreenPlay/entitlements.plist' 'ScreenPlay.app/' ",
2023-02-11 11:57:09 +01:00
# cwd=build_config.bin_dir)
# Do not use --deep https://developer.apple.com/forums/thread/129980
# base_sign_command = "codesign -s \"Developer ID Application: Elias Steurer (V887LHYKRH)\" --verbose --force --timestamp --options \"runtime\" \"ScreenPlay.app/Contents/MacOS/{app}\""
# run(base_sign_command.format(app="ffmpeg"), cwd=build_config.bin_dir)
# run(base_sign_command.format(app="ffprobe"), cwd=build_config.bin_dir)
2023-08-24 16:17:48 +02:00
run ( " codesign --deep -s \" Developer ID Application: Elias Steurer (V887LHYKRH) \" --verbose --force --timestamp --options \" runtime \" --entitlements \" ../../ScreenPlay/entitlements.plist \" \" ScreenPlay.app/ \" " ,
2022-08-26 15:45:49 +02:00
cwd = build_config . bin_dir )
print ( " Run codedesign verify " )
2023-08-24 16:17:48 +02:00
run ( " codesign --verify --verbose=4 ' ScreenPlay.app/ ' " ,
2022-08-26 15:45:49 +02:00
cwd = build_config . bin_dir )
# Note the profile is the one name of the first step of (App Store Connect API) in the macOSSigning.md
# xcrun notarytool submit "ScreenPlay.app.zip" --keychain-profile "ScreenPlay" --wait
# xcrun stapler staple "ScreenPlay.app"
print ( " Packing .apps for upload " )
2023-08-24 16:17:48 +02:00
run ( " ditto -c -k --keepParent ' ScreenPlay.app ' ' ScreenPlay.app.zip ' " ,
cwd = build_config . bin_dir )
2023-02-09 11:52:12 +01:00
# run this if you get an error:
# `xcrun notarytool log --apple-id "xxxxx@xxxx.com" --password "xxxx-xxxx-xxxx-xxxx" --team-id "xxxxxxxxxxx" <ID>`
# Processing complete
# id: xxxxxx-xxxxxx-xxxx-xxxxx-xxxxx
# status: Invalid
2022-08-26 15:45:49 +02:00
print ( " Run xcnotary submit " )
2023-08-24 16:17:48 +02:00
run ( " xcrun notarytool submit --keychain-profile ' ScreenPlay ' ScreenPlay.app.zip --wait " ,
cwd = build_config . bin_dir )
2022-08-26 15:45:49 +02:00
print ( " Run stapler staple " )
run ( " xcrun stapler staple ScreenPlay.app " , cwd = build_config . bin_dir )
print ( " Run spctl assess " )
2023-02-09 11:52:12 +01:00
run ( " spctl --assess --verbose ' ScreenPlay.app/ ' " , cwd = build_config . bin_dir )
2022-08-26 15:45:49 +02:00
2023-08-24 16:02:43 +02:00
print ( " Remove ScreenPlay.app.zip. " )
2022-08-26 15:45:49 +02:00
run ( " rm ScreenPlay.app.zip " , cwd = build_config . bin_dir )
2023-08-24 16:17:48 +02:00
2023-08-24 16:02:43 +02:00
def sign_dmg ( build_config : BuildConfig ) :
# Sign the DMG
2023-12-03 11:42:51 +01:00
run ( " codesign -f -s \" 3rd Party Mac Developer Installer: Elias Steurer (V887LHYKRH) \" --timestamp -f --deep \" ScreenPlay-Installer.dmg \" " , cwd = build_config . build_folder )
2023-08-24 16:17:48 +02:00
2023-08-24 16:02:43 +02:00
# Verify the DMG's signature
2023-08-24 16:17:48 +02:00
run ( " codesign --verify --verbose=4 \" ScreenPlay-Installer.dmg \" " ,
cwd = build_config . build_folder )
2023-08-24 16:02:43 +02:00
# Pack the DMG for notarization
2023-08-24 16:17:48 +02:00
run ( " ditto -c -k --keepParent ScreenPlay-Installer.dmg ScreenPlay-Installer.dmg.zip " ,
cwd = build_config . build_folder )
2023-08-24 16:02:43 +02:00
# Notarize the DMG using notarytool
2023-08-24 16:17:48 +02:00
run ( " xcrun notarytool submit ScreenPlay-Installer.dmg.zip --keychain-profile ' ScreenPlay ' --wait " ,
cwd = build_config . build_folder )
2023-08-24 16:02:43 +02:00
# Staple the notarization ticket to the DMG
2023-08-24 16:17:48 +02:00
run ( " xcrun stapler staple ScreenPlay-Installer.dmg " ,
cwd = build_config . build_folder )
2023-08-24 16:02:43 +02:00
# Check the notarization status for the DMG
2023-08-24 16:17:48 +02:00
run ( " spctl --assess --verbose \" ScreenPlay-Installer.dmg \" " ,
cwd = build_config . build_folder )
2023-08-24 16:02:43 +02:00
# Clean up the zip file
run ( " rm ScreenPlay-Installer.dmg.zip " , cwd = build_config . build_folder )