@@ -71,12 +71,24 @@ setup() {
7171}
7272
7373prepare_signing () {
74+ # # Certificate types in use:
75+ # - MACOS_CERTIFICATE - Developer ID Application - for codesigning for adhoc release
76+ # - MAC_STORE_APP_CERT - Mac App Distribution - codesigning for App Store submission
77+ # - MAC_STORE_INST_CERT - Mac Installer Distribution - for signing installer pkg file for App Store submission
78+
7479 [[ " ${SIGN_IF_POSSIBLE:- 0} " == " 1" ]] || return 1
7580
7681 # Signing was requested, now check all prerequisites:
7782 [[ -n " ${MACOS_CERTIFICATE:- } " ]] || return 1
7883 [[ -n " ${MACOS_CERTIFICATE_ID:- } " ]] || return 1
7984 [[ -n " ${MACOS_CERTIFICATE_PWD:- } " ]] || return 1
85+ [[ -n " ${MAC_STORE_APP_CERT:- } " ]] || return 1
86+ [[ -n " ${MAC_STORE_APP_CERT_ID:- } " ]] || return 1
87+ [[ -n " ${MAC_STORE_APP_CERT_PWD:- } " ]] || return 1
88+ [[ -n " ${MAC_STORE_INST_CERT:- } " ]] || return 1
89+ [[ -n " ${MAC_STORE_INST_CERT_ID:- } " ]] || return 1
90+ [[ -n " ${MAC_STORE_INST_CERT_PWD:- } " ]] || return 1
91+ [[ -n " ${NOTARIZATION_PASSWORD:- } " ]] || return 1
8092 [[ -n " ${KEYCHAIN_PASSWORD:- } " ]] || return 1
8193
8294 # Check for notarization (not wanted on self signed build)
@@ -90,8 +102,16 @@ prepare_signing() {
90102
91103 echo " Signing was requested and all dependencies are satisfied"
92104
93- # Put the cert to a file
94- echo " ${MACOS_CERTIFICATE} " | base64 --decode > certificate.p12
105+ # # Put the certs to files
106+ echo " ${MACOS_CERTIFICATE} " | base64 --decode > macos_certificate.p12
107+
108+ # If distribution cert is present, set for store signing + submission
109+ if [[ -n " ${MAC_STORE_APP_CERT} " ]]; then
110+ echo " ${MAC_STORE_APP_CERT} " | base64 --decode > macapp_certificate.p12
111+ echo " ${MAC_STORE_INST_CERT} " | base64 --decode > macinst_certificate.p12
112+ # Tell Github Workflow that we are building for store submission
113+ echo " macos_store=true" >> " $GITHUB_OUTPUT "
114+ fi
95115
96116 # If set, put the CA public key into a file
97117 if [[ -n " ${MACOS_CA_PUBLICKEY} " ]]; then
@@ -104,8 +124,10 @@ prepare_signing() {
104124 # Remove default re-lock timeout to avoid codesign hangs:
105125 security set-keychain-settings build.keychain
106126 security unlock-keychain -p " ${KEYCHAIN_PASSWORD} " build.keychain
107- security import certificate.p12 -k build.keychain -P " ${MACOS_CERTIFICATE_PWD} " -T /usr/bin/codesign
108- security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k " ${KEYCHAIN_PASSWORD} " build.keychain
127+ security import macos_certificate.p12 -k build.keychain -P " ${MACOS_CERTIFICATE_PWD} " -A -T /usr/bin/codesign
128+ security import macapp_certificate.p12 -k build.keychain -P " ${MAC_STORE_APP_CERT_PWD} " -A -T /usr/bin/codesign
129+ security import macinst_certificate.p12 -k build.keychain -P " ${MAC_STORE_INST_CERT_PWD} " -A -T /usr/bin/productbuild
130+ security set-key-partition-list -S apple-tool:,apple: -s -k " ${KEYCHAIN_PASSWORD} " build.keychain
109131
110132 # Tell Github Workflow that we want signing
111133 echo " macos_signed=true" >> " $GITHUB_OUTPUT "
@@ -136,7 +158,7 @@ build_app_as_dmg_installer() {
136158 # Mac's bash version considers BUILD_ARGS unset without at least one entry:
137159 BUILD_ARGS=(" " )
138160 if prepare_signing; then
139- BUILD_ARGS=(" -s" " ${MACOS_CERTIFICATE_ID} " )
161+ BUILD_ARGS=(" -s" " ${MACOS_CERTIFICATE_ID} " " -a " " ${MAC_STORE_APP_CERT_ID} " " -i " " ${MAC_STORE_INST_CERT_ID} " " -k " " ${KEYCHAIN_PASSWORD} " )
140162 fi
141163 TARGET_ARCHS=" ${TARGET_ARCHS} " ./mac/deploy_mac.sh " ${BUILD_ARGS[@]} "
142164}
@@ -146,6 +168,27 @@ pass_artifact_to_job() {
146168 echo " Moving build artifact to deploy/${artifact} "
147169 mv ./deploy/Jamulus-* installer-mac.dmg " ./deploy/${artifact} "
148170 echo " artifact_1=${artifact} " >> " $GITHUB_OUTPUT "
171+
172+ artifact2=" jamulus_${JAMULUS_BUILD_VERSION} _mac${ARTIFACT_SUFFIX:- } .pkg"
173+ for file in ./deploy/Jamulus_* .pkg; do
174+ if [ -f " ${file} " ]; then
175+ echo " Moving build artifact2 to deploy/${artifact2} "
176+ mv " ${file} " " ./deploy/${artifact2} "
177+ echo " artifact_2=${artifact2} " >> " $GITHUB_OUTPUT "
178+ fi
179+ done
180+ }
181+
182+ appstore_submit () {
183+ echo " Submitting package to AppStore Connect..."
184+ # test the signature of package
185+ pkgutil --check-signature " ${ARTIFACT_PATH} "
186+
187+ xcrun notarytool submit " ${ARTIFACT_PATH} " \
188+ --apple-id " ${NOTARIZATION_USERNAME} " \
189+ --team-id " ${APPLE_TEAM_ID} " \
190+ --password " ${NOTARIZATION_PASSWORD} " \
191+ --wait
149192}
150193
151194case " ${1:- } " in
@@ -158,6 +201,9 @@ case "${1:-}" in
158201 get-artifacts)
159202 pass_artifact_to_job
160203 ;;
204+ appstore-submit)
205+ appstore_submit
206+ ;;
161207 * )
162208 echo " Unknown stage '${1:- } '"
163209 exit 1
0 commit comments