From 11b26ff010199c98931f2a80100ca3e59370a430 Mon Sep 17 00:00:00 2001 From: Will Schurman Date: Tue, 23 Apr 2024 16:47:40 -0700 Subject: [PATCH] [build-tools] Pass through workflow from job to expo-updates CLI commands --- packages/build-tools/src/builders/android.ts | 8 +++++++- packages/build-tools/src/builders/ios.ts | 1 + .../steps/functions/calculateEASUpdateRuntimeVersion.ts | 9 ++++++++- packages/build-tools/src/utils/expoUpdates.ts | 5 ++++- .../build-tools/src/utils/resolveRuntimeVersionAsync.ts | 5 ++++- packages/eas-build-job/src/generic.ts | 1 + 6 files changed, 25 insertions(+), 4 deletions(-) diff --git a/packages/build-tools/src/builders/android.ts b/packages/build-tools/src/builders/android.ts index 8c5004f44..089a0828a 100644 --- a/packages/build-tools/src/builders/android.ts +++ b/packages/build-tools/src/builders/android.ts @@ -77,6 +77,7 @@ async function buildAsync(ctx: BuildContext): Promise { logger: ctx.logger, appConfig: ctx.appConfig, platform: ctx.job.platform, + workflow: ctx.job.type, }); } ); @@ -105,7 +106,12 @@ async function buildAsync(ctx: BuildContext): Promise { gradleCommand, androidDir: path.join(ctx.getReactNativeProjectDirectory(), 'android'), ...(resolvedExpoUpdatesRuntimeVersion - ? { extraEnv: { EXPO_UPDATES_FINGERPRINT_OVERRIDE: resolvedExpoUpdatesRuntimeVersion } } + ? { + extraEnv: { + EXPO_UPDATES_FINGERPRINT_OVERRIDE: resolvedExpoUpdatesRuntimeVersion, + EXPO_UPDATES_WORKFLOW_OVERRIDE: ctx.job.type, + }, + } : null), }); }); diff --git a/packages/build-tools/src/builders/ios.ts b/packages/build-tools/src/builders/ios.ts index 9bbec6026..2d0522cfa 100644 --- a/packages/build-tools/src/builders/ios.ts +++ b/packages/build-tools/src/builders/ios.ts @@ -85,6 +85,7 @@ async function buildAsync(ctx: BuildContext): Promise { logger: ctx.logger, appConfig: ctx.appConfig, platform: ctx.job.platform, + workflow: ctx.job.type, }); } ); diff --git a/packages/build-tools/src/steps/functions/calculateEASUpdateRuntimeVersion.ts b/packages/build-tools/src/steps/functions/calculateEASUpdateRuntimeVersion.ts index 4f0e7f8d9..58ddd067d 100644 --- a/packages/build-tools/src/steps/functions/calculateEASUpdateRuntimeVersion.ts +++ b/packages/build-tools/src/steps/functions/calculateEASUpdateRuntimeVersion.ts @@ -1,4 +1,4 @@ -import { Platform } from '@expo/eas-build-job'; +import { Platform, Workflow } from '@expo/eas-build-job'; import { BuildFunction, BuildStepInput, @@ -22,6 +22,12 @@ export function calculateEASUpdateRuntimeVersionFunction(ctx: CustomBuildContext required: !ctx.job.platform, allowedValueTypeName: BuildStepInputValueTypeName.STRING, }), + BuildStepInput.createProvider({ + id: 'workflow', + defaultValue: ctx.job.type, + required: !ctx.job.type, + allowedValueTypeName: BuildStepInputValueTypeName.STRING, + }), ], outputProviders: [ BuildStepOutput.createProvider({ @@ -47,6 +53,7 @@ export function calculateEASUpdateRuntimeVersionFunction(ctx: CustomBuildContext logger: stepCtx.logger, appConfig, platform: inputs.platform.value as Platform, + workflow: inputs.workflow.value as Workflow, }); if (resolvedRuntimeVersion) { outputs.resolved_eas_update_runtime_version.set(resolvedRuntimeVersion); diff --git a/packages/build-tools/src/utils/expoUpdates.ts b/packages/build-tools/src/utils/expoUpdates.ts index 9bfc18248..37c609eac 100644 --- a/packages/build-tools/src/utils/expoUpdates.ts +++ b/packages/build-tools/src/utils/expoUpdates.ts @@ -1,6 +1,6 @@ import assert from 'assert'; -import { Platform, Job, BuildJob } from '@expo/eas-build-job'; +import { Platform, Job, BuildJob, Workflow } from '@expo/eas-build-job'; import semver from 'semver'; import { ExpoConfig } from '@expo/config'; import { bunyan } from '@expo/logger'; @@ -215,11 +215,13 @@ export async function resolveRuntimeVersionForExpoUpdatesIfConfiguredAsync({ cwd, appConfig, platform, + workflow, logger, }: { cwd: string; appConfig: ExpoConfig; platform: Platform; + workflow: Workflow; logger: bunyan; }): Promise { const expoUpdatesPackageVersion = await getExpoUpdatesPackageVersionIfInstalledAsync(cwd, logger); @@ -231,6 +233,7 @@ export async function resolveRuntimeVersionForExpoUpdatesIfConfiguredAsync({ projectDir: cwd, exp: appConfig, platform, + workflow, logger, expoUpdatesPackageVersion, }); diff --git a/packages/build-tools/src/utils/resolveRuntimeVersionAsync.ts b/packages/build-tools/src/utils/resolveRuntimeVersionAsync.ts index fabfef970..197690c72 100644 --- a/packages/build-tools/src/utils/resolveRuntimeVersionAsync.ts +++ b/packages/build-tools/src/utils/resolveRuntimeVersionAsync.ts @@ -1,6 +1,7 @@ import { ExpoConfig } from '@expo/config'; import { Updates } from '@expo/config-plugins'; import { bunyan } from '@expo/logger'; +import { Workflow } from '@expo/eas-build-job'; import { ExpoUpdatesCLIModuleNotFoundError, expoUpdatesCommandAsync } from './expoUpdatesCli'; import { isModernExpoUpdatesCLIWithRuntimeVersionCommandSupported } from './expoUpdates'; @@ -8,12 +9,14 @@ import { isModernExpoUpdatesCLIWithRuntimeVersionCommandSupported } from './expo export async function resolveRuntimeVersionAsync({ exp, platform, + workflow, projectDir, logger, expoUpdatesPackageVersion, }: { exp: ExpoConfig; platform: 'ios' | 'android'; + workflow: Workflow; projectDir: string; logger: bunyan; expoUpdatesPackageVersion: string; @@ -32,7 +35,7 @@ export async function resolveRuntimeVersionAsync({ const resolvedRuntimeVersionJSONResult = await expoUpdatesCommandAsync( projectDir, - ['runtimeversion:resolve', '--platform', platform, ...extraArgs], + ['runtimeversion:resolve', '--platform', platform, '--workflow', workflow, ...extraArgs], { logger, } diff --git a/packages/eas-build-job/src/generic.ts b/packages/eas-build-job/src/generic.ts index 6a39be459..d0461b995 100644 --- a/packages/eas-build-job/src/generic.ts +++ b/packages/eas-build-job/src/generic.ts @@ -34,6 +34,7 @@ export namespace Generic { builderEnvironment: BuilderEnvironmentSchemaZ, // We use this to discern between Android.Job, Ios.Job and Generic.Job. platform: z.never().optional(), + type: z.never().optional(), triggeredBy: z.literal(BuildTrigger.GIT_BASED_INTEGRATION), loggerLevel: z.nativeEnum(LoggerLevel).optional(), });