2 Commits

Author SHA1 Message Date
Drew Heavner
290e6a13bf Fixed #5 - Added input for providing the text of the service account json to authorize the action 2020-02-12 10:55:53 -05:00
Drew Heavner
ec56d49b16 Update README.md 2020-01-30 11:53:11 -05:00
4 changed files with 69 additions and 13 deletions

View File

@@ -4,9 +4,15 @@ This action will help you upload an Android `.apk` or `.aab` (Android App Bundle
## Inputs
_You must provide one of either `serviceAccountJson` or `serviceAccountJsonPlainText`_
### `serviceAccountJson`
**Required:** The service account json private key file to authorize the upload request
The service account json private key file to authorize the upload request
### `serviceAccountJsonPlainText`
The service account json in plain text, provided via a secret, etc.
### `packageName`
@@ -28,11 +34,21 @@ Portion of users who should get the staged version of the app. Accepts values be
### `whatsNewDirectory`
The directory of localized whats new files to upload as the release notes. Using the pattern `whatsnew-<LOCALE>`
i.e. `whatsnew-en-US`. Where `LOCALE` is using the [`BCP 47`](https://tools.ietf.org/html/bcp47) format, for example:
The directory of localized whats new files to upload as the release notes. The files contained in the `whatsNewDirectory` MUST use the pattern `whatsnew-<LOCALE>` where `LOCALE` is using the [`BCP 47`](https://tools.ietf.org/html/bcp47) format, e.g.
* `en-US` - English/America
* `de-DE` - German/Germany
* `ja-JP` - Japanese/Japan
* `ja-JP` - Japanese/Japan
and contain plain `utf8` encoded text with no extension on the file. The resulting directory in your project should look something like this:
```
projectDir/
└── whatsNewDirectory/
├── whatsnew-en-US
├── whatsnew-de-DE
└── whatsnew-ja-JP
```
where `whatsNewDirectory` is the path you pass to the action.
### `mappingFile`
@@ -50,4 +66,4 @@ with:
userFraction: 0.33
whatsNewDirectory: /distribution/whatsnew
mappingFile: /app/build/outputs/mapping/release/mapping.txt
```
```

View File

@@ -7,7 +7,10 @@ branding:
inputs:
serviceAccountJson:
description: 'The service account json private key file to authorize the upload request'
required: true
required: false
serviceAccountJsonPlainText:
description: 'The raw json text of the service account private key to authorize the upload request'
required: false
packageName:
description: 'The package name, or Application Id, of the app you are uploading'
required: true

View File

@@ -26,13 +26,32 @@ const auth = new google.auth.GoogleAuth({
function run() {
return __awaiter(this, void 0, void 0, function* () {
try {
const serviceAccountJson = core.getInput('serviceAccountJson', { required: true });
const serviceAccountJson = core.getInput('serviceAccountJson', { required: false });
const serviceAccountJsonRaw = core.getInput('serviceAccountJsonPlainText', { required: false });
const packageName = core.getInput('packageName', { required: true });
const releaseFile = core.getInput('releaseFile', { required: true });
const track = core.getInput('track', { required: true });
const userFraction = core.getInput('userFraction', { required: false });
const whatsNewDir = core.getInput('whatsNewDirectory', { required: false });
const mappingFile = core.getInput('mappingFile', { required: false });
if (!serviceAccountJson && !serviceAccountJsonRaw) {
console.log("No service account json key provided!");
core.setFailed("You must provide one of 'serviceAccountJson' or 'serviceAccountJsonPlainText' to use this action");
}
// If the user has provided the raw plain text via secrets, or w/e, then write to file and
// set appropriate env variable for the auth
if (serviceAccountJsonRaw) {
const serviceAccountFile = "./serviceAccountJson.json";
fs.writeFileSync(serviceAccountFile, serviceAccountJsonRaw, {
encoding: 'utf8'
});
// Insure that the api can find our service account credentials
core.exportVariable("GOOGLE_APPLICATION_CREDENTIALS", serviceAccountFile);
}
if (serviceAccountJson) {
// Insure that the api can find our service account credentials
core.exportVariable("GOOGLE_APPLICATION_CREDENTIALS", serviceAccountJson);
}
// verify inputs
let userFractionFloat = parseFloat(userFraction);
if (!isNaN(userFractionFloat)) {
@@ -57,8 +76,6 @@ function run() {
core.setFailed(`Unable to find 'mappingFile' @ ${mappingFile}`);
return;
}
// Insure that the api can find our service account credentials
core.exportVariable("GOOGLE_APPLICATION_CREDENTIALS", serviceAccountJson);
const authClient = yield auth.getClient();
yield edits_1.uploadRelease({
auth: authClient,

View File

@@ -9,7 +9,8 @@ const auth = new google.auth.GoogleAuth({
async function run() {
try {
const serviceAccountJson = core.getInput('serviceAccountJson', { required: true });
const serviceAccountJson = core.getInput('serviceAccountJson', { required: false });
const serviceAccountJsonRaw = core.getInput('serviceAccountJsonPlainText', { required: false});
const packageName = core.getInput('packageName', { required: true });
const releaseFile = core.getInput('releaseFile', { required: true });
const track = core.getInput('track', { required: true });
@@ -17,6 +18,28 @@ async function run() {
const whatsNewDir = core.getInput('whatsNewDirectory', { required: false });
const mappingFile = core.getInput('mappingFile', { required: false });
if (!serviceAccountJson && !serviceAccountJsonRaw) {
console.log("No service account json key provided!");
core.setFailed("You must provide one of 'serviceAccountJson' or 'serviceAccountJsonPlainText' to use this action");
}
// If the user has provided the raw plain text via secrets, or w/e, then write to file and
// set appropriate env variable for the auth
if (serviceAccountJsonRaw) {
const serviceAccountFile = "./serviceAccountJson.json";
fs.writeFileSync(serviceAccountFile, serviceAccountJsonRaw, {
encoding: 'utf8'
});
// Insure that the api can find our service account credentials
core.exportVariable("GOOGLE_APPLICATION_CREDENTIALS", serviceAccountFile);
}
if (serviceAccountJson) {
// Insure that the api can find our service account credentials
core.exportVariable("GOOGLE_APPLICATION_CREDENTIALS", serviceAccountJson);
}
// verify inputs
let userFractionFloat: number | undefined = parseFloat(userFraction);
if (!isNaN(userFractionFloat)) {
@@ -44,9 +67,6 @@ async function run() {
return
}
// Insure that the api can find our service account credentials
core.exportVariable("GOOGLE_APPLICATION_CREDENTIALS", serviceAccountJson);
const authClient = await auth.getClient();
await uploadRelease({