Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2f949adc6e | ||
|
|
f9a7fda708 | ||
|
|
05570869bd | ||
|
|
aa45a3257f | ||
|
|
fc490c3965 | ||
|
|
d5d1fde18f | ||
|
|
df30106c36 |
31
lib/edits.js
31
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.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
@@ -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,13 +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({
|
||||
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;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
@@ -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);
|
||||
|
||||
@@ -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.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "upload-google-play",
|
||||
"version": "1.0.6",
|
||||
"version": "1.0.10",
|
||||
"private": true,
|
||||
"description": "Upload an Android release (.apk or .aab) to Google Play Console",
|
||||
"main": "lib/main.js",
|
||||
|
||||
28
src/edits.ts
28
src/edits.ts
@@ -54,7 +54,7 @@ export async function uploadToPlayStore(options: EditOptions, releaseFiles: stri
|
||||
});
|
||||
|
||||
// Upload artifacts to Google Play, and store their version codes
|
||||
var versionCodes = new Array<number>();
|
||||
const versionCodes = new Array<number>();
|
||||
for (const releaseFile of releaseFiles) {
|
||||
core.debug(`Uploading ${releaseFile}`);
|
||||
const versionCode = await uploadRelease(appEdit.data, options, releaseFile).catch(reason => {
|
||||
@@ -66,6 +66,15 @@ export async function uploadToPlayStore(options: EditOptions, releaseFiles: stri
|
||||
|
||||
// Add the uploaded artifacts to the Edit track
|
||||
const track = await addReleasesToTrack(appEdit.data, options, versionCodes);
|
||||
core.debug(`Track: ${track}`);
|
||||
|
||||
// Extract the release name for the response
|
||||
let trackReleaseName: string | undefined | null;
|
||||
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 = await androidPublisher.edits.commit({
|
||||
@@ -77,8 +86,12 @@ 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}`);
|
||||
const name = options.name || (await 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 {
|
||||
core.setFailed(`Error ${res.status}: ${res.statusText}`);
|
||||
@@ -239,13 +252,4 @@ async function uploadBundle(appEdit: AppEdit, options: EditOptions, bundleReleas
|
||||
});
|
||||
|
||||
return res.data
|
||||
}
|
||||
|
||||
async function getPublishedReleaseName(appEdit: AppEdit, options: EditOptions): Promise<String | null | undefined> {
|
||||
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
|
||||
}
|
||||
@@ -106,7 +106,7 @@ async function run() {
|
||||
|
||||
const authClient = await auth.getClient();
|
||||
|
||||
await uploadToPlayStore({
|
||||
const result = await uploadToPlayStore({
|
||||
auth: authClient,
|
||||
applicationId: packageName,
|
||||
track: track,
|
||||
@@ -117,7 +117,7 @@ async function run() {
|
||||
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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user