[eas-cli] Validate/regenerate/create distribution certificate in non-interactive iOS builds using submission ASC API key when present#3739
Conversation
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
--refresh-distribution-certificate for non-intractive builds
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## szymonswierk/non-interactive-build-provisioning-profile-validationa-and-refresh-best-effort #3739 +/- ##
===============================================================================================================================
+ Coverage 57.86% 57.99% +0.13%
===============================================================================================================================
Files 913 913
Lines 39622 39638 +16
Branches 8296 8304 +8
===============================================================================================================================
+ Hits 22925 22985 +60
+ Misses 15242 15204 -38
+ Partials 1455 1449 -6 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Subscribed to pull request
Generated by CodeMention |
763d237 to
1e21106
Compare
701b7d7 to
4c939d9
Compare
354509c to
e1e9a7e
Compare
quinlanj
left a comment
There was a problem hiding this comment.
lgtm. I'm surprised this was a feature people asked for because the number of dist certs apple lets you have in your account is very low (2-3 max)
d20291d to
d4b4bf6
Compare
e1e9a7e to
6436e27
Compare
| throw new Error( | ||
| 'No App Store Connect API Key found for distribution certificate refresh. In non-interactive mode, provide one via:\n' + | ||
| ' - Environment variables: EXPO_ASC_API_KEY_PATH, EXPO_ASC_KEY_ID, EXPO_ASC_ISSUER_ID\n' + | ||
| ' - EAS credentials service: configure an App Store Connect API Key for submissions on this app' |
There was a problem hiding this comment.
ugh it's still weird to me we're saying to use key for submissions to generate certificates
| Log.log(`Reusing distribution certificate with serial number ${cert.serialNumber}`); | ||
| return cert; | ||
| } | ||
| return await this.createNewDistCertAsync(ctx); |
There was a problem hiding this comment.
how likely is that we're going to hit
often? can we do something about it?There was a problem hiding this comment.
We're going to hit this when a new certificate needs to be created and there are already 3 (non-matching, e.g. for different teams) certificates in the Apple account. I don't think we should do anything automatically in this case, as this would involve revoking unrelated certs. We could make an opt-in flag to "force override" a cert.
6436e27 to
424bd35
Compare
…fort Remove the --refresh-distribution-certificate opt-in flag and validate or refresh distribution certificates automatically in non-interactive builds, reusing tryAuthenticateAppStoreWithEasAscApiKeyAsync from the parent stack.
424bd35 to
0d88201
Compare
15311b5 to
dc5b262
Compare
--refresh-distribution-certificate for non-intractive builds|
✅ Thank you for adding the changelog entry! |
|
Changed this to follow the "best effort" approach like provisioning profiles in #3805 instead of being opt-in with a flag, as I don't see any downsides of just attempting to do the validation when an ASC API key is available in EAS. If we were to do something like "force setup dist cert even if some other unrelated (other apple team) cert needs to be revoked", that would be an opt-in flag for special use cases. @quinlanj Apologies, re-requesting review. |

Why
When a non-interactive build runs (e.g. from CI or a workflow job) and the app's distribution certificate is invalid or out of sync with Apple, the build can fail even without
--freeze-credentials, because the certificate was not validated or refreshed against App Store Connect. That often forces a manual interactiveeas buildto repair credentials.See the Linear issue: https://linear.app/expo/issue/ENG-21330/make-it-possible-to-refresh-a-distribution-certificate-in-non
How
In
SetUpDistributionCertificate.runNonInteractiveAsync:MissingCredentialsNonInteractiveError(unchanged).EXPO_ASC_*) or the submission ASC API key from EAS credentials (same as provisioning profile repair).--freeze-credentials→ error.When ASC auth is unavailable but the certificate is still locally valid (dates OK), the build continues without Apple-side validation (existing skip behavior).
Test Plan
Added/updated unit tests in
SetUpDistributionCertificate-test.tsandIosCredentialsProvider-test.ts.Manual verification (non-interactive iOS development builds, no extra flags):
Credentials are not set uperror.--freeze-credentialswith invalid cert → blocked from repair.--refresh-ad-hoc-provisioning-profile→ ASC API key resolved once (shared best-effort auth).