From 2cdaa1833681347c82ad299f7120736f991100bd Mon Sep 17 00:00:00 2001 From: Piotr Szeremeta Date: Tue, 17 Dec 2024 18:34:36 +0100 Subject: [PATCH] ENG-14518 Add keystoreName field to build profile --- CHANGELOG.md | 1 + packages/eas-cli/src/build/android/build.ts | 1 + .../android/AndroidCredentialsProvider.ts | 3 ++- .../src/__tests__/buildProfiles-test.ts | 27 +++++++++++++++++++ packages/eas-json/src/build/schema.ts | 8 ++++++ packages/eas-json/src/build/types.ts | 2 ++ 6 files changed, 41 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 092f67a73d..a1f205257d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ This is the log of notable changes to EAS CLI and related packages. ### 🎉 New features - Add `eas deploy --dry-run` flag to output tarball. ([#2761](https://github.com/expo/eas-cli/pull/2761) by [@kitten](https://github.com/kitten)) +- Allow specifying credentials for android builds. ([#2775](https://github.com/expo/eas-cli/pull/2775) by [@khamilowicz](https://github.com/khamilowicz)) ### 🐛 Bug fixes diff --git a/packages/eas-cli/src/build/android/build.ts b/packages/eas-cli/src/build/android/build.ts index ee4fec6070..7b9d13081e 100644 --- a/packages/eas-cli/src/build/android/build.ts +++ b/packages/eas-cli/src/build/android/build.ts @@ -151,6 +151,7 @@ async function ensureAndroidCredentialsAsync( ctx.android.gradleContext ); const provider = new AndroidCredentialsProvider(ctx.credentialsCtx, { + name: ctx.buildProfile.keystoreName, app: { account: nullthrows( ctx.user.accounts.find(a => a.name === ctx.accountName), diff --git a/packages/eas-cli/src/credentials/android/AndroidCredentialsProvider.ts b/packages/eas-cli/src/credentials/android/AndroidCredentialsProvider.ts index c48b9f8357..c5824986dc 100644 --- a/packages/eas-cli/src/credentials/android/AndroidCredentialsProvider.ts +++ b/packages/eas-cli/src/credentials/android/AndroidCredentialsProvider.ts @@ -15,6 +15,7 @@ export interface AndroidCredentials { interface Options { app: AppLookupParams; + name?: string; } export default class AndroidCredentialsProvider { @@ -37,7 +38,7 @@ export default class AndroidCredentialsProvider { } private async getRemoteAsync(): Promise { - const setupBuildCredentialsAction = new SetUpBuildCredentials({ app: this.options.app }); + const setupBuildCredentialsAction = new SetUpBuildCredentials(this.options); const buildCredentials = await setupBuildCredentialsAction.runAsync(this.ctx); return this.toAndroidCredentials(buildCredentials); } diff --git a/packages/eas-json/src/__tests__/buildProfiles-test.ts b/packages/eas-json/src/__tests__/buildProfiles-test.ts index aacdb77dd7..3dc444af9e 100644 --- a/packages/eas-json/src/__tests__/buildProfiles-test.ts +++ b/packages/eas-json/src/__tests__/buildProfiles-test.ts @@ -129,6 +129,33 @@ test('valid eas.json with specified environment', async () => { }); }); +test('valid eas.json with specified keystoreName', async () => { + const keystoreName = 'this-is-a-keystore-name'; + await fs.writeJson('/project/eas.json', { + build: { + development: { + android: { + credentialsSource: 'remote', + keystoreName, + }, + }, + }, + }); + + const accessor = EasJsonAccessor.fromProjectPath('/project'); + const androidProfile = await EasJsonUtils.getBuildProfileAsync( + accessor, + Platform.ANDROID, + 'development' + ); + + expect(androidProfile).toEqual( + expect.objectContaining({ + keystoreName, + }) + ); +}); + test('valid eas.json with top level withoutCredentials property', async () => { await fs.writeJson('/project/eas.json', { build: { diff --git a/packages/eas-json/src/build/schema.ts b/packages/eas-json/src/build/schema.ts index 5021077a23..27f9b2e8f9 100644 --- a/packages/eas-json/src/build/schema.ts +++ b/packages/eas-json/src/build/schema.ts @@ -101,6 +101,14 @@ const AndroidBuildProfileSchema = PlatformBuildProfileSchema.concat( Joi.boolean(), Joi.string().valid('version', 'versionCode') ), + + keystoreName: Joi.when('credentialsSource', { + is: 'remote', + then: Joi.string(), + otherwise: Joi.forbidden().messages({ + 'any.unknown': 'keystoreName is not allowed when credentialsSource is not remote', + }), + }), }) ); diff --git a/packages/eas-json/src/build/types.ts b/packages/eas-json/src/build/types.ts index 6ab4b133f6..ff2f86895b 100644 --- a/packages/eas-json/src/build/types.ts +++ b/packages/eas-json/src/build/types.ts @@ -93,6 +93,8 @@ export interface AndroidBuildProfile extends PlatformBuildProfile { // versions autoIncrement?: AndroidVersionAutoIncrement; + + keystoreName?: string; } export interface IosBuildProfile extends PlatformBuildProfile {