Skip to content

Commit 5ceb58e

Browse files
committed
separate logic for apple appstore signing/distribution
1 parent 4152729 commit 5ceb58e

File tree

1 file changed

+29
-17
lines changed

1 file changed

+29
-17
lines changed

.github/autobuild/mac.sh

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,6 @@ prepare_signing() {
8282
[[ -n "${MACOS_CERTIFICATE:-}" ]] || return 1
8383
[[ -n "${MACOS_CERTIFICATE_ID:-}" ]] || return 1
8484
[[ -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
9185
[[ -n "${NOTARIZATION_PASSWORD:-}" ]] || return 1
9286
[[ -n "${KEYCHAIN_PASSWORD:-}" ]] || return 1
9387

@@ -105,14 +99,6 @@ prepare_signing() {
10599
## Put the certs to files
106100
echo "${MACOS_CERTIFICATE}" | base64 --decode > macos_certificate.p12
107101

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
115-
116102
# If set, put the CA public key into a file
117103
if [[ -n "${MACOS_CA_PUBLICKEY}" ]]; then
118104
echo "${MACOS_CA_PUBLICKEY}" | base64 --decode > CA.cer
@@ -121,12 +107,10 @@ prepare_signing() {
121107
# Set up a keychain for the build:
122108
security create-keychain -p "${KEYCHAIN_PASSWORD}" build.keychain
123109
security default-keychain -s build.keychain
124-
# Remove default re-lock timeout to avoid codesign hangs:
110+
# # Remove default re-lock timeout to avoid codesign hangs:
125111
security set-keychain-settings build.keychain
126112
security unlock-keychain -p "${KEYCHAIN_PASSWORD}" build.keychain
127113
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
130114
security set-key-partition-list -S apple-tool:,apple: -s -k "${KEYCHAIN_PASSWORD}" build.keychain
131115

132116
# Tell Github Workflow that we want signing
@@ -147,6 +131,34 @@ prepare_signing() {
147131
echo "macos_notarize=true" >> "$GITHUB_OUTPUT"
148132
fi
149133

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+
150162
return 0
151163
}
152164

0 commit comments

Comments
 (0)