Added checks to make sure the specified track exists
Added precondition checks to validate input files and paths to return more informative error messages as per #2
This commit is contained in:
15
src/edits.ts
15
src/edits.ts
@@ -33,6 +33,12 @@ export async function uploadRelease(options: EditOptions, releaseFile: string) {
|
||||
packageName: options.applicationId
|
||||
});
|
||||
|
||||
const allTracks = await getAllTracks(appEdit.data!, options);
|
||||
if (allTracks == undefined || allTracks.find(value => value.track == options.track) == undefined) {
|
||||
core.setFailed(`Track "${options.track}" could not be found `)
|
||||
return Promise.reject(`No track found for "${options.track}"`)
|
||||
}
|
||||
|
||||
let track: Track | undefined = undefined;
|
||||
if (releaseFile.endsWith('.apk')) {
|
||||
const apk = await uploadApk(appEdit.data, options, releaseFile);
|
||||
@@ -57,6 +63,15 @@ export async function uploadRelease(options: EditOptions, releaseFile: string) {
|
||||
}
|
||||
}
|
||||
|
||||
async function getAllTracks(appEdit: AppEdit, options: EditOptions): Promise<Track[] | undefined> {
|
||||
const res = await androidPublisher.edits.tracks.list({
|
||||
auth: options.auth,
|
||||
editId: appEdit.id!,
|
||||
packageName: options.applicationId
|
||||
});
|
||||
|
||||
return res.data.tracks
|
||||
}
|
||||
|
||||
async function trackVersionCode(appEdit: AppEdit, options: EditOptions, versionCode: number): Promise<Track> {
|
||||
let status: string;
|
||||
|
||||
17
src/main.ts
17
src/main.ts
@@ -1,4 +1,5 @@
|
||||
import * as core from '@actions/core';
|
||||
import * as fs from "fs";
|
||||
import {uploadRelease} from "./edits";
|
||||
const {google} = require('googleapis');
|
||||
|
||||
@@ -27,6 +28,22 @@ async function run() {
|
||||
userFractionFloat = undefined
|
||||
}
|
||||
|
||||
// Check release file
|
||||
if (!fs.existsSync(releaseFile)) {
|
||||
core.setFailed(`Unable to find release file @ ${releaseFile}`);
|
||||
return
|
||||
}
|
||||
|
||||
if (whatsNewDir != undefined && !fs.existsSync(whatsNewDir)) {
|
||||
core.setFailed(`Unable to find 'whatsnew' directory @ ${whatsNewDir}`);
|
||||
return
|
||||
}
|
||||
|
||||
if (mappingFile != undefined && !fs.existsSync(mappingFile)) {
|
||||
core.setFailed(`Unable to find 'mappingFile' @ ${mappingFile}`);
|
||||
return
|
||||
}
|
||||
|
||||
// Insure that the api can find our service account credentials
|
||||
core.exportVariable("GOOGLE_APPLICATION_CREDENTIALS", serviceAccountJson);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user