diff --git a/packages/build-tools/src/context.ts b/packages/build-tools/src/context.ts index d8e9d1136..06d65a689 100644 --- a/packages/build-tools/src/context.ts +++ b/packages/build-tools/src/context.ts @@ -12,6 +12,8 @@ import { errors, Metadata, EnvironmentSecretType, + GenericArtifactType, + isGenericArtifact, } from '@expo/eas-build-job'; import { ExpoConfig } from '@expo/config'; import { bunyan } from '@expo/logger'; @@ -35,11 +37,18 @@ export interface LogBuffer { getPhaseLogs(buildPhase: string): string[]; } -export type ArtifactToUpload = { - type: ManagedArtifactType; - paths: string[]; - logger: bunyan; -}; +export type ArtifactToUpload = + | { + type: ManagedArtifactType; + paths: string[]; + logger: bunyan; + } + | { + type: GenericArtifactType; + key: string; + paths: string[]; + logger: bunyan; + }; export interface BuildContextOptions { workingdir: string; @@ -214,7 +223,7 @@ export class BuildContext { public async uploadArtifacts(artifact: ArtifactToUpload): Promise { const bucketKey = await this._uploadArtifacts(artifact); - if (bucketKey) { + if (bucketKey && !isGenericArtifact(artifact)) { this.artifacts[artifact.type] = bucketKey; } } diff --git a/packages/build-tools/src/steps/functions/uploadArtifact.ts b/packages/build-tools/src/steps/functions/uploadArtifact.ts index c83e5f981..a69f3aa5b 100644 --- a/packages/build-tools/src/steps/functions/uploadArtifact.ts +++ b/packages/build-tools/src/steps/functions/uploadArtifact.ts @@ -1,6 +1,6 @@ import path from 'path'; -import { ManagedArtifactType } from '@expo/eas-build-job'; +import { GenericArtifactType, ManagedArtifactType, isGenericArtifact } from '@expo/eas-build-job'; import { BuildFunction, BuildStepInput, BuildStepInputValueTypeName } from '@expo/steps'; import nullthrows from 'nullthrows'; @@ -18,10 +18,17 @@ export function createUploadArtifactBuildFunction(ctx: CustomBuildContext): Buil allowedValues: [ ManagedArtifactType.APPLICATION_ARCHIVE, ManagedArtifactType.BUILD_ARTIFACTS, + ...Object.values(GenericArtifactType), ], required: true, allowedValueTypeName: BuildStepInputValueTypeName.STRING, }), + BuildStepInput.createProvider({ + id: 'key', + defaultValue: '', + required: false, + allowedValueTypeName: BuildStepInputValueTypeName.STRING, + }), BuildStepInput.createProvider({ id: 'path', required: true, @@ -33,13 +40,24 @@ export function createUploadArtifactBuildFunction(ctx: CustomBuildContext): Buil stepsCtx.workingDirectory, nullthrows(inputs.path.value).toString() ); - const artifactType = inputs.type.value as ManagedArtifactType; - await ctx.runtimeApi.uploadArtifacts({ - type: artifactType, + const artifact = { + type: inputs.type.value as ManagedArtifactType | GenericArtifactType, paths: [filePath], logger: stepsCtx.logger, - }); + key: inputs.key.value as string, + }; + + if (!isGenericArtifact(artifact)) { + await ctx.runtimeApi.uploadArtifacts({ + type: inputs.type.value as ManagedArtifactType, + paths: [filePath], + logger: stepsCtx.logger, + }); + return; + } + + await ctx.runtimeApi.uploadArtifacts(artifact); }, }); } diff --git a/packages/eas-build-job/src/artifacts.ts b/packages/eas-build-job/src/artifacts.ts index c93f8fa89..add7eb6b5 100644 --- a/packages/eas-build-job/src/artifacts.ts +++ b/packages/eas-build-job/src/artifacts.ts @@ -6,3 +6,27 @@ export enum ManagedArtifactType { */ XCODE_BUILD_LOGS = 'XCODE_BUILD_LOGS', } + +// TODO: Consider adding dev-client artifacts. Or should dev clients live in user space? +export enum GenericArtifactType { + ANDROID_APK = 'android-apk', + ANDROID_AAB = 'android-aab', + + IOS_SIMULATOR_APP = 'ios-simulator-app', + // TODO: Consider splitting into specific: internal-ipa and app-store-ipa. + // Should the "internal / app store" split live in user space? + IOS_IPA = 'ios-ipa', + + UNKNOWN = 'unknown', +} + +export const isGenericArtifact = < + TSpec extends { type: GenericArtifactType | ManagedArtifactType } +>( + artifactSpec: TSpec +): artifactSpec is TSpec & { type: GenericArtifactType } => { + if (Object.values(GenericArtifactType).includes(artifactSpec.type as GenericArtifactType)) { + return true; + } + return false; +}; diff --git a/packages/local-build-plugin/src/android.ts b/packages/local-build-plugin/src/android.ts index f7c964b31..bcdb16b0a 100644 --- a/packages/local-build-plugin/src/android.ts +++ b/packages/local-build-plugin/src/android.ts @@ -25,6 +25,7 @@ export async function buildAndroidAsync( logBuffer, runGlobalExpoCliCommand: runGlobalExpoCliCommandAsync, uploadArtifacts: async (artifact: ArtifactToUpload) => { + // TODO: Support GenericArtifactTypes if (artifact.type !== ManagedArtifactType.APPLICATION_ARCHIVE) { return null; } else { diff --git a/packages/local-build-plugin/src/ios.ts b/packages/local-build-plugin/src/ios.ts index 7aa767a8b..0f5b39545 100644 --- a/packages/local-build-plugin/src/ios.ts +++ b/packages/local-build-plugin/src/ios.ts @@ -25,6 +25,7 @@ export async function buildIosAsync( logBuffer, runGlobalExpoCliCommand: runGlobalExpoCliCommandAsync, uploadArtifacts: async ({ type, paths, logger }: ArtifactToUpload) => { + // TODO: Support GenericArtifactTypes if (type !== ManagedArtifactType.APPLICATION_ARCHIVE) { return null; } else {