From cea1728d1bb68b08df70877923413876656ff361 Mon Sep 17 00:00:00 2001 From: "Jack Boswell (boswelja)" Date: Mon, 19 Oct 2020 18:16:43 +1300 Subject: [PATCH] Initial multi artifact work Supports multiple artifact inputs, separated by "|". Multiple mapping files need support, and uploading internal sharing artifacts also needs work --- src/edits.ts | 48 ++++++++++++++++++++++++++---------------------- src/main.ts | 18 ++++++++++-------- 2 files changed, 36 insertions(+), 30 deletions(-) diff --git a/src/edits.ts b/src/edits.ts index 7513e447..29864034 100644 --- a/src/edits.ts +++ b/src/edits.ts @@ -27,19 +27,21 @@ export interface EditOptions { mappingFile?: string; } -export async function uploadRelease(options: EditOptions, releaseFile: string): Promise { +export async function uploadRelease(options: EditOptions, releaseFiles: string[]): Promise { // Check the 'track' for 'internalsharing', if so switch to a non-track api if (options.track === 'internalsharing'){ core.debug("Track is Internal app sharing, switch to special upload api") - if (releaseFile.endsWith('.apk')) { - const res = await internalSharingUploadApk(options, releaseFile) - return Promise.resolve(res.downloadUrl) - } else if (releaseFile.endsWith('.aab')) { - const res = await internalSharingUploadBundle(options, releaseFile) - return Promise.resolve(res.downloadUrl) - } else { - return Promise.reject(`Unrecognized Release File`) - } + releaseFiles.forEach(async releaseFile => { + // if (releaseFile.endsWith('.apk')) { + // const res = await internalSharingUploadApk(options, releaseFile) + // return Promise.resolve(res.downloadUrl) + // } else if (releaseFile.endsWith('.aab')) { + // const res = await internalSharingUploadBundle(options, releaseFile) + // return Promise.resolve(res.downloadUrl) + // } else { + // return Promise.reject(`Unrecognized Release File`) + // } + }) } const appEdit = await androidPublisher.edits.insert({ @@ -54,18 +56,20 @@ export async function uploadRelease(options: EditOptions, releaseFile: string): } let track: Track | undefined = undefined; - if (releaseFile.endsWith('.apk')) { - const apk = await uploadApk(appEdit.data, options, releaseFile); - await uploadMappingFile(appEdit.data, apk.versionCode!, options); - track = await trackVersionCode(appEdit.data, options, apk.versionCode!) - } else if (releaseFile.endsWith('.aab')) { - const bundle = await uploadBundle(appEdit.data, options, releaseFile); - await uploadMappingFile(appEdit.data, bundle.versionCode!, options); - track = await trackVersionCode(appEdit.data, options, bundle.versionCode!) - } else { - return Promise.reject("Invalid release file") - } - + releaseFiles.forEach(async releaseFile => { + if (releaseFile.endsWith('.apk')) { + const apk = await uploadApk(appEdit.data, options, releaseFile); + await uploadMappingFile(appEdit.data, apk.versionCode!, options); + track = await trackVersionCode(appEdit.data, options, apk.versionCode!) + } else if (releaseFile.endsWith('.aab')) { + const bundle = await uploadBundle(appEdit.data, options, releaseFile); + await uploadMappingFile(appEdit.data, bundle.versionCode!, options); + track = await trackVersionCode(appEdit.data, options, bundle.versionCode!) + } else { + return Promise.reject("Invalid release file") + } + }) + if (track != undefined) { const res = await androidPublisher.edits.commit({ auth: options.auth, diff --git a/src/main.ts b/src/main.ts index 6cb36b13..25237bfd 100644 --- a/src/main.ts +++ b/src/main.ts @@ -12,7 +12,7 @@ async function run() { const serviceAccountJson = core.getInput('serviceAccountJson', { required: false }); const serviceAccountJsonRaw = core.getInput('serviceAccountJsonPlainText', { required: false}); const packageName = core.getInput('packageName', { required: true }); - const releaseFile = core.getInput('releaseFile', { required: true }); + const releaseFiles = core.getInput('releaseFile', { required: true }).split("|").filter(x => x !== ""); const track = core.getInput('track', { required: true }); const userFraction = core.getInput('userFraction', { required: false }); const whatsNewDir = core.getInput('whatsNewDirectory', { required: false }); @@ -51,11 +51,13 @@ async function run() { userFractionFloat = undefined } - // Check release file - if (!fs.existsSync(releaseFile)) { - core.setFailed(`Unable to find release file @ ${releaseFile}`); - return - } + // Check release files + releaseFiles.forEach(releaseFile => { + if (!fs.existsSync(releaseFile)) { + core.setFailed(`Unable to find release file @ ${releaseFile}`); + return + } + }); if (whatsNewDir != undefined && whatsNewDir.length > 0 && !fs.existsSync(whatsNewDir)) { core.setFailed(`Unable to find 'whatsnew' directory @ ${whatsNewDir}`); @@ -76,14 +78,14 @@ async function run() { userFraction: userFractionFloat, whatsNewDir: whatsNewDir, mappingFile: mappingFile - }, releaseFile); + }, releaseFiles); if (downloadUrl) { core.setOutput('internalSharingDownloadUrl', downloadUrl); core.exportVariable('INTERNAL_SHARING_DOWNLOAD_URL', downloadUrl); } - console.log(`Finished uploading ${releaseFile} to the Play Store`) + console.log(`Finished uploading to the Play Store`) } catch (error) { core.setFailed(error.message) }