16 Commits

Author SHA1 Message Date
Drew Heavner
ba5abd87ce Merge pull request #54 from boswelja/master
Remove releaseName from outputs
2021-01-06 08:58:17 -05:00
Jack Boswell (boswelja)
d4681f654d Remove releaseName from outputs in readme 2021-01-01 16:43:34 +13:00
Jack Boswell (boswelja)
bda8b09ade Remove outputting generated release name
Seems like Google doesn't expose this before edits are committed.
2021-01-01 16:42:39 +13:00
Drew Heavner
ca061d798d Merge pull request #53 from lriccardo/master
Add internal sharing download url to outputs and env
2020-12-30 15:29:09 -05:00
Riccardo Lattarulo
21e00b9d69 Update documentation to address the addition of multiple urls as output for internal sharing 2020-12-29 17:39:10 +01:00
Riccardo Lattarulo
e9a4446395 Add multiple urls to internal sharing outputs 2020-12-23 10:16:35 +01:00
Riccardo Lattarulo
b06f374506 Add internal sharing download url to output 2020-12-22 16:57:37 +01:00
Drew Heavner
84d17e8c1c Merge pull request #50 from boswelja/add-console-output
Add some output for the user to read while the action is running
2020-12-16 10:23:49 -05:00
Jack Boswell (boswelja)
40448bb1bb Add some output for the user to read while the action is running 2020-12-12 18:38:17 +13:00
Drew Heavner
2f949adc6e 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.
2020-12-10 11:36:45 -05:00
Drew Heavner
f9a7fda708 Bumped version for release
Adjusted 'packageName' order in params to be consistent
2020-12-09 14:11:55 -05:00
Drew Heavner
05570869bd Merge pull request #47 from xom9ikk/master
Add missing params
2020-12-09 14:10:53 -05:00
Max Romanyuta
aa45a3257f Merge branch 'patch-1' 2020-12-09 18:41:30 +02:00
Max Romanyuta
fc490c3965 Add auth 2020-12-09 18:41:12 +02:00
Max Romanyuta
d5d1fde18f Merge branch 'patch-1' 2020-12-09 18:30:30 +02:00
Max Romanyuta
df30106c36 Add missing params 2020-12-09 18:29:00 +02:00
7 changed files with 60 additions and 45 deletions

View File

@@ -72,13 +72,17 @@ The mapping.txt file used to de-obfuscate your stack traces from crash reports
## Outputs
### `releaseName`
### `internalSharingDownloadUrls`
The name of the release published to Google Play, which is generated on commit by default
A JSON list containing the download urls for every release file uploaded using the `track` `internalsharing`
### ENV VAR: `INTERNAL_SHARING_DOWNLOAD_URLS`
The environment variable that is set when using the `track` `internalsharing`
### `internalSharingDownloadUrl`
The download url for an app that was uploaded using the `track` `internalsharing`
The download url for the last release file uploaded using the `track` `internalsharing`, useful when a single release file is uploaded
### ENV VAR: `INTERNAL_SHARING_DOWNLOAD_URL`

View File

@@ -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;
};
@@ -40,38 +40,51 @@ function uploadToPlayStore(options, releaseFiles) {
// Check the 'track' for 'internalsharing', if so switch to a non-track api
if (options.track === 'internalsharing') {
core.debug("Track is Internal app sharing, switch to special upload api");
let downloadUrls = [];
for (const releaseFile of releaseFiles) {
core.debug(`Uploading ${releaseFile}`);
yield uploadInternalSharingRelease(options, releaseFile).catch(reason => {
yield uploadInternalSharingRelease(options, releaseFile)
.then(downloadUrl => {
downloadUrls.push(downloadUrl);
})
.catch(reason => {
core.setFailed(reason);
return Promise.reject(reason);
});
}
core.setOutput("internalSharingDownloadUrls", downloadUrls);
core.exportVariable("INTERNAL_SHARING_DOWNLOAD_URLS", downloadUrls);
}
else {
// Create a new Edit
core.info(`Creating a new Edit for this release`);
const appEdit = yield androidPublisher.edits.insert({
auth: options.auth,
packageName: options.applicationId
});
// Validate the given track
core.info(`Validating track '${options.track}'`);
yield validateSelectedTrack(appEdit.data, options).catch(reason => {
core.setFailed(reason);
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}`);
core.info(`Uploading ${releaseFile}`);
const versionCode = yield uploadRelease(appEdit.data, options, releaseFile).catch(reason => {
core.setFailed(reason);
return Promise.reject(reason);
});
versionCodes.push(versionCode);
}
core.info(`Successfully uploaded ${versionCodes.length} artifacts`);
// Add the uploaded artifacts to the Edit track
core.info(`Adding ${versionCodes.length} artifacts to release on '${options.track}' track`);
const track = yield addReleasesToTrack(appEdit.data, options, versionCodes);
core.debug(`Track: ${track}`);
// Commit the pending Edit
core.info(`Committing the Edit`);
const res = yield androidPublisher.edits.commit({
auth: options.auth,
editId: appEdit.data.id,
@@ -79,9 +92,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}`);
const name = options.name || (yield getPublishedReleaseName(res.data, options));
core.setOutput("releaseName", name);
core.info(`Successfully committed ${res.data.id}`);
return Promise.resolve(res.data.id);
}
else {
@@ -96,11 +107,15 @@ function uploadInternalSharingRelease(options, releaseFile) {
return __awaiter(this, void 0, void 0, function* () {
if (releaseFile.endsWith('.apk')) {
const res = yield internalSharingUploadApk(options, releaseFile);
core.setOutput("internalSharingDownloadUrl", res.downloadUrl);
core.exportVariable("INTERNAL_SHARING_DOWNLOAD_URL", res.downloadUrl);
console.log(`${releaseFile} uploaded to Internal Sharing, download it with ${res.downloadUrl}`);
return Promise.resolve(res.downloadUrl);
}
else if (releaseFile.endsWith('.aab')) {
const res = yield internalSharingUploadBundle(options, releaseFile);
core.setOutput("internalSharingDownloadUrl", res.downloadUrl);
core.exportVariable("INTERNAL_SHARING_DOWNLOAD_URL", res.downloadUrl);
console.log(`${releaseFile} uploaded to Internal Sharing, download it with ${res.downloadUrl}`);
return Promise.resolve(res.downloadUrl);
}
@@ -251,13 +266,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;
});
}

View File

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

View File

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

View File

@@ -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",

View File

@@ -33,41 +33,54 @@ export async function uploadToPlayStore(options: EditOptions, releaseFiles: stri
// Check the 'track' for 'internalsharing', if so switch to a non-track api
if (options.track === 'internalsharing') {
core.debug("Track is Internal app sharing, switch to special upload api")
let downloadUrls: string[] = []
for (const releaseFile of releaseFiles) {
core.debug(`Uploading ${releaseFile}`);
await uploadInternalSharingRelease(options, releaseFile).catch(reason => {
core.setFailed(reason);
return Promise.reject(reason);
});
await uploadInternalSharingRelease(options, releaseFile)
.then(downloadUrl => {
downloadUrls.push(downloadUrl as string)
})
.catch(reason => {
core.setFailed(reason);
return Promise.reject(reason);
});
}
core.setOutput("internalSharingDownloadUrls", downloadUrls);
core.exportVariable("INTERNAL_SHARING_DOWNLOAD_URLS", downloadUrls);
} else {
// Create a new Edit
core.info(`Creating a new Edit for this release`)
const appEdit = await androidPublisher.edits.insert({
auth: options.auth,
packageName: options.applicationId
});
// Validate the given track
core.info(`Validating track '${options.track}'`)
await validateSelectedTrack(appEdit.data, options).catch(reason => {
core.setFailed(reason);
return Promise.reject(reason);
});
// 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}`);
core.info(`Uploading ${releaseFile}`);
const versionCode = await uploadRelease(appEdit.data, options, releaseFile).catch(reason => {
core.setFailed(reason);
return Promise.reject(reason);
});
versionCodes.push(versionCode!);
}
core.info(`Successfully uploaded ${versionCodes.length} artifacts`)
// Add the uploaded artifacts to the Edit track
core.info(`Adding ${versionCodes.length} artifacts to release on '${options.track}' track`)
const track = await addReleasesToTrack(appEdit.data, options, versionCodes);
core.debug(`Track: ${track}`);
// Commit the pending Edit
core.info(`Committing the Edit`)
const res = await androidPublisher.edits.commit({
auth: options.auth,
editId: appEdit.data.id!,
@@ -76,9 +89,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}`);
const name = options.name || (await getPublishedReleaseName(res.data, options));
core.setOutput("releaseName", name)
core.info(`Successfully committed ${res.data.id}`);
return Promise.resolve(res.data.id!);
} else {
core.setFailed(`Error ${res.status}: ${res.statusText}`);
@@ -90,10 +101,14 @@ export async function uploadToPlayStore(options: EditOptions, releaseFiles: stri
async function uploadInternalSharingRelease(options: EditOptions, releaseFile: string): Promise<string | undefined | null> {
if (releaseFile.endsWith('.apk')) {
const res = await internalSharingUploadApk(options, releaseFile)
core.setOutput("internalSharingDownloadUrl", res.downloadUrl);
core.exportVariable("INTERNAL_SHARING_DOWNLOAD_URL", res.downloadUrl);
console.log(`${releaseFile} uploaded to Internal Sharing, download it with ${res.downloadUrl}`)
return Promise.resolve(res.downloadUrl)
} else if (releaseFile.endsWith('.aab')) {
const res = await internalSharingUploadBundle(options, releaseFile)
core.setOutput("internalSharingDownloadUrl", res.downloadUrl);
core.exportVariable("INTERNAL_SHARING_DOWNLOAD_URL", res.downloadUrl);
console.log(`${releaseFile} uploaded to Internal Sharing, download it with ${res.downloadUrl}`)
return Promise.resolve(res.downloadUrl)
} else {
@@ -239,13 +254,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
}

View File

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