@@ -119,10 +119,10 @@ jobs:
119119
120120 - run : pnpm install --frozen-lockfile
121121
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 .
122+ # Import Apple certificate ourselves, then DON'T pass APPLE_CERTIFICATE
123+ # to tauri-action. Tauri's bundler uses var_os() which treats empty
124+ # strings as present (Some("")), so we must completely omit the env var.
125+ # Instead we import the cert here and only pass APPLE_SIGNING_IDENTITY .
126126 - name : Import Apple certificate
127127 if : matrix.os == 'macos-latest' || matrix.os == 'macos-15'
128128 id : apple-cert
@@ -132,43 +132,45 @@ jobs:
132132 KEYCHAIN_PASSWORD : ${{ secrets.KEYCHAIN_PASSWORD }}
133133 run : |
134134 if [ -z "$APPLE_CERTIFICATE" ] || [ -z "$KEYCHAIN_PASSWORD" ]; then
135- echo "No Apple certificate configured — skipping import "
136- echo "cert_ok=false " >> "$GITHUB_OUTPUT"
135+ echo "No Apple certificate configured — using ad-hoc signing "
136+ echo "identity=- " >> "$GITHUB_OUTPUT"
137137 exit 0
138138 fi
139139 echo "$APPLE_CERTIFICATE" | base64 --decode > certificate.p12
140140 if [ ! -s certificate.p12 ]; then
141- echo "Certificate decode produced empty file — skipping import "
141+ echo "Certificate decode produced empty file — using ad-hoc signing "
142142 rm -f certificate.p12
143- echo "cert_ok=false " >> "$GITHUB_OUTPUT"
143+ echo "identity=- " >> "$GITHUB_OUTPUT"
144144 exit 0
145145 fi
146146 security create-keychain -p "$KEYCHAIN_PASSWORD" build.keychain
147147 security default-keychain -s build.keychain
148148 security unlock-keychain -p "$KEYCHAIN_PASSWORD" build.keychain
149149 if ! security import certificate.p12 -k build.keychain -P "$APPLE_CERTIFICATE_PASSWORD" -T /usr/bin/codesign; then
150- echo "Certificate import failed — falling back to ad-hoc signing"
150+ echo "Certificate import failed — using ad-hoc signing"
151151 rm -f certificate.p12
152- echo "cert_ok=false " >> "$GITHUB_OUTPUT"
152+ echo "identity=- " >> "$GITHUB_OUTPUT"
153153 exit 0
154154 fi
155155 security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "$KEYCHAIN_PASSWORD" build.keychain
156156 rm certificate.p12
157+ echo "identity=${{ secrets.APPLE_SIGNING_IDENTITY }}" >> "$GITHUB_OUTPUT"
157158 echo "cert_ok=true" >> "$GITHUB_OUTPUT"
158159
160+ # IMPORTANT: Do NOT pass APPLE_CERTIFICATE to tauri-action.
161+ # We handle certificate import ourselves above. Tauri's bundler
162+ # treats empty strings as "certificate present" and tries to import,
163+ # which fails. By omitting the var entirely, the bundler skips import
164+ # and uses the identity from APPLE_SIGNING_IDENTITY (or ad-hoc).
159165 - name : Build Tauri app
160166 uses : tauri-apps/tauri-action@v0
161167 env :
162168 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
163169 TAURI_SIGNING_PRIVATE_KEY : ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
164170 TAURI_SIGNING_PRIVATE_KEY_PASSWORD : ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
165171 PKG_CONFIG_PATH : /usr/lib/x86_64-linux-gnu/pkgconfig:/usr/lib/pkgconfig:/usr/share/pkgconfig
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_SIGNING_IDENTITY : ${{ steps.apple-cert.outputs.identity }}
173+ # Notarization only when cert import succeeded
172174 APPLE_ID : ${{ steps.apple-cert.outputs.cert_ok == 'true' && secrets.APPLE_ID || '' }}
173175 APPLE_PASSWORD : ${{ steps.apple-cert.outputs.cert_ok == 'true' && secrets.APPLE_PASSWORD || '' }}
174176 APPLE_TEAM_ID : ${{ steps.apple-cert.outputs.cert_ok == 'true' && secrets.APPLE_TEAM_ID || '' }}
0 commit comments