@@ -119,50 +119,42 @@ jobs:
119119
120120 - run : pnpm install --frozen-lockfile
121121
122- # Import Apple certificate for macOS signing (only when Developer ID is available)
122+ # Import Apple certificate for macOS signing. Outputs cert_ok=true
123+ # only when the certificate was successfully imported into keychain.
124+ # If import fails, tauri-action gets no APPLE_CERTIFICATE, forcing
125+ # ad-hoc signing instead of failing the build.
123126 - name : Import Apple certificate
124127 if : matrix.os == 'macos-latest' || matrix.os == 'macos-15'
128+ id : apple-cert
125129 env :
126130 APPLE_CERTIFICATE : ${{ secrets.APPLE_CERTIFICATE }}
127131 APPLE_CERTIFICATE_PASSWORD : ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
128132 KEYCHAIN_PASSWORD : ${{ secrets.KEYCHAIN_PASSWORD }}
129133 run : |
130134 if [ -z "$APPLE_CERTIFICATE" ] || [ -z "$KEYCHAIN_PASSWORD" ]; then
131135 echo "No Apple certificate configured — skipping import"
136+ echo "cert_ok=false" >> "$GITHUB_OUTPUT"
132137 exit 0
133138 fi
134139 echo "$APPLE_CERTIFICATE" | base64 --decode > certificate.p12
135- # Validate the decoded file is a real PKCS#12 before attempting import
136140 if [ ! -s certificate.p12 ]; then
137141 echo "Certificate decode produced empty file — skipping import"
138142 rm -f certificate.p12
143+ echo "cert_ok=false" >> "$GITHUB_OUTPUT"
139144 exit 0
140145 fi
141146 security create-keychain -p "$KEYCHAIN_PASSWORD" build.keychain
142147 security default-keychain -s build.keychain
143148 security unlock-keychain -p "$KEYCHAIN_PASSWORD" build.keychain
144149 if ! security import certificate.p12 -k build.keychain -P "$APPLE_CERTIFICATE_PASSWORD" -T /usr/bin/codesign; then
145- echo "⚠ Certificate import failed — falling back to ad-hoc signing"
150+ echo "Certificate import failed — falling back to ad-hoc signing"
146151 rm -f certificate.p12
152+ echo "cert_ok=false" >> "$GITHUB_OUTPUT"
147153 exit 0
148154 fi
149155 security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "$KEYCHAIN_PASSWORD" build.keychain
150156 rm certificate.p12
151-
152- # Determine macOS signing identity: Developer ID if available, ad-hoc (-) otherwise
153- - name : Resolve macOS signing identity
154- if : matrix.os == 'macos-latest' || matrix.os == 'macos-15'
155- id : macos-signing
156- env :
157- APPLE_SIGNING_IDENTITY : ${{ secrets.APPLE_SIGNING_IDENTITY }}
158- run : |
159- if [ -n "$APPLE_SIGNING_IDENTITY" ]; then
160- echo "identity=$APPLE_SIGNING_IDENTITY" >> "$GITHUB_OUTPUT"
161- echo "Using Developer ID signing"
162- else
163- echo "identity=-" >> "$GITHUB_OUTPUT"
164- echo "Using ad-hoc signing (no Apple Developer ID)"
165- fi
157+ echo "cert_ok=true" >> "$GITHUB_OUTPUT"
166158
167159 - name : Build Tauri app
168160 uses : tauri-apps/tauri-action@v0
@@ -171,14 +163,15 @@ jobs:
171163 TAURI_SIGNING_PRIVATE_KEY : ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
172164 TAURI_SIGNING_PRIVATE_KEY_PASSWORD : ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
173165 PKG_CONFIG_PATH : /usr/lib/x86_64-linux-gnu/pkgconfig:/usr/lib/pkgconfig:/usr/share/pkgconfig
174- # macOS signing — falls back to ad-hoc (-) when no Apple Developer cert
175- APPLE_SIGNING_IDENTITY : ${{ steps.macos-signing.outputs.identity }}
176- APPLE_CERTIFICATE : ${{ secrets.APPLE_CERTIFICATE }}
177- APPLE_CERTIFICATE_PASSWORD : ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
178- # macOS notarization (only works with Developer ID)
179- APPLE_ID : ${{ secrets.APPLE_ID }}
180- APPLE_PASSWORD : ${{ secrets.APPLE_PASSWORD }}
181- APPLE_TEAM_ID : ${{ secrets.APPLE_TEAM_ID }}
166+ # Only pass Apple certificate/signing to tauri-action when import succeeded.
167+ # When cert_ok is false, these are empty strings — tauri falls back to ad-hoc signing.
168+ APPLE_SIGNING_IDENTITY : ${{ steps.apple-cert.outputs.cert_ok == 'true' && secrets.APPLE_SIGNING_IDENTITY || '' }}
169+ APPLE_CERTIFICATE : ${{ steps.apple-cert.outputs.cert_ok == 'true' && secrets.APPLE_CERTIFICATE || '' }}
170+ APPLE_CERTIFICATE_PASSWORD : ${{ steps.apple-cert.outputs.cert_ok == 'true' && secrets.APPLE_CERTIFICATE_PASSWORD || '' }}
171+ # macOS notarization (only works with Developer ID cert)
172+ APPLE_ID : ${{ steps.apple-cert.outputs.cert_ok == 'true' && secrets.APPLE_ID || '' }}
173+ APPLE_PASSWORD : ${{ steps.apple-cert.outputs.cert_ok == 'true' && secrets.APPLE_PASSWORD || '' }}
174+ APPLE_TEAM_ID : ${{ steps.apple-cert.outputs.cert_ok == 'true' && secrets.APPLE_TEAM_ID || '' }}
182175 with :
183176 projectPath : apps/desktop
184177 # Upload to the existing draft release
0 commit comments