From 373fb32d65d42937228bd043057033c26701d575 Mon Sep 17 00:00:00 2001 From: "Jack Boswell (boswelja)" Date: Tue, 1 Dec 2020 17:53:30 +1300 Subject: [PATCH] Output published release name on success --- lib/edits.js | 13 ++++++++++++- lib/main.js | 2 +- lib/whatsnew.js | 2 +- src/edits.ts | 10 ++++++++++ 4 files changed, 24 insertions(+), 3 deletions(-) diff --git a/lib/edits.js b/lib/edits.js index be7d3c10..6e181f2c 100644 --- a/lib/edits.js +++ b/lib/edits.js @@ -14,7 +14,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? ( var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; @@ -80,6 +80,7 @@ function uploadToPlayStore(options, releaseFiles) { // Simple check to see whether commit was successful if (res.data.id != null) { core.debug(`Successfully committed ${res.data.id}`); + core.setOutput("releaseName", getPublishedReleaseName(res.data, options)); return Promise.resolve(res.data.id); } else { @@ -249,3 +250,13 @@ 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({ + 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; + }); +} diff --git a/lib/main.js b/lib/main.js index 449be056..44999d2d 100644 --- a/lib/main.js +++ b/lib/main.js @@ -14,7 +14,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? ( var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; diff --git a/lib/whatsnew.js b/lib/whatsnew.js index 75954d92..5bfc4378 100644 --- a/lib/whatsnew.js +++ b/lib/whatsnew.js @@ -14,7 +14,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? ( var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; diff --git a/src/edits.ts b/src/edits.ts index 0c0fe652..e311bf40 100644 --- a/src/edits.ts +++ b/src/edits.ts @@ -77,6 +77,7 @@ export async function uploadToPlayStore(options: EditOptions, releaseFiles: stri // Simple check to see whether commit was successful if (res.data.id != null) { core.debug(`Successfully committed ${res.data.id}`); + core.setOutput("releaseName", getPublishedReleaseName(res.data, options)) return Promise.resolve(res.data.id!); } else { core.setFailed(`Error ${res.status}: ${res.statusText}`); @@ -238,3 +239,12 @@ async function uploadBundle(appEdit: AppEdit, options: EditOptions, bundleReleas return res.data } + +async function getPublishedReleaseName(appEdit: AppEdit, options: EditOptions): Promise { + const track = await androidPublisher.edits.tracks.get({ + 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 +} \ No newline at end of file