@@ -71,12 +71,18 @@ 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 " ${NOTARIZATION_PASSWORD:- } " ]] || return 1
8086 [[ -n " ${KEYCHAIN_PASSWORD:- } " ]] || return 1
8187
8288 # Check for notarization (not wanted on self signed build)
@@ -90,8 +96,8 @@ prepare_signing() {
9096
9197 echo " Signing was requested and all dependencies are satisfied"
9298
93- # Put the cert to a file
94- echo " ${MACOS_CERTIFICATE} " | base64 --decode > certificate .p12
99+ # # Put the certs to files
100+ echo " ${MACOS_CERTIFICATE} " | base64 --decode > macos_certificate .p12
95101
96102 # If set, put the CA public key into a file
97103 if [[ -n " ${MACOS_CA_PUBLICKEY} " ]]; then
@@ -104,8 +110,8 @@ prepare_signing() {
104110 # Remove default re-lock timeout to avoid codesign hangs:
105111 security set-keychain-settings build.keychain
106112 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
113+ security import macos_certificate .p12 -k build.keychain -P " ${MACOS_CERTIFICATE_PWD} " -A -T /usr/bin/codesign
114+ security set-key-partition-list -S apple-tool:,apple: -s -k " ${KEYCHAIN_PASSWORD} " build.keychain
109115
110116 # Tell Github Workflow that we want signing
111117 echo " macos_signed=true" >> " $GITHUB_OUTPUT "
@@ -125,6 +131,34 @@ prepare_signing() {
125131 echo " macos_notarize=true" >> " $GITHUB_OUTPUT "
126132 fi
127133
134+ # If distribution cert is present, set for store signing + submission
135+ if [[ -n " ${MAC_STORE_APP_CERT} " ]]; then
136+
137+ # Check all Github secrets are in place
138+ # MAC_STORE_APP_CERT already checked
139+ [[ -n " ${MAC_STORE_APP_CERT_ID:- } " ]] || return 1
140+ [[ -n " ${MAC_STORE_APP_CERT_PWD:- } " ]] || return 1
141+ [[ -n " ${MAC_STORE_INST_CERT:- } " ]] || return 1
142+ [[ -n " ${MAC_STORE_INST_CERT_ID:- } " ]] || return 1
143+ [[ -n " ${MAC_STORE_INST_CERT_PWD:- } " ]] || return 1
144+
145+ # Put the certs to files
146+ echo " ${MAC_STORE_APP_CERT} " | base64 --decode > macapp_certificate.p12
147+ echo " ${MAC_STORE_INST_CERT} " | base64 --decode > macinst_certificate.p12
148+
149+ echo " App Store distribution dependencies are satisfied, proceeding..."
150+
151+ # Add additional certs to the keychain
152+ security set-keychain-settings build.keychain
153+ security unlock-keychain -p " ${KEYCHAIN_PASSWORD} " build.keychain
154+ security import macapp_certificate.p12 -k build.keychain -P " ${MAC_STORE_APP_CERT_PWD} " -A -T /usr/bin/codesign
155+ security import macinst_certificate.p12 -k build.keychain -P " ${MAC_STORE_INST_CERT_PWD} " -A -T /usr/bin/productbuild
156+ security set-key-partition-list -S apple-tool:,apple: -s -k " ${KEYCHAIN_PASSWORD} " build.keychain
157+
158+ # Tell Github Workflow that we are building for store submission
159+ echo " macos_store=true" >> " $GITHUB_OUTPUT "
160+ fi
161+
128162 return 0
129163}
130164
@@ -136,7 +170,7 @@ build_app_as_dmg_installer() {
136170 # Mac's bash version considers BUILD_ARGS unset without at least one entry:
137171 BUILD_ARGS=(" " )
138172 if prepare_signing; then
139- BUILD_ARGS=(" -s" " ${MACOS_CERTIFICATE_ID} " )
173+ BUILD_ARGS=(" -s" " ${MACOS_CERTIFICATE_ID} " " -a " " ${MAC_STORE_APP_CERT_ID} " " -i " " ${MAC_STORE_INST_CERT_ID} " " -k " " ${KEYCHAIN_PASSWORD} " )
140174 fi
141175 TARGET_ARCHS=" ${TARGET_ARCHS} " ./mac/deploy_mac.sh " ${BUILD_ARGS[@]} "
142176}
@@ -146,6 +180,26 @@ pass_artifact_to_job() {
146180 echo " Moving build artifact to deploy/${artifact} "
147181 mv ./deploy/Jamulus-* installer-mac.dmg " ./deploy/${artifact} "
148182 echo " artifact_1=${artifact} " >> " $GITHUB_OUTPUT "
183+
184+ artifact2=" jamulus_${JAMULUS_BUILD_VERSION} _mac${ARTIFACT_SUFFIX:- } .pkg"
185+ file=(./deploy/Jamulus_* .pkg)
186+ if [ -f " ${file[0]} " ]; then
187+ echo " Moving build artifact2 to deploy/${artifact2} "
188+ mv " ${file[0]} " " ./deploy/${artifact2} "
189+ echo " artifact_2=${artifact2} " >> " $GITHUB_OUTPUT "
190+ fi
191+ }
192+
193+ appstore_submit () {
194+ echo " Submitting package to AppStore Connect..."
195+ # test the signature of package
196+ pkgutil --check-signature " ${ARTIFACT_PATH} "
197+
198+ xcrun notarytool submit " ${ARTIFACT_PATH} " \
199+ --apple-id " ${NOTARIZATION_USERNAME} " \
200+ --team-id " ${APPLE_TEAM_ID} " \
201+ --password " ${NOTARIZATION_PASSWORD} " \
202+ --wait
149203}
150204
151205case " ${1:- } " in
@@ -158,6 +212,9 @@ case "${1:-}" in
158212 get-artifacts)
159213 pass_artifact_to_job
160214 ;;
215+ appstore-submit)
216+ appstore_submit
217+ ;;
161218 * )
162219 echo " Unknown stage '${1:- } '"
163220 exit 1
0 commit comments