Removed call to developer api to pull the releaseName for the edit and instead used result from actual update to the track.

Added more debug logging.
This commit is contained in:
Drew Heavner
2020-12-10 11:36:45 -05:00
parent f9a7fda708
commit 2f949adc6e
5 changed files with 37 additions and 34 deletions

View File

@@ -60,7 +60,7 @@ function uploadToPlayStore(options, releaseFiles) {
return Promise.reject(reason);
});
// Upload artifacts to Google Play, and store their version codes
var versionCodes = new Array();
const versionCodes = new Array();
for (const releaseFile of releaseFiles) {
core.debug(`Uploading ${releaseFile}`);
const versionCode = yield uploadRelease(appEdit.data, options, releaseFile).catch(reason => {
@@ -71,6 +71,14 @@ function uploadToPlayStore(options, releaseFiles) {
}
// Add the uploaded artifacts to the Edit track
const track = yield addReleasesToTrack(appEdit.data, options, versionCodes);
core.debug(`Track: ${track}`);
// Extract the release name for the response
let trackReleaseName;
if (track.releases && track.releases.length > 0) {
const trackRelease = track.releases[0];
trackReleaseName = trackRelease.name;
core.debug(`Pulled track release name from update: ${trackReleaseName}`);
}
// Commit the pending Edit
const res = yield androidPublisher.edits.commit({
auth: options.auth,
@@ -80,8 +88,13 @@ function uploadToPlayStore(options, releaseFiles) {
// Simple check to see whether commit was successful
if (res.data.id != null) {
core.debug(`Successfully committed ${res.data.id}`);
const name = options.name || (yield getPublishedReleaseName(res.data, options));
core.setOutput("releaseName", name);
const name = options.name || trackReleaseName;
if (name) {
core.setOutput("releaseName", name);
}
else {
core.debug("Unable to set 'releaseName' output.");
}
return Promise.resolve(res.data.id);
}
else {
@@ -251,15 +264,3 @@ function uploadBundle(appEdit, options, bundleReleaseFile) {
return res.data;
});
}
function getPublishedReleaseName(appEdit, options) {
return __awaiter(this, void 0, void 0, function* () {
const track = yield androidPublisher.edits.tracks.get({
auth: options.auth,
packageName: options.applicationId,
editId: appEdit.id,
track: options.track
});
const release = track.data.releases[0]; // We only ever create one release, so grab the first one
return release.name;
});
}

View File

@@ -128,7 +128,7 @@ function run() {
return;
}
const authClient = yield auth.getClient();
yield edits_1.uploadToPlayStore({
const result = yield edits_1.uploadToPlayStore({
auth: authClient,
applicationId: packageName,
track: track,
@@ -138,7 +138,7 @@ function run() {
mappingFile: mappingFile,
name: releaseName
}, validatedReleaseFiles);
console.log(`Finished uploading to the Play Store`);
console.log(`Finished uploading to the Play Store: ${result}`);
}
catch (error) {
core.setFailed(error.message);