From e219a80fabf89a7605698c9689bc7a1cecd962e0 Mon Sep 17 00:00:00 2001 From: "Jack Boswell (boswelja)" Date: Wed, 4 Nov 2020 21:33:08 +1300 Subject: [PATCH] Comment code a bit --- lib/edits.js | 8 +++++++- lib/main.js | 6 +----- src/edits.ts | 9 ++++++++- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/lib/edits.js b/lib/edits.js index eb907305..4c513f58 100644 --- a/lib/edits.js +++ b/lib/edits.js @@ -37,6 +37,7 @@ const whatsnew_1 = require("./whatsnew"); const androidPublisher = googleapis_1.google.androidpublisher('v3'); function uploadToPlayStore(options, releaseFiles) { return __awaiter(this, void 0, void 0, function* () { + // Check the 'track' for 'internalsharing', if so switch to a non-track api if (options.track === 'internalappsharing') { core.debug("Track is Internal app sharing, switch to special upload api"); releaseFiles.forEach((releaseFile) => __awaiter(this, void 0, void 0, function* () { @@ -48,15 +49,17 @@ function uploadToPlayStore(options, releaseFiles) { })); } else { + // Create a new Edit const appEdit = yield androidPublisher.edits.insert({ auth: options.auth, packageName: options.applicationId }); + // Validate the given track yield validateSelectedTrack(appEdit.data, options).catch(reason => { core.setFailed(reason); return Promise.reject(reason); }); - // Check the 'track' for 'internalsharing', if so switch to a non-track api + // Upload artifacts to Google Play, and store their version codes var versionCodes = new Array(); releaseFiles.forEach((releaseFile) => __awaiter(this, void 0, void 0, function* () { core.debug(`Uploading ${releaseFile}`); @@ -66,12 +69,15 @@ function uploadToPlayStore(options, releaseFiles) { }); versionCodes.push(versionCode); })); + // Add the uploaded artifacts to the Edit track const track = addReleasesToTrack(appEdit.data, options, versionCodes); + // Commit the pending Edit const res = yield androidPublisher.edits.commit({ auth: options.auth, editId: appEdit.data.id, packageName: options.applicationId }); + // Simple check to see whether commit was successful if (res.data.id != null) { core.debug(`Successfully committed ${res.data.id}`); return Promise.resolve(res.data.id); diff --git a/lib/main.js b/lib/main.js index 4b0a2759..1ab7a519 100644 --- a/lib/main.js +++ b/lib/main.js @@ -91,7 +91,7 @@ function run() { return; } const authClient = yield auth.getClient(); - const downloadUrl = yield edits_1.uploadToPlayStore({ + yield edits_1.uploadToPlayStore({ auth: authClient, applicationId: packageName, track: track, @@ -99,10 +99,6 @@ function run() { whatsNewDir: whatsNewDir, mappingFile: mappingFile }, releaseFiles); - if (downloadUrl) { - core.setOutput('internalSharingDownloadUrl', downloadUrl); - core.exportVariable('INTERNAL_SHARING_DOWNLOAD_URL', downloadUrl); - } console.log(`Finished uploading to the Play Store`); } catch (error) { diff --git a/src/edits.ts b/src/edits.ts index d517c92c..5f57ecfd 100644 --- a/src/edits.ts +++ b/src/edits.ts @@ -28,6 +28,7 @@ export interface EditOptions { } export async function uploadToPlayStore(options: EditOptions, releaseFiles: string[]): Promise { + // Check the 'track' for 'internalsharing', if so switch to a non-track api if (options.track === 'internalappsharing') { core.debug("Track is Internal app sharing, switch to special upload api") releaseFiles.forEach(async releaseFile => { @@ -38,17 +39,19 @@ export async function uploadToPlayStore(options: EditOptions, releaseFiles: stri }); }); } else { + // Create a new Edit const appEdit = await androidPublisher.edits.insert({ auth: options.auth, packageName: options.applicationId }); + // Validate the given track await validateSelectedTrack(appEdit.data, options).catch(reason => { core.setFailed(reason); return Promise.reject(reason); }); - // Check the 'track' for 'internalsharing', if so switch to a non-track api + // Upload artifacts to Google Play, and store their version codes var versionCodes = new Array(); releaseFiles.forEach(async releaseFile => { core.debug(`Uploading ${releaseFile}`); @@ -59,13 +62,17 @@ export async function uploadToPlayStore(options: EditOptions, releaseFiles: stri versionCodes.push(versionCode!); }); + // Add the uploaded artifacts to the Edit track const track = addReleasesToTrack(appEdit.data, options, versionCodes); + + // Commit the pending Edit const res = await androidPublisher.edits.commit({ auth: options.auth, editId: appEdit.data.id!, packageName: options.applicationId }); + // Simple check to see whether commit was successful if (res.data.id != null) { core.debug(`Successfully committed ${res.data.id}`); return Promise.resolve(res.data.id!);