Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion packages/build-tools/src/builders/android.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import { uploadApplicationArchive } from '../utils/artifacts';
import {
configureExpoUpdatesIfInstalledAsync,
resolveRuntimeVersionForExpoUpdatesIfConfiguredAsync,
updateBuildRuntimeVersionInDatabaseAsync,
} from '../utils/expoUpdates';
import { uploadEmbeddedBundleAsync } from '../utils/expoUpdatesEmbedded';
import { Hook, runHookIfPresent } from '../utils/hooks';
Expand Down Expand Up @@ -103,14 +104,22 @@ async function buildAsync(ctx: BuildContext<Android.Job>): Promise<void> {
const resolvedExpoUpdatesRuntimeVersion = await ctx.runBuildPhase(
BuildPhase.CALCULATE_EXPO_UPDATES_RUNTIME_VERSION,
async () => {
return await resolveRuntimeVersionForExpoUpdatesIfConfiguredAsync({
const resolved = await resolveRuntimeVersionForExpoUpdatesIfConfiguredAsync({
cwd: ctx.getReactNativeProjectDirectory(),
logger: ctx.logger,
appConfig: await ctx.appConfig,
platform: ctx.job.platform,
workflow: ctx.job.type,
env: ctx.env,
});
if (resolved?.runtimeVersion) {
await updateBuildRuntimeVersionInDatabaseAsync(
ctx,
resolved.runtimeVersion,
resolved.fingerprintSources
);
}
return resolved;
}
);

Expand Down
11 changes: 10 additions & 1 deletion packages/build-tools/src/builders/ios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { uploadApplicationArchive } from '../utils/artifacts';
import {
configureExpoUpdatesIfInstalledAsync,
resolveRuntimeVersionForExpoUpdatesIfConfiguredAsync,
updateBuildRuntimeVersionInDatabaseAsync,
} from '../utils/expoUpdates';
import { uploadEmbeddedBundleAsync } from '../utils/expoUpdatesEmbedded';
import { Hook, runHookIfPresent } from '../utils/hooks';
Expand Down Expand Up @@ -104,14 +105,22 @@ async function buildAsync(ctx: BuildContext<Ios.Job>): Promise<void> {
const resolvedExpoUpdatesRuntimeVersion = await ctx.runBuildPhase(
BuildPhase.CALCULATE_EXPO_UPDATES_RUNTIME_VERSION,
async () => {
return await resolveRuntimeVersionForExpoUpdatesIfConfiguredAsync({
const resolved = await resolveRuntimeVersionForExpoUpdatesIfConfiguredAsync({
cwd: ctx.getReactNativeProjectDirectory(),
logger: ctx.logger,
appConfig: await ctx.appConfig,
platform: ctx.job.platform,
workflow: ctx.job.type,
env: ctx.env,
});
if (resolved?.runtimeVersion) {
await updateBuildRuntimeVersionInDatabaseAsync(
ctx,
resolved.runtimeVersion,
resolved.fingerprintSources
);
}
return resolved;
}
);

Expand Down
38 changes: 37 additions & 1 deletion packages/build-tools/src/utils/expoUpdates.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ExpoConfig } from '@expo/config';
import { BuildJob, Job, Platform, Workflow } from '@expo/eas-build-job';
import { BuildJob, BuildTrigger, Job, Platform, Workflow } from '@expo/eas-build-job';
import { bunyan } from '@expo/logger';
import { BuildStepEnv } from '@expo/steps';
import assert from 'assert';
Expand Down Expand Up @@ -194,6 +194,42 @@ export async function resolveRuntimeVersionForExpoUpdatesIfConfiguredAsync({
return resolvedRuntimeVersion;
}

export async function updateBuildRuntimeVersionInDatabaseAsync(
ctx: BuildContext<BuildJob>,
runtimeVersion: string,
fingerprintSources: object[] | null
): Promise<void> {
const buildId = ctx.env.EAS_BUILD_ID;
if (!buildId || ctx.job.triggeredBy !== BuildTrigger.GIT_BASED_INTEGRATION) {
return;
}
const fingerprintHash = fingerprintSources ? runtimeVersion : undefined;
const result = await ctx.graphqlClient
.mutation(
graphql(`
mutation UpdateBuildRuntimeVersionMutation(
$buildId: ID!
$runtimeVersion: String!
$fingerprintHash: String
) {
build {
updateBuildMetadata(
buildId: $buildId
metadata: { runtimeVersion: $runtimeVersion, fingerprintHash: $fingerprintHash }
) {
id
}
}
}
`),
{ buildId, runtimeVersion, fingerprintHash }
)
.toPromise();
if (result.error) {
throw result.error;
}
}

export async function getChannelAsync(ctx: BuildContext<Job>): Promise<string | null> {
switch (ctx.job.platform) {
case Platform.ANDROID: {
Expand Down
7 changes: 6 additions & 1 deletion packages/eas-cli/src/build/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,13 @@ export async function prepareBuildRequestForPlatformAsync<
}
assert(projectArchive);

// In INTERNAL mode the fingerprint is computed before prebuild runs, so native directories
// don't exist yet. The post-prebuild fingerprint is written to the DB by the
// CALCULATE_EXPO_UPDATES_RUNTIME_VERSION build phase instead.
const runtimeAndFingerprintMetadata =
await computeAndMaybeUploadRuntimeAndFingerprintMetadataAsync(ctx);
ctx.localBuildOptions.localBuildMode === LocalBuildMode.INTERNAL
? {}
: await computeAndMaybeUploadRuntimeAndFingerprintMetadataAsync(ctx);
const metadata = await collectMetadataAsync(ctx, runtimeAndFingerprintMetadata);
const buildParams = resolveBuildParamsInput(ctx, metadata);
const job = await builder.prepareJobAsync(ctx, {
Expand Down
Loading