Comment code a bit

This commit is contained in:
Jack Boswell (boswelja)
2020-11-04 21:33:08 +13:00
parent edfaa9c57a
commit e219a80fab
3 changed files with 16 additions and 7 deletions

View File

@@ -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);

View File

@@ -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) {

View File

@@ -28,6 +28,7 @@ export interface EditOptions {
}
export async function uploadToPlayStore(options: EditOptions, releaseFiles: string[]): Promise<string | undefined> {
// 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<number>();
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!);