Initial multi artifact work
Supports multiple artifact inputs, separated by "|". Multiple mapping files need support, and uploading internal sharing artifacts also needs work
This commit is contained in:
committed by
Jack Boswell
parent
8b7f712de4
commit
cea1728d1b
48
src/edits.ts
48
src/edits.ts
@@ -27,19 +27,21 @@ export interface EditOptions {
|
||||
mappingFile?: string;
|
||||
}
|
||||
|
||||
export async function uploadRelease(options: EditOptions, releaseFile: string): Promise<string | undefined | null> {
|
||||
export async function uploadRelease(options: EditOptions, releaseFiles: string[]): Promise<string | undefined | null> {
|
||||
// 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,
|
||||
|
||||
18
src/main.ts
18
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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user