Add releases to the edit track correctly

This commit is contained in:
Jack Boswell (boswelja)
2020-10-23 16:00:18 +13:00
parent f5c3d22549
commit 87accbcd41
2 changed files with 23 additions and 23 deletions

View File

@@ -41,13 +41,16 @@ function uploadToPlayStore(options, releaseFiles) {
auth: options.auth,
packageName: options.applicationId
});
var versionCodes = new Array();
releaseFiles.forEach((releaseFile) => __awaiter(this, void 0, void 0, function* () {
core.debug(`Uploading ${releaseFile}`);
yield uploadRelease(appEdit.data, options, releaseFile).catch(reason => {
const versionCode = yield uploadRelease(appEdit.data, options, releaseFile).catch(reason => {
core.setFailed(reason);
return Promise.reject(reason);
});
versionCodes.push(versionCode);
}));
const track = trackVersionCode(appEdit.data, options, versionCodes);
const res = yield androidPublisher.edits.commit({
auth: options.auth,
editId: appEdit.data.id,
@@ -72,12 +75,12 @@ function uploadRelease(appEdit, options, releaseFile) {
if (releaseFile.endsWith('.apk')) {
const res = yield internalSharingUploadApk(options, releaseFile);
console.log(`${releaseFile} uploaded to Internal Sharing, download it with ${res.downloadUrl}`);
return Promise.resolve(res.downloadUrl);
return Promise.resolve(undefined);
}
else if (releaseFile.endsWith('.aab')) {
const res = yield internalSharingUploadBundle(options, releaseFile);
console.log(`${releaseFile} uploaded to Internal Sharing, download it with ${res.downloadUrl}`);
return Promise.resolve(res.downloadUrl);
return Promise.resolve(undefined);
}
else {
core.setFailed(`${releaseFile} is invalid`);
@@ -89,16 +92,15 @@ function uploadRelease(appEdit, options, releaseFile) {
core.setFailed(`Track "${options.track}" could not be found `);
return Promise.reject(`No track found for "${options.track}"`);
}
let track = undefined;
if (releaseFile.endsWith('.apk')) {
const apk = yield uploadApk(appEdit, options, releaseFile);
yield uploadMappingFile(appEdit, apk.versionCode, options);
track = yield trackVersionCode(appEdit, options, apk.versionCode);
return Promise.resolve(apk.versionCode);
}
else if (releaseFile.endsWith('.aab')) {
const bundle = yield uploadBundle(appEdit, options, releaseFile);
yield uploadMappingFile(appEdit, bundle.versionCode, options);
track = yield trackVersionCode(appEdit, options, bundle.versionCode);
return Promise.resolve(bundle.versionCode);
}
else {
core.setFailed(`${releaseFile} is invalid`);
@@ -116,7 +118,7 @@ function getAllTracks(appEdit, options) {
return res.data.tracks;
});
}
function trackVersionCode(appEdit, options, versionCode) {
function trackVersionCode(appEdit, options, versionCodes) {
return __awaiter(this, void 0, void 0, function* () {
let status;
if (options.userFraction != undefined) {
@@ -125,7 +127,7 @@ function trackVersionCode(appEdit, options, versionCode) {
else {
status = 'completed';
}
core.debug(`Creating Track Release for Edit(${appEdit.id}) for Track(${options.track}) with a UserFraction(${options.userFraction}) and VersionCode(${versionCode})`);
core.debug(`Creating Track Release for Edit(${appEdit.id}) for Track(${options.track}) with a UserFraction(${options.userFraction}) and VersionCodes(${versionCodes})`);
const res = yield androidPublisher.edits.tracks
.update({
auth: options.auth,
@@ -139,9 +141,7 @@ function trackVersionCode(appEdit, options, versionCode) {
userFraction: options.userFraction,
status: status,
releaseNotes: yield whatsnew_1.readLocalizedReleaseNotes(options.whatsNewDir),
versionCodes: [
versionCode.toString()
]
versionCodes: versionCodes.map(x => x.toString())
}
]
}