8 Commits

Author SHA1 Message Date
Drew Heavner
b6496ac4e3 Fixed precondition checks for whatsnew and mapping files, to fix issues outlined in #2 2019-12-12 08:50:26 -05:00
Drew Heavner
3e0a7f808c 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
2019-12-11 23:40:19 -05:00
Drew Heavner
3fe51cca76 Fixing workflow 2019-12-04 10:34:36 -05:00
Drew Heavner
50592d62ad Fixing workflow 2019-12-04 10:32:05 -05:00
Drew Heavner
db7def7467 Fixing workflow 2019-12-04 10:30:37 -05:00
Drew Heavner
fc9e3b4597 Pruned node modules
tweaking workflow
2019-12-04 10:28:59 -05:00
Drew Heavner
c328f3aa5c Tweaking workflow 2019-12-04 10:16:22 -05:00
Drew Heavner
575e057922 Tweaking workflow 2019-12-04 10:14:12 -05:00
10 changed files with 114 additions and 42 deletions

View File

@@ -11,14 +11,8 @@ jobs:
steps: steps:
- uses: actions/checkout@v1 - uses: actions/checkout@v1
- name: Build Action
run: |
npm ci
npm run build
- name: Update v1 Tag - name: Update v1 Tag
run: | uses: hole19/git-tag-action@master
npm prune --production env:
git commit -m "Pruning Node Modules, Preparing for release" TAG: v1
git tag -fa v1 -m "Update v1 tag" GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
git push origin --force --tags

View File

@@ -20,10 +20,13 @@ inputs:
required: true required: true
userFraction: userFraction:
description: 'Portion of users who should get the staged version of the app. Accepts values between 0.0 and 1.0 (exclusive-exclusive).' description: 'Portion of users who should get the staged version of the app. Accepts values between 0.0 and 1.0 (exclusive-exclusive).'
required: false
whatsNewDirectory: whatsNewDirectory:
description: 'The directory of localized whats new files' description: 'The directory of localized whats new files'
required: false
mappingFile: mappingFile:
description: 'The mapping.txt file used to de-obfuscate your stack traces from crash reports' description: 'The mapping.txt file used to de-obfuscate your stack traces from crash reports'
required: false
runs: runs:
using: 'node12' using: 'node12'
main: 'lib/main.js' main: 'lib/main.js'

View File

@@ -26,6 +26,11 @@ function uploadRelease(options, releaseFile) {
auth: options.auth, auth: options.auth,
packageName: options.applicationId packageName: options.applicationId
}); });
const allTracks = yield 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 = undefined; let track = undefined;
if (releaseFile.endsWith('.apk')) { if (releaseFile.endsWith('.apk')) {
const apk = yield uploadApk(appEdit.data, options, releaseFile); const apk = yield uploadApk(appEdit.data, options, releaseFile);
@@ -51,6 +56,16 @@ function uploadRelease(options, releaseFile) {
}); });
} }
exports.uploadRelease = uploadRelease; exports.uploadRelease = uploadRelease;
function getAllTracks(appEdit, options) {
return __awaiter(this, void 0, void 0, function* () {
const res = yield androidPublisher.edits.tracks.list({
auth: options.auth,
editId: appEdit.id,
packageName: options.applicationId
});
return res.data.tracks;
});
}
function trackVersionCode(appEdit, options, versionCode) { function trackVersionCode(appEdit, options, versionCode) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
let status; let status;
@@ -85,7 +100,7 @@ function trackVersionCode(appEdit, options, versionCode) {
} }
function readLocalizedReleaseNotes(whatsNewDir) { function readLocalizedReleaseNotes(whatsNewDir) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
if (whatsNewDir != undefined) { if (whatsNewDir != undefined && whatsNewDir.length > 0) {
const releaseNotes = fs.readdirSync(whatsNewDir).filter(value => /whatsnew-*-*/.test(value)); const releaseNotes = fs.readdirSync(whatsNewDir).filter(value => /whatsnew-*-*/.test(value));
const pattern = /whatsnew-(?<local>.*-.*)/.compile(); const pattern = /whatsnew-(?<local>.*-.*)/.compile();
let localizedReleaseNotes = []; let localizedReleaseNotes = [];
@@ -110,7 +125,7 @@ function readLocalizedReleaseNotes(whatsNewDir) {
} }
function uploadMappingFile(appEdit, versionCode, options) { function uploadMappingFile(appEdit, versionCode, options) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
if (options.mappingFile != undefined) { if (options.mappingFile != undefined && options.mappingFile.length > 0) {
const mapping = fs_1.readFileSync(options.mappingFile, 'utf-8'); const mapping = fs_1.readFileSync(options.mappingFile, 'utf-8');
if (mapping != undefined) { if (mapping != undefined) {
core.debug(`[${appEdit.id}, versionCode=${versionCode}, packageName=${options.applicationId}]: Uploading Proguard mapping file @ ${options.mappingFile}`); core.debug(`[${appEdit.id}, versionCode=${versionCode}, packageName=${options.applicationId}]: Uploading Proguard mapping file @ ${options.mappingFile}`);

View File

@@ -16,6 +16,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
}; };
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
const core = __importStar(require("@actions/core")); const core = __importStar(require("@actions/core"));
const fs = __importStar(require("fs"));
const edits_1 = require("./edits"); const edits_1 = require("./edits");
const { google } = require('googleapis'); const { google } = require('googleapis');
const auth = new google.auth.GoogleAuth({ const auth = new google.auth.GoogleAuth({
@@ -42,6 +43,19 @@ function run() {
else { else {
userFractionFloat = undefined; userFractionFloat = undefined;
} }
// Check release file
if (!fs.existsSync(releaseFile)) {
core.setFailed(`Unable to find release file @ ${releaseFile}`);
return;
}
if (whatsNewDir != undefined && whatsNewDir.length > 0 && !fs.existsSync(whatsNewDir)) {
core.setFailed(`Unable to find 'whatsnew' directory @ ${whatsNewDir}`);
return;
}
if (mappingFile != undefined && mappingFile.length > 0 && !fs.existsSync(mappingFile)) {
core.setFailed(`Unable to find 'mappingFile' @ ${mappingFile}`);
return;
}
// Insure that the api can find our service account credentials // Insure that the api can find our service account credentials
core.exportVariable("GOOGLE_APPLICATION_CREDENTIALS", serviceAccountJson); core.exportVariable("GOOGLE_APPLICATION_CREDENTIALS", serviceAccountJson);
const authClient = yield auth.getClient(); const authClient = yield auth.getClient();
@@ -53,7 +67,7 @@ function run() {
whatsNewDir: whatsNewDir, whatsNewDir: whatsNewDir,
mappingFile: mappingFile mappingFile: mappingFile
}, releaseFile); }, releaseFile);
core.debug('Finished App Release!'); console.log(`Finished uploading ${releaseFile} to the Play Store`);
} }
catch (error) { catch (error) {
core.setFailed(error.message); core.setFailed(error.message);

25
node_modules/commander/package.json generated vendored
View File

@@ -1,27 +1,34 @@
{ {
"_from": "commander@~2.20.3", "_args": [
[
"commander@2.20.3",
"/Users/drew.heavner/Documents/Github/upload-google-play"
]
],
"_development": true,
"_from": "commander@2.20.3",
"_id": "commander@2.20.3", "_id": "commander@2.20.3",
"_inBundle": false, "_inBundle": false,
"_integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", "_integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==",
"_location": "/commander", "_location": "/commander",
"_optional": true,
"_phantomChildren": {}, "_phantomChildren": {},
"_requested": { "_requested": {
"type": "range", "type": "version",
"registry": true, "registry": true,
"raw": "commander@~2.20.3", "raw": "commander@2.20.3",
"name": "commander", "name": "commander",
"escapedName": "commander", "escapedName": "commander",
"rawSpec": "~2.20.3", "rawSpec": "2.20.3",
"saveSpec": null, "saveSpec": null,
"fetchSpec": "~2.20.3" "fetchSpec": "2.20.3"
}, },
"_requiredBy": [ "_requiredBy": [
"/uglify-js" "/uglify-js"
], ],
"_resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", "_resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz",
"_shasum": "fd485e84c03eb4881c20722ba48035e8531aeb33", "_spec": "2.20.3",
"_spec": "commander@~2.20.3", "_where": "/Users/drew.heavner/Documents/Github/upload-google-play",
"_where": "/Users/drew.heavner/Documents/Github/upload-google-play/node_modules/uglify-js",
"author": { "author": {
"name": "TJ Holowaychuk", "name": "TJ Holowaychuk",
"email": "tj@vision-media.ca" "email": "tj@vision-media.ca"
@@ -29,9 +36,7 @@
"bugs": { "bugs": {
"url": "https://github.com/tj/commander.js/issues" "url": "https://github.com/tj/commander.js/issues"
}, },
"bundleDependencies": false,
"dependencies": {}, "dependencies": {},
"deprecated": false,
"description": "the complete solution for node.js command-line programs", "description": "the complete solution for node.js command-line programs",
"devDependencies": { "devDependencies": {
"@types/node": "^12.7.8", "@types/node": "^12.7.8",

14
node_modules/handlebars/package.json generated vendored
View File

@@ -1,4 +1,11 @@
{ {
"_args": [
[
"handlebars@4.5.3",
"/Users/drew.heavner/Documents/Github/upload-google-play"
]
],
"_development": true,
"_from": "handlebars@4.5.3", "_from": "handlebars@4.5.3",
"_id": "handlebars@4.5.3", "_id": "handlebars@4.5.3",
"_inBundle": false, "_inBundle": false,
@@ -19,9 +26,8 @@
"/istanbul-reports" "/istanbul-reports"
], ],
"_resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.5.3.tgz", "_resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.5.3.tgz",
"_shasum": "5cf75bd8714f7605713511a56be7c349becb0482", "_spec": "4.5.3",
"_spec": "handlebars@4.5.3", "_where": "/Users/drew.heavner/Documents/Github/upload-google-play",
"_where": "/Users/drew.heavner/Documents/Github/upload-google-play/node_modules/istanbul-reports",
"author": { "author": {
"name": "Yehuda Katz" "name": "Yehuda Katz"
}, },
@@ -36,14 +42,12 @@
"bugs": { "bugs": {
"url": "https://github.com/wycats/handlebars.js/issues" "url": "https://github.com/wycats/handlebars.js/issues"
}, },
"bundleDependencies": false,
"dependencies": { "dependencies": {
"neo-async": "^2.6.0", "neo-async": "^2.6.0",
"optimist": "^0.6.1", "optimist": "^0.6.1",
"source-map": "^0.6.1", "source-map": "^0.6.1",
"uglify-js": "^3.1.4" "uglify-js": "^3.1.4"
}, },
"deprecated": false,
"description": "Handlebars provides the power necessary to let you build semantic templates effectively with no frustration", "description": "Handlebars provides the power necessary to let you build semantic templates effectively with no frustration",
"devDependencies": { "devDependencies": {
"@knappi/grunt-saucelabs": "^9.0.2", "@knappi/grunt-saucelabs": "^9.0.2",

25
node_modules/uglify-js/package.json generated vendored
View File

@@ -1,27 +1,34 @@
{ {
"_from": "uglify-js@^3.1.4", "_args": [
[
"uglify-js@3.7.1",
"/Users/drew.heavner/Documents/Github/upload-google-play"
]
],
"_development": true,
"_from": "uglify-js@3.7.1",
"_id": "uglify-js@3.7.1", "_id": "uglify-js@3.7.1",
"_inBundle": false, "_inBundle": false,
"_integrity": "sha512-pnOF7jY82wdIhATVn87uUY/FHU+MDUdPLkmGFvGoclQmeu229eTkbG5gjGGBi3R7UuYYSEeYXY/TTY5j2aym2g==", "_integrity": "sha512-pnOF7jY82wdIhATVn87uUY/FHU+MDUdPLkmGFvGoclQmeu229eTkbG5gjGGBi3R7UuYYSEeYXY/TTY5j2aym2g==",
"_location": "/uglify-js", "_location": "/uglify-js",
"_optional": true,
"_phantomChildren": {}, "_phantomChildren": {},
"_requested": { "_requested": {
"type": "range", "type": "version",
"registry": true, "registry": true,
"raw": "uglify-js@^3.1.4", "raw": "uglify-js@3.7.1",
"name": "uglify-js", "name": "uglify-js",
"escapedName": "uglify-js", "escapedName": "uglify-js",
"rawSpec": "^3.1.4", "rawSpec": "3.7.1",
"saveSpec": null, "saveSpec": null,
"fetchSpec": "^3.1.4" "fetchSpec": "3.7.1"
}, },
"_requiredBy": [ "_requiredBy": [
"/handlebars" "/handlebars"
], ],
"_resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.7.1.tgz", "_resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.7.1.tgz",
"_shasum": "35c7de17971a4aa7689cd2eae0a5b39bb838c0c5", "_spec": "3.7.1",
"_spec": "uglify-js@^3.1.4", "_where": "/Users/drew.heavner/Documents/Github/upload-google-play",
"_where": "/Users/drew.heavner/Documents/Github/upload-google-play/node_modules/handlebars",
"author": { "author": {
"name": "Mihai Bazon", "name": "Mihai Bazon",
"email": "mihai.bazon@gmail.com", "email": "mihai.bazon@gmail.com",
@@ -33,12 +40,10 @@
"bugs": { "bugs": {
"url": "https://github.com/mishoo/UglifyJS2/issues" "url": "https://github.com/mishoo/UglifyJS2/issues"
}, },
"bundleDependencies": false,
"dependencies": { "dependencies": {
"commander": "~2.20.3", "commander": "~2.20.3",
"source-map": "~0.6.1" "source-map": "~0.6.1"
}, },
"deprecated": false,
"description": "JavaScript parser, mangler/compressor and beautifier toolkit", "description": "JavaScript parser, mangler/compressor and beautifier toolkit",
"devDependencies": { "devDependencies": {
"acorn": "~7.1.0", "acorn": "~7.1.0",

View File

@@ -1,6 +1,6 @@
{ {
"name": "upload-google-play", "name": "upload-google-play",
"version": "1.0.0", "version": "1.0.2",
"private": true, "private": true,
"description": "Upload an Android release (.apk or .aab) to Google Play Console", "description": "Upload an Android release (.apk or .aab) to Google Play Console",
"main": "lib/main.js", "main": "lib/main.js",

View File

@@ -33,6 +33,12 @@ export async function uploadRelease(options: EditOptions, releaseFile: string) {
packageName: options.applicationId 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; let track: Track | undefined = undefined;
if (releaseFile.endsWith('.apk')) { if (releaseFile.endsWith('.apk')) {
const apk = await uploadApk(appEdit.data, options, releaseFile); 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> { async function trackVersionCode(appEdit: AppEdit, options: EditOptions, versionCode: number): Promise<Track> {
let status: string; let status: string;
@@ -91,7 +106,7 @@ async function trackVersionCode(appEdit: AppEdit, options: EditOptions, versionC
} }
async function readLocalizedReleaseNotes(whatsNewDir: string | undefined): Promise<LocalizedText[] | undefined> { async function readLocalizedReleaseNotes(whatsNewDir: string | undefined): Promise<LocalizedText[] | undefined> {
if (whatsNewDir != undefined) { if (whatsNewDir != undefined && whatsNewDir.length > 0) {
const releaseNotes = fs.readdirSync(whatsNewDir).filter(value => /whatsnew-*-*/.test(value)); const releaseNotes = fs.readdirSync(whatsNewDir).filter(value => /whatsnew-*-*/.test(value));
const pattern = /whatsnew-(?<local>.*-.*)/.compile(); const pattern = /whatsnew-(?<local>.*-.*)/.compile();
@@ -121,7 +136,7 @@ async function readLocalizedReleaseNotes(whatsNewDir: string | undefined): Promi
} }
async function uploadMappingFile(appEdit: AppEdit, versionCode: number, options: EditOptions) { async function uploadMappingFile(appEdit: AppEdit, versionCode: number, options: EditOptions) {
if (options.mappingFile != undefined) { if (options.mappingFile != undefined && options.mappingFile.length > 0) {
const mapping = readFileSync(options.mappingFile, 'utf-8'); const mapping = readFileSync(options.mappingFile, 'utf-8');
if (mapping != undefined) { if (mapping != undefined) {
core.debug(`[${appEdit.id}, versionCode=${versionCode}, packageName=${options.applicationId}]: Uploading Proguard mapping file @ ${options.mappingFile}`); core.debug(`[${appEdit.id}, versionCode=${versionCode}, packageName=${options.applicationId}]: Uploading Proguard mapping file @ ${options.mappingFile}`);

View File

@@ -1,4 +1,5 @@
import * as core from '@actions/core'; import * as core from '@actions/core';
import * as fs from "fs";
import {uploadRelease} from "./edits"; import {uploadRelease} from "./edits";
const {google} = require('googleapis'); const {google} = require('googleapis');
@@ -27,6 +28,22 @@ async function run() {
userFractionFloat = undefined userFractionFloat = undefined
} }
// Check release file
if (!fs.existsSync(releaseFile)) {
core.setFailed(`Unable to find release file @ ${releaseFile}`);
return
}
if (whatsNewDir != undefined && whatsNewDir.length > 0 && !fs.existsSync(whatsNewDir)) {
core.setFailed(`Unable to find 'whatsnew' directory @ ${whatsNewDir}`);
return
}
if (mappingFile != undefined && mappingFile.length > 0 && !fs.existsSync(mappingFile)) {
core.setFailed(`Unable to find 'mappingFile' @ ${mappingFile}`);
return
}
// Insure that the api can find our service account credentials // Insure that the api can find our service account credentials
core.exportVariable("GOOGLE_APPLICATION_CREDENTIALS", serviceAccountJson); core.exportVariable("GOOGLE_APPLICATION_CREDENTIALS", serviceAccountJson);
@@ -41,7 +58,7 @@ async function run() {
mappingFile: mappingFile mappingFile: mappingFile
}, releaseFile); }, releaseFile);
core.debug('Finished App Release!') console.log(`Finished uploading ${releaseFile} to the Play Store`)
} catch (error) { } catch (error) {
core.setFailed(error.message) core.setFailed(error.message)
} }