Updating changes from remote. Adding compiled .js files to git.

This commit is contained in:
Drew Heavner
2020-10-09 14:12:33 +00:00
committed by GitHub
5 changed files with 112 additions and 5 deletions

View File

@@ -26,7 +26,7 @@ The service account json in plain text, provided via a secret, etc.
**Required:** The track in which you want to assign the uploaded app.
**Default:** `production`
_Values:_ `alpha`, `beta`, `internal`, `production`
_Values:_ `alpha`, `beta`, `internal`, `production`, `internalsharing`
### `userFraction`
@@ -54,6 +54,16 @@ where `whatsNewDirectory` is the path you pass to the action.
The mapping.txt file used to de-obfuscate your stack traces from crash reports
## Outputs
### `internalSharingDownloadUrl`
The download url for an app that was uploaded using the `track` `internalsharing`
### ENV VAR: `INTERNAL_SHARING_DOWNLOAD_URL`
The environment variable that is set when using the `track` `internalsharing`
## Example usage
```yaml
@@ -64,6 +74,6 @@ with:
releaseFile: ${{ SIGNED_RELEASE_FILE}}
track: beta
userFraction: 0.33
whatsNewDirectory: /distribution/whatsnew
mappingFile: /app/build/outputs/mapping/release/mapping.txt
whatsNewDirectory: distribution/whatsnew
mappingFile: app/build/outputs/mapping/release/mapping.txt
```

View File

@@ -30,6 +30,9 @@ inputs:
mappingFile:
description: 'The mapping.txt file used to de-obfuscate your stack traces from crash reports'
required: false
outputs:
internalSharingDownloadUrl:
description: "The internal app sharing download url if track was 'internalsharing'"
runs:
using: 'node12'
main: 'lib/main.js'

View File

@@ -24,6 +24,21 @@ const whatsnew_1 = require("./whatsnew");
const androidPublisher = googleapis_1.google.androidpublisher('v3');
function uploadRelease(options, releaseFile) {
return __awaiter(this, void 0, void 0, function* () {
// 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");
if (releaseFile.endsWith('.apk')) {
const res = yield internalSharingUploadApk(options, releaseFile);
return Promise.resolve(res.downloadUrl);
}
else if (releaseFile.endsWith('.aab')) {
const res = yield internalSharingUploadBundle(options, releaseFile);
return Promise.resolve(res.downloadUrl);
}
else {
return Promise.reject(`Unrecognized Release File`);
}
}
const appEdit = yield androidPublisher.edits.insert({
auth: options.auth,
packageName: options.applicationId
@@ -122,6 +137,34 @@ function uploadMappingFile(appEdit, versionCode, options) {
}
});
}
function internalSharingUploadApk(options, apkReleaseFile) {
return __awaiter(this, void 0, void 0, function* () {
core.debug(`[packageName=${options.applicationId}]: Uploading Internal Sharing APK @ ${apkReleaseFile}`);
const res = yield androidPublisher.internalappsharingartifacts.uploadapk({
auth: options.auth,
packageName: options.applicationId,
media: {
mimeType: 'application/vnd.android.package-archive',
body: fs.createReadStream(apkReleaseFile)
}
});
return res.data;
});
}
function internalSharingUploadBundle(options, bundleReleaseFile) {
return __awaiter(this, void 0, void 0, function* () {
core.debug(`[packageName=${options.applicationId}]: Uploading Internal Sharing Bundle @ ${bundleReleaseFile}`);
const res = yield androidPublisher.internalappsharingartifacts.uploadbundle({
auth: options.auth,
packageName: options.applicationId,
media: {
mimeType: 'application/octet-stream',
body: fs.createReadStream(bundleReleaseFile)
}
});
return res.data;
});
}
function uploadApk(appEdit, options, apkReleaseFile) {
return __awaiter(this, void 0, void 0, function* () {
core.debug(`[${appEdit.id}, packageName=${options.applicationId}]: Uploading APK @ ${apkReleaseFile}`);

View File

@@ -10,6 +10,7 @@ import AppEdit = androidpublisher_v3.Schema$AppEdit;
import Apk = androidpublisher_v3.Schema$Apk;
import Bundle = androidpublisher_v3.Schema$Bundle;
import Track = androidpublisher_v3.Schema$Track;
import InternalAppSharingArtifact = androidpublisher_v3.Schema$InternalAppSharingArtifact;
import {Compute} from "google-auth-library/build/src/auth/computeclient";
import {JWT} from "google-auth-library/build/src/auth/jwtclient";
import {UserRefreshClient} from "google-auth-library/build/src/auth/refreshclient";
@@ -26,7 +27,21 @@ export interface EditOptions {
mappingFile?: string;
}
export async function uploadRelease(options: EditOptions, releaseFile: string) {
export async function uploadRelease(options: EditOptions, releaseFile: string): Promise<string | undefined | null> {
// 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")
if (releaseFile.endsWith('.apk')) {
const res = await internalSharingUploadApk(options, releaseFile)
return Promise.resolve(res.downloadUrl)
} else if (releaseFile.endsWith('.aab')) {
const res = await internalSharingUploadBundle(options, releaseFile)
return Promise.resolve(res.downloadUrl)
} else {
return Promise.reject(`Unrecognized Release File`)
}
}
const appEdit = await androidPublisher.edits.insert({
auth: options.auth,
packageName: options.applicationId
@@ -125,8 +140,39 @@ async function uploadMappingFile(appEdit: AppEdit, versionCode: number, options:
}
}
async function internalSharingUploadApk(options: EditOptions, apkReleaseFile: string): Promise<InternalAppSharingArtifact> {
core.debug(`[packageName=${options.applicationId}]: Uploading Internal Sharing APK @ ${apkReleaseFile}`);
const res = await androidPublisher.internalappsharingartifacts.uploadapk({
auth: options.auth,
packageName: options.applicationId,
media: {
mimeType: 'application/vnd.android.package-archive',
body: fs.createReadStream(apkReleaseFile)
}
});
return res.data;
}
async function internalSharingUploadBundle(options: EditOptions, bundleReleaseFile: string): Promise<InternalAppSharingArtifact> {
core.debug(`[packageName=${options.applicationId}]: Uploading Internal Sharing Bundle @ ${bundleReleaseFile}`);
const res = await androidPublisher.internalappsharingartifacts.uploadbundle({
auth: options.auth,
packageName: options.applicationId,
media: {
mimeType: 'application/octet-stream',
body: fs.createReadStream(bundleReleaseFile)
}
});
return res.data;
}
async function uploadApk(appEdit: AppEdit, options: EditOptions, apkReleaseFile: string): Promise<Apk> {
core.debug(`[${appEdit.id}, packageName=${options.applicationId}]: Uploading APK @ ${apkReleaseFile}`);
const res = await androidPublisher.edits.apks.upload({
auth: options.auth,
packageName: options.applicationId,

View File

@@ -69,7 +69,7 @@ async function run() {
const authClient = await auth.getClient();
await uploadRelease({
const downloadUrl = await uploadRelease({
auth: authClient,
applicationId: packageName,
track: track,
@@ -78,6 +78,11 @@ async function run() {
mappingFile: mappingFile
}, releaseFile);
if (downloadUrl) {
core.setOutput('internalSharingDownloadUrl', downloadUrl);
core.exportVariable('INTERNAL_SHARING_DOWNLOAD_URL', downloadUrl);
}
console.log(`Finished uploading ${releaseFile} to the Play Store`)
} catch (error) {
core.setFailed(error.message)