From 8b7f712de445d9d7f03a6229e37be1eeebaacd04 Mon Sep 17 00:00:00 2001 From: "Jack Boswell (boswelja)" Date: Mon, 19 Oct 2020 17:57:06 +1300 Subject: [PATCH 01/26] npm install --- node_modules/node-fetch/CHANGELOG.md | 6 +++ node_modules/node-fetch/README.md | 53 ++++++++++++++----------- node_modules/node-fetch/browser.js | 4 +- node_modules/node-fetch/lib/index.es.js | 11 ++++- node_modules/node-fetch/lib/index.js | 11 ++++- node_modules/node-fetch/lib/index.mjs | 11 ++++- node_modules/node-fetch/package.json | 31 ++++++++------- 7 files changed, 83 insertions(+), 44 deletions(-) diff --git a/node_modules/node-fetch/CHANGELOG.md b/node_modules/node-fetch/CHANGELOG.md index 188fcd39..543d3d94 100644 --- a/node_modules/node-fetch/CHANGELOG.md +++ b/node_modules/node-fetch/CHANGELOG.md @@ -5,6 +5,12 @@ Changelog # 2.x release +## v2.6.1 + +**This is an important security release. It is strongly recommended to update as soon as possible.** + +- Fix: honor the `size` option after following a redirect. + ## v2.6.0 - Enhance: `options.agent`, it now accepts a function that returns custom http(s).Agent instance based on current URL, see readme for more information. diff --git a/node_modules/node-fetch/README.md b/node_modules/node-fetch/README.md index cb199012..2dde7428 100644 --- a/node_modules/node-fetch/README.md +++ b/node_modules/node-fetch/README.md @@ -5,11 +5,14 @@ node-fetch [![build status][travis-image]][travis-url] [![coverage status][codecov-image]][codecov-url] [![install size][install-size-image]][install-size-url] +[![Discord][discord-image]][discord-url] A light-weight module that brings `window.fetch` to Node.js (We are looking for [v2 maintainers and collaborators](https://github.com/bitinn/node-fetch/issues/567)) +[![Backers][opencollective-image]][opencollective-url] + - [Motivation](#motivation) @@ -48,7 +51,7 @@ A light-weight module that brings `window.fetch` to Node.js ## Motivation -Instead of implementing `XMLHttpRequest` in Node.js to run browser-specific [Fetch polyfill](https://github.com/github/fetch), why not go from native `http` to `fetch` API directly? Hence `node-fetch`, minimal code for a `window.fetch` compatible API on Node.js runtime. +Instead of implementing `XMLHttpRequest` in Node.js to run browser-specific [Fetch polyfill](https://github.com/github/fetch), why not go from native `http` to `fetch` API directly? Hence, `node-fetch`, minimal code for a `window.fetch` compatible API on Node.js runtime. See Matt Andrews' [isomorphic-fetch](https://github.com/matthew-andrews/isomorphic-fetch) or Leonardo Quixada's [cross-fetch](https://github.com/lquixada/cross-fetch) for isomorphic usage (exports `node-fetch` for server-side, `whatwg-fetch` for client-side). @@ -56,9 +59,9 @@ See Matt Andrews' [isomorphic-fetch](https://github.com/matthew-andrews/isomorph - Stay consistent with `window.fetch` API. - Make conscious trade-off when following [WHATWG fetch spec][whatwg-fetch] and [stream spec](https://streams.spec.whatwg.org/) implementation details, document known differences. -- Use native promise, but allow substituting it with [insert your favorite promise library]. -- Use native Node streams for body, on both request and response. -- Decode content encoding (gzip/deflate) properly, and convert string output (such as `res.text()` and `res.json()`) to UTF-8 automatically. +- Use native promise but allow substituting it with [insert your favorite promise library]. +- Use native Node streams for body on both request and response. +- Decode content encoding (gzip/deflate) properly and convert string output (such as `res.text()` and `res.json()`) to UTF-8 automatically. - Useful extensions such as timeout, redirect limit, response size limit, [explicit errors](ERROR-HANDLING.md) for troubleshooting. ## Difference from client-side fetch @@ -72,16 +75,16 @@ See Matt Andrews' [isomorphic-fetch](https://github.com/matthew-andrews/isomorph Current stable release (`2.x`) ```sh -$ npm install node-fetch --save +$ npm install node-fetch ``` ## Loading and configuring the module -We suggest you load the module via `require`, pending the stabalizing of es modules in node: +We suggest you load the module via `require` until the stabilization of ES modules in node: ```js const fetch = require('node-fetch'); ``` -If you are using a Promise library other than native, set it through fetch.Promise: +If you are using a Promise library other than native, set it through `fetch.Promise`: ```js const Bluebird = require('bluebird'); @@ -90,7 +93,7 @@ fetch.Promise = Bluebird; ## Common Usage -NOTE: The documentation below is up-to-date with `2.x` releases, [see `1.x` readme](https://github.com/bitinn/node-fetch/blob/1.x/README.md), [changelog](https://github.com/bitinn/node-fetch/blob/1.x/CHANGELOG.md) and [2.x upgrade guide](UPGRADE-GUIDE.md) for the differences. +NOTE: The documentation below is up-to-date with `2.x` releases; see the [`1.x` readme](https://github.com/bitinn/node-fetch/blob/1.x/README.md), [changelog](https://github.com/bitinn/node-fetch/blob/1.x/CHANGELOG.md) and [2.x upgrade guide](UPGRADE-GUIDE.md) for the differences. #### Plain text or HTML ```js @@ -146,9 +149,9 @@ fetch('https://httpbin.org/post', { method: 'POST', body: params }) ``` #### Handling exceptions -NOTE: 3xx-5xx responses are *NOT* exceptions, and should be handled in `then()`, see the next section. +NOTE: 3xx-5xx responses are *NOT* exceptions and should be handled in `then()`; see the next section for more information. -Adding a catch to the fetch promise chain will catch *all* exceptions, such as errors originating from node core libraries, like network errors, and operational errors which are instances of FetchError. See the [error handling document](ERROR-HANDLING.md) for more details. +Adding a catch to the fetch promise chain will catch *all* exceptions, such as errors originating from node core libraries, network errors and operational errors, which are instances of FetchError. See the [error handling document](ERROR-HANDLING.md) for more details. ```js fetch('https://domain.invalid/') @@ -186,7 +189,7 @@ fetch('https://assets-cdn.github.com/images/modules/logos_page/Octocat.png') ``` #### Buffer -If you prefer to cache binary data in full, use buffer(). (NOTE: buffer() is a `node-fetch` only API) +If you prefer to cache binary data in full, use buffer(). (NOTE: `buffer()` is a `node-fetch`-only API) ```js const fileType = require('file-type'); @@ -211,7 +214,7 @@ fetch('https://github.com/') #### Extract Set-Cookie Header -Unlike browsers, you can access raw `Set-Cookie` headers manually using `Headers.raw()`, this is a `node-fetch` only API. +Unlike browsers, you can access raw `Set-Cookie` headers manually using `Headers.raw()`. This is a `node-fetch` only API. ```js fetch(url).then(res => { @@ -263,11 +266,11 @@ fetch('https://httpbin.org/post', options) #### Request cancellation with AbortSignal -> NOTE: You may only cancel streamed requests on Node >= v8.0.0 +> NOTE: You may cancel streamed requests only on Node >= v8.0.0 You may cancel requests with `AbortController`. A suggested implementation is [`abort-controller`](https://www.npmjs.com/package/abort-controller). -An example of timing out a request after 150ms could be achieved as follows: +An example of timing out a request after 150ms could be achieved as the following: ```js import AbortController from 'abort-controller'; @@ -308,7 +311,7 @@ See [test cases](https://github.com/bitinn/node-fetch/blob/master/test/test.js) Perform an HTTP(S) fetch. -`url` should be an absolute url, such as `https://example.com/`. A path-relative URL (`/file/under/root`) or protocol-relative URL (`//can-be-http-or-https.com/`) will result in a rejected promise. +`url` should be an absolute url, such as `https://example.com/`. A path-relative URL (`/file/under/root`) or protocol-relative URL (`//can-be-http-or-https.com/`) will result in a rejected `Promise`. ### Options @@ -350,7 +353,7 @@ Note: when `body` is a `Stream`, `Content-Length` is not set automatically. ##### Custom Agent -The `agent` option allows you to specify networking related options that's out of the scope of Fetch. Including and not limit to: +The `agent` option allows you to specify networking related options which are out of the scope of Fetch, including and not limited to the following: - Support self-signed certificate - Use only IPv4 or IPv6 @@ -358,7 +361,7 @@ The `agent` option allows you to specify networking related options that's out o See [`http.Agent`](https://nodejs.org/api/http.html#http_new_agent_options) for more information. -In addition, `agent` option accepts a function that returns http(s).Agent instance given current [URL](https://nodejs.org/api/url.html), this is useful during a redirection chain across HTTP and HTTPS protocol. +In addition, the `agent` option accepts a function that returns `http`(s)`.Agent` instance given current [URL](https://nodejs.org/api/url.html), this is useful during a redirection chain across HTTP and HTTPS protocol. ```js const httpAgent = new http.Agent({ @@ -432,7 +435,7 @@ The following properties are not implemented in node-fetch at this moment: *(spec-compliant)* -- `body` A string or [Readable stream][node-readable] +- `body` A `String` or [`Readable` stream][node-readable] - `options` A [`ResponseInit`][response-init] options dictionary Constructs a new `Response` object. The constructor is identical to that in the [browser](https://developer.mozilla.org/en-US/docs/Web/API/Response/Response). @@ -462,7 +465,7 @@ This class allows manipulating and iterating over a set of HTTP headers. All met - `init` Optional argument to pre-fill the `Headers` object -Construct a new `Headers` object. `init` can be either `null`, a `Headers` object, an key-value map object, or any iterable object. +Construct a new `Headers` object. `init` can be either `null`, a `Headers` object, an key-value map object or any iterable object. ```js // Example adapted from https://fetch.spec.whatwg.org/#example-headers-class @@ -503,7 +506,7 @@ The following methods are not yet implemented in node-fetch at this moment: * Node.js [`Readable` stream][node-readable] -The data encapsulated in the `Body` object. Note that while the [Fetch Standard][whatwg-fetch] requires the property to always be a WHATWG `ReadableStream`, in node-fetch it is a Node.js [`Readable` stream][node-readable]. +Data are encapsulated in the `Body` object. Note that while the [Fetch Standard][whatwg-fetch] requires the property to always be a WHATWG `ReadableStream`, in node-fetch it is a Node.js [`Readable` stream][node-readable]. #### body.bodyUsed @@ -511,7 +514,7 @@ The data encapsulated in the `Body` object. Note that while the [Fetch Standard] * `Boolean` -A boolean property for if this body has been consumed. Per spec, a consumed body cannot be used again. +A boolean property for if this body has been consumed. Per the specs, a consumed body cannot be used again. #### body.arrayBuffer() #### body.blob() @@ -538,9 +541,9 @@ Consume the body and return a promise that will resolve to a Buffer. * Returns: Promise<String> -Identical to `body.text()`, except instead of always converting to UTF-8, encoding sniffing will be performed and text converted to UTF-8, if possible. +Identical to `body.text()`, except instead of always converting to UTF-8, encoding sniffing will be performed and text converted to UTF-8 if possible. -(This API requires an optional dependency on npm package [encoding](https://www.npmjs.com/package/encoding), which you need to install manually. `webpack` users may see [a warning message](https://github.com/bitinn/node-fetch/issues/412#issuecomment-379007792) due to this optional dependency.) +(This API requires an optional dependency of the npm package [encoding](https://www.npmjs.com/package/encoding), which you need to install manually. `webpack` users may see [a warning message](https://github.com/bitinn/node-fetch/issues/412#issuecomment-379007792) due to this optional dependency.) ### Class: FetchError @@ -574,6 +577,10 @@ MIT [codecov-url]: https://codecov.io/gh/bitinn/node-fetch [install-size-image]: https://flat.badgen.net/packagephobia/install/node-fetch [install-size-url]: https://packagephobia.now.sh/result?p=node-fetch +[discord-image]: https://img.shields.io/discord/619915844268326952?color=%237289DA&label=Discord&style=flat-square +[discord-url]: https://discord.gg/Zxbndcm +[opencollective-image]: https://opencollective.com/node-fetch/backers.svg +[opencollective-url]: https://opencollective.com/node-fetch [whatwg-fetch]: https://fetch.spec.whatwg.org/ [response-init]: https://fetch.spec.whatwg.org/#responseinit [node-readable]: https://nodejs.org/api/stream.html#stream_readable_streams diff --git a/node_modules/node-fetch/browser.js b/node_modules/node-fetch/browser.js index 0ad5de00..83c54c58 100644 --- a/node_modules/node-fetch/browser.js +++ b/node_modules/node-fetch/browser.js @@ -16,7 +16,9 @@ var global = getGlobal(); module.exports = exports = global.fetch; // Needed for TypeScript and Webpack. -exports.default = global.fetch.bind(global); +if (global.fetch) { + exports.default = global.fetch.bind(global); +} exports.Headers = global.Headers; exports.Request = global.Request; diff --git a/node_modules/node-fetch/lib/index.es.js b/node_modules/node-fetch/lib/index.es.js index 37d022c9..61906c95 100644 --- a/node_modules/node-fetch/lib/index.es.js +++ b/node_modules/node-fetch/lib/index.es.js @@ -461,6 +461,12 @@ function convertBody(buffer, headers) { // html4 if (!res && str) { res = / Date: Mon, 19 Oct 2020 18:16:43 +1300 Subject: [PATCH 02/26] Initial multi artifact work Supports multiple artifact inputs, separated by "|". Multiple mapping files need support, and uploading internal sharing artifacts also needs work --- src/edits.ts | 48 ++++++++++++++++++++++++++---------------------- src/main.ts | 18 ++++++++++-------- 2 files changed, 36 insertions(+), 30 deletions(-) diff --git a/src/edits.ts b/src/edits.ts index 7513e447..29864034 100644 --- a/src/edits.ts +++ b/src/edits.ts @@ -27,19 +27,21 @@ export interface EditOptions { mappingFile?: string; } -export async function uploadRelease(options: EditOptions, releaseFile: string): Promise { +export async function uploadRelease(options: EditOptions, releaseFiles: string[]): Promise { // 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`) - } + releaseFiles.forEach(async releaseFile => { + // 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({ @@ -54,18 +56,20 @@ export async function uploadRelease(options: EditOptions, releaseFile: string): } let track: Track | undefined = undefined; - if (releaseFile.endsWith('.apk')) { - const apk = await uploadApk(appEdit.data, options, releaseFile); - await uploadMappingFile(appEdit.data, apk.versionCode!, options); - track = await trackVersionCode(appEdit.data, options, apk.versionCode!) - } else if (releaseFile.endsWith('.aab')) { - const bundle = await uploadBundle(appEdit.data, options, releaseFile); - await uploadMappingFile(appEdit.data, bundle.versionCode!, options); - track = await trackVersionCode(appEdit.data, options, bundle.versionCode!) - } else { - return Promise.reject("Invalid release file") - } - + releaseFiles.forEach(async releaseFile => { + if (releaseFile.endsWith('.apk')) { + const apk = await uploadApk(appEdit.data, options, releaseFile); + await uploadMappingFile(appEdit.data, apk.versionCode!, options); + track = await trackVersionCode(appEdit.data, options, apk.versionCode!) + } else if (releaseFile.endsWith('.aab')) { + const bundle = await uploadBundle(appEdit.data, options, releaseFile); + await uploadMappingFile(appEdit.data, bundle.versionCode!, options); + track = await trackVersionCode(appEdit.data, options, bundle.versionCode!) + } else { + return Promise.reject("Invalid release file") + } + }) + if (track != undefined) { const res = await androidPublisher.edits.commit({ auth: options.auth, diff --git a/src/main.ts b/src/main.ts index 6cb36b13..25237bfd 100644 --- a/src/main.ts +++ b/src/main.ts @@ -12,7 +12,7 @@ async function run() { 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 releaseFiles = core.getInput('releaseFile', { required: true }).split("|").filter(x => x !== ""); const track = core.getInput('track', { required: true }); const userFraction = core.getInput('userFraction', { required: false }); const whatsNewDir = core.getInput('whatsNewDirectory', { required: false }); @@ -51,11 +51,13 @@ async function run() { userFractionFloat = undefined } - // Check release file - if (!fs.existsSync(releaseFile)) { - core.setFailed(`Unable to find release file @ ${releaseFile}`); - return - } + // Check release files + releaseFiles.forEach(releaseFile => { + 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}`); @@ -76,14 +78,14 @@ async function run() { userFraction: userFractionFloat, whatsNewDir: whatsNewDir, mappingFile: mappingFile - }, releaseFile); + }, releaseFiles); if (downloadUrl) { core.setOutput('internalSharingDownloadUrl', downloadUrl); core.exportVariable('INTERNAL_SHARING_DOWNLOAD_URL', downloadUrl); } - console.log(`Finished uploading ${releaseFile} to the Play Store`) + console.log(`Finished uploading to the Play Store`) } catch (error) { core.setFailed(error.message) } From 8a9c9e7f3a4ef4f0a2c7158d722431c5d46b0352 Mon Sep 17 00:00:00 2001 From: "Jack Boswell (boswelja)" Date: Mon, 19 Oct 2020 18:25:02 +1300 Subject: [PATCH 03/26] Build updated action --- lib/edits.js | 79 +++++++++++++++++++++++++++++-------------------- lib/main.js | 50 +++++++++++++++++++++---------- lib/whatsnew.js | 27 ++++++++++++----- 3 files changed, 101 insertions(+), 55 deletions(-) diff --git a/lib/edits.js b/lib/edits.js index 8b1ee7fe..5c5032d0 100644 --- a/lib/edits.js +++ b/lib/edits.js @@ -1,4 +1,23 @@ "use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +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); + __setModuleDefault(result, mod); + return result; +}; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { @@ -8,36 +27,30 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; - result["default"] = mod; - return result; -}; Object.defineProperty(exports, "__esModule", { value: true }); +exports.uploadRelease = void 0; const core = __importStar(require("@actions/core")); const fs = __importStar(require("fs")); const fs_1 = require("fs"); const googleapis_1 = require("googleapis"); const whatsnew_1 = require("./whatsnew"); const androidPublisher = googleapis_1.google.androidpublisher('v3'); -function uploadRelease(options, releaseFile) { +function uploadRelease(options, releaseFiles) { 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`); - } + releaseFiles.forEach((releaseFile) => __awaiter(this, void 0, void 0, function* () { + // 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 = yield androidPublisher.edits.insert({ auth: options.auth, @@ -49,19 +62,21 @@ function uploadRelease(options, releaseFile) { return Promise.reject(`No track found for "${options.track}"`); } let track = undefined; - if (releaseFile.endsWith('.apk')) { - const apk = yield uploadApk(appEdit.data, options, releaseFile); - yield uploadMappingFile(appEdit.data, apk.versionCode, options); - track = yield trackVersionCode(appEdit.data, options, apk.versionCode); - } - else if (releaseFile.endsWith('.aab')) { - const bundle = yield uploadBundle(appEdit.data, options, releaseFile); - yield uploadMappingFile(appEdit.data, bundle.versionCode, options); - track = yield trackVersionCode(appEdit.data, options, bundle.versionCode); - } - else { - return Promise.reject("Invalid release file"); - } + releaseFiles.forEach((releaseFile) => __awaiter(this, void 0, void 0, function* () { + if (releaseFile.endsWith('.apk')) { + const apk = yield uploadApk(appEdit.data, options, releaseFile); + yield uploadMappingFile(appEdit.data, apk.versionCode, options); + track = yield trackVersionCode(appEdit.data, options, apk.versionCode); + } + else if (releaseFile.endsWith('.aab')) { + const bundle = yield uploadBundle(appEdit.data, options, releaseFile); + yield uploadMappingFile(appEdit.data, bundle.versionCode, options); + track = yield trackVersionCode(appEdit.data, options, bundle.versionCode); + } + else { + return Promise.reject("Invalid release file"); + } + })); if (track != undefined) { const res = yield androidPublisher.edits.commit({ auth: options.auth, diff --git a/lib/main.js b/lib/main.js index 951e9a3b..e4b02bd8 100644 --- a/lib/main.js +++ b/lib/main.js @@ -1,4 +1,23 @@ "use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +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); + __setModuleDefault(result, mod); + return result; +}; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { @@ -8,13 +27,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; - result["default"] = mod; - return result; -}; Object.defineProperty(exports, "__esModule", { value: true }); const core = __importStar(require("@actions/core")); const fs = __importStar(require("fs")); @@ -29,7 +41,7 @@ function run() { 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 releaseFiles = core.getInput('releaseFile', { required: true }).split("|").filter(x => x !== ""); const track = core.getInput('track', { required: true }); const userFraction = core.getInput('userFraction', { required: false }); const whatsNewDir = core.getInput('whatsNewDirectory', { required: false }); @@ -63,11 +75,13 @@ function run() { else { userFractionFloat = undefined; } - // Check release file - if (!fs.existsSync(releaseFile)) { - core.setFailed(`Unable to find release file @ ${releaseFile}`); - return; - } + // Check release files + releaseFiles.forEach(releaseFile => { + 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; @@ -77,15 +91,19 @@ function run() { return; } const authClient = yield auth.getClient(); - yield edits_1.uploadRelease({ + const downloadUrl = yield edits_1.uploadRelease({ auth: authClient, applicationId: packageName, track: track, userFraction: userFractionFloat, whatsNewDir: whatsNewDir, mappingFile: mappingFile - }, releaseFile); - console.log(`Finished uploading ${releaseFile} to the Play Store`); + }, releaseFiles); + if (downloadUrl) { + core.setOutput('internalSharingDownloadUrl', downloadUrl); + core.exportVariable('INTERNAL_SHARING_DOWNLOAD_URL', downloadUrl); + } + console.log(`Finished uploading to the Play Store`); } catch (error) { core.setFailed(error.message); diff --git a/lib/whatsnew.js b/lib/whatsnew.js index c51a53ce..5bfc4378 100644 --- a/lib/whatsnew.js +++ b/lib/whatsnew.js @@ -1,4 +1,23 @@ "use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}); +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); + __setModuleDefault(result, mod); + return result; +}; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { @@ -8,14 +27,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; - result["default"] = mod; - return result; -}; Object.defineProperty(exports, "__esModule", { value: true }); +exports.readLocalizedReleaseNotes = void 0; const core = __importStar(require("@actions/core")); const fs = __importStar(require("fs")); const path = __importStar(require("path")); From b2ae82a1044b4ed885fb59639e99400672048f6f Mon Sep 17 00:00:00 2001 From: "Jack Boswell (boswelja)" Date: Tue, 20 Oct 2020 13:11:31 +1300 Subject: [PATCH 04/26] Try a different split character --- lib/main.js | 2 +- src/main.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/main.js b/lib/main.js index e4b02bd8..04422bf5 100644 --- a/lib/main.js +++ b/lib/main.js @@ -41,7 +41,7 @@ function run() { const serviceAccountJson = core.getInput('serviceAccountJson', { required: false }); const serviceAccountJsonRaw = core.getInput('serviceAccountJsonPlainText', { required: false }); const packageName = core.getInput('packageName', { required: true }); - const releaseFiles = core.getInput('releaseFile', { required: true }).split("|").filter(x => x !== ""); + const releaseFiles = core.getInput('releaseFile', { required: true }).split(',').filter(x => x !== ''); const track = core.getInput('track', { required: true }); const userFraction = core.getInput('userFraction', { required: false }); const whatsNewDir = core.getInput('whatsNewDirectory', { required: false }); diff --git a/src/main.ts b/src/main.ts index 25237bfd..f935b841 100644 --- a/src/main.ts +++ b/src/main.ts @@ -12,7 +12,7 @@ async function run() { const serviceAccountJson = core.getInput('serviceAccountJson', { required: false }); const serviceAccountJsonRaw = core.getInput('serviceAccountJsonPlainText', { required: false}); const packageName = core.getInput('packageName', { required: true }); - const releaseFiles = core.getInput('releaseFile', { required: true }).split("|").filter(x => x !== ""); + const releaseFiles = core.getInput('releaseFile', { required: true }).split(',').filter(x => x !== ''); const track = core.getInput('track', { required: true }); const userFraction = core.getInput('userFraction', { required: false }); const whatsNewDir = core.getInput('whatsNewDirectory', { required: false }); From 18300ceb509a32f10c46019b33c42c9ce9a02fb2 Mon Sep 17 00:00:00 2001 From: "Jack Boswell (boswelja)" Date: Tue, 20 Oct 2020 13:41:02 +1300 Subject: [PATCH 05/26] Log release file count for testing purposes --- lib/main.js | 1 + src/main.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/lib/main.js b/lib/main.js index 04422bf5..a5c35caf 100644 --- a/lib/main.js +++ b/lib/main.js @@ -76,6 +76,7 @@ function run() { userFractionFloat = undefined; } // Check release files + console.log(`Checking ${releaseFiles.length} files`); releaseFiles.forEach(releaseFile => { if (!fs.existsSync(releaseFile)) { core.setFailed(`Unable to find release file @ ${releaseFile}`); diff --git a/src/main.ts b/src/main.ts index f935b841..ade87d60 100644 --- a/src/main.ts +++ b/src/main.ts @@ -52,6 +52,7 @@ async function run() { } // Check release files + console.log(`Checking ${releaseFiles.length} files`) releaseFiles.forEach(releaseFile => { if (!fs.existsSync(releaseFile)) { core.setFailed(`Unable to find release file @ ${releaseFile}`); From 2d2abb06d46509d153a7d9e783247be6f9149de2 Mon Sep 17 00:00:00 2001 From: "Jack Boswell (boswelja)" Date: Tue, 20 Oct 2020 18:52:07 +1300 Subject: [PATCH 06/26] Remove file count log output --- lib/main.js | 1 - src/main.ts | 1 - 2 files changed, 2 deletions(-) diff --git a/lib/main.js b/lib/main.js index a5c35caf..04422bf5 100644 --- a/lib/main.js +++ b/lib/main.js @@ -76,7 +76,6 @@ function run() { userFractionFloat = undefined; } // Check release files - console.log(`Checking ${releaseFiles.length} files`); releaseFiles.forEach(releaseFile => { if (!fs.existsSync(releaseFile)) { core.setFailed(`Unable to find release file @ ${releaseFile}`); diff --git a/src/main.ts b/src/main.ts index ade87d60..f935b841 100644 --- a/src/main.ts +++ b/src/main.ts @@ -52,7 +52,6 @@ async function run() { } // Check release files - console.log(`Checking ${releaseFiles.length} files`) releaseFiles.forEach(releaseFile => { if (!fs.existsSync(releaseFile)) { core.setFailed(`Unable to find release file @ ${releaseFile}`); From 640b063c96581ea842d811714a7174e726bcab84 Mon Sep 17 00:00:00 2001 From: "Jack Boswell (boswelja)" Date: Tue, 20 Oct 2020 18:56:28 +1300 Subject: [PATCH 07/26] Rename releaseFile input to releaseFiles --- action.yml | 4 ++-- lib/main.js | 2 +- src/main.ts | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/action.yml b/action.yml index 5f1e171b..9085d7a2 100644 --- a/action.yml +++ b/action.yml @@ -14,8 +14,8 @@ inputs: packageName: description: 'The package name, or Application Id, of the app you are uploading' required: true - releaseFile: - description: 'The Android release file to upload (.apk or .aab)' + releaseFiles: + description: 'The Android release file(s) to upload (.apk or .aab). Separated by a \',\' for multiple artifacts' required: true track: description: 'The track in which you want to assign the uploaded app.' diff --git a/lib/main.js b/lib/main.js index 04422bf5..9e642230 100644 --- a/lib/main.js +++ b/lib/main.js @@ -41,7 +41,7 @@ function run() { const serviceAccountJson = core.getInput('serviceAccountJson', { required: false }); const serviceAccountJsonRaw = core.getInput('serviceAccountJsonPlainText', { required: false }); const packageName = core.getInput('packageName', { required: true }); - const releaseFiles = core.getInput('releaseFile', { required: true }).split(',').filter(x => x !== ''); + const releaseFiles = core.getInput('releaseFiles', { required: true }).split(',').filter(x => x !== ''); const track = core.getInput('track', { required: true }); const userFraction = core.getInput('userFraction', { required: false }); const whatsNewDir = core.getInput('whatsNewDirectory', { required: false }); diff --git a/src/main.ts b/src/main.ts index f935b841..ef145635 100644 --- a/src/main.ts +++ b/src/main.ts @@ -12,7 +12,7 @@ async function run() { const serviceAccountJson = core.getInput('serviceAccountJson', { required: false }); const serviceAccountJsonRaw = core.getInput('serviceAccountJsonPlainText', { required: false}); const packageName = core.getInput('packageName', { required: true }); - const releaseFiles = core.getInput('releaseFile', { required: true }).split(',').filter(x => x !== ''); + const releaseFiles = core.getInput('releaseFiles', { required: true }).split(',').filter(x => x !== ''); const track = core.getInput('track', { required: true }); const userFraction = core.getInput('userFraction', { required: false }); const whatsNewDir = core.getInput('whatsNewDirectory', { required: false }); From 5d0e398bfbbdf84fa92efcbbae9136dcb8ce5514 Mon Sep 17 00:00:00 2001 From: "Jack Boswell (boswelja)" Date: Tue, 20 Oct 2020 19:27:02 +1300 Subject: [PATCH 08/26] Rewrite a portion of edits.ts uploadRelease now specifically only uploads to an edit. uploadToPlayStore is designed to handle multiple inputs, and commit them at the right time. Error catching should be improved now. --- lib/edits.js | 97 ++++++++++++++++++++++++++++++---------------------- lib/main.js | 2 +- src/edits.ts | 91 ++++++++++++++++++++++++++---------------------- src/main.ts | 4 +-- 4 files changed, 110 insertions(+), 84 deletions(-) diff --git a/lib/edits.js b/lib/edits.js index 5c5032d0..1b9c72c3 100644 --- a/lib/edits.js +++ b/lib/edits.js @@ -28,66 +28,81 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge }); }; Object.defineProperty(exports, "__esModule", { value: true }); -exports.uploadRelease = void 0; +exports.uploadToPlayStore = void 0; const core = __importStar(require("@actions/core")); const fs = __importStar(require("fs")); const fs_1 = require("fs"); const googleapis_1 = require("googleapis"); const whatsnew_1 = require("./whatsnew"); const androidPublisher = googleapis_1.google.androidpublisher('v3'); -function uploadRelease(options, releaseFiles) { +function uploadToPlayStore(options, releaseFiles) { 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"); - releaseFiles.forEach((releaseFile) => __awaiter(this, void 0, void 0, function* () { - // 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 = yield androidPublisher.edits.insert({ auth: options.auth, packageName: options.applicationId }); - const allTracks = yield getAllTracks(appEdit.data, options); + releaseFiles.forEach((releaseFile) => __awaiter(this, void 0, void 0, function* () { + core.debug(`Uploading ${releaseFile}`); + yield uploadRelease(appEdit.data, options, releaseFile).catch(reason => { + return Promise.reject(reason); + }); + })); + const res = yield androidPublisher.edits.commit({ + auth: options.auth, + editId: appEdit.data.id, + packageName: options.applicationId + }); + if (res.data.id != null) { + core.debug(`Successfully committed ${res.data.id}`); + return Promise.resolve(res.data.id); + } + else { + core.setFailed(`Error ${res.status}: ${res.statusText}`); + return Promise.reject(res.status); + } + }); +} +exports.uploadToPlayStore = uploadToPlayStore; +function uploadRelease(appEdit, 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 { + core.setFailed(`${releaseFile} is invalid`); + return Promise.reject(`${releaseFile} is invalid`); + } + } + const allTracks = yield getAllTracks(appEdit, 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; - releaseFiles.forEach((releaseFile) => __awaiter(this, void 0, void 0, function* () { - if (releaseFile.endsWith('.apk')) { - const apk = yield uploadApk(appEdit.data, options, releaseFile); - yield uploadMappingFile(appEdit.data, apk.versionCode, options); - track = yield trackVersionCode(appEdit.data, options, apk.versionCode); - } - else if (releaseFile.endsWith('.aab')) { - const bundle = yield uploadBundle(appEdit.data, options, releaseFile); - yield uploadMappingFile(appEdit.data, bundle.versionCode, options); - track = yield trackVersionCode(appEdit.data, options, bundle.versionCode); - } - else { - return Promise.reject("Invalid release file"); - } - })); - if (track != undefined) { - const res = yield androidPublisher.edits.commit({ - auth: options.auth, - editId: appEdit.data.id, - packageName: options.applicationId - }); - core.debug(`Committed release with Id(${res.data.id}) and Track: ${track}`); + if (releaseFile.endsWith('.apk')) { + const apk = yield uploadApk(appEdit, options, releaseFile); + yield uploadMappingFile(appEdit, apk.versionCode, options); + track = yield trackVersionCode(appEdit, options, apk.versionCode); + } + else if (releaseFile.endsWith('.aab')) { + const bundle = yield uploadBundle(appEdit, options, releaseFile); + yield uploadMappingFile(appEdit, bundle.versionCode, options); + track = yield trackVersionCode(appEdit, options, bundle.versionCode); + } + else { + core.setFailed(`${releaseFile} is invalid`); + return Promise.reject(`${releaseFile} is invalid`); } }); } -exports.uploadRelease = uploadRelease; function getAllTracks(appEdit, options) { return __awaiter(this, void 0, void 0, function* () { const res = yield androidPublisher.edits.tracks.list({ diff --git a/lib/main.js b/lib/main.js index 9e642230..4b0a2759 100644 --- a/lib/main.js +++ b/lib/main.js @@ -91,7 +91,7 @@ function run() { return; } const authClient = yield auth.getClient(); - const downloadUrl = yield edits_1.uploadRelease({ + const downloadUrl = yield edits_1.uploadToPlayStore({ auth: authClient, applicationId: packageName, track: track, diff --git a/src/edits.ts b/src/edits.ts index 29864034..643e94ca 100644 --- a/src/edits.ts +++ b/src/edits.ts @@ -27,57 +27,68 @@ export interface EditOptions { mappingFile?: string; } -export async function uploadRelease(options: EditOptions, releaseFiles: string[]): Promise { - // 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") - releaseFiles.forEach(async releaseFile => { - // 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`) - // } - }) - } - +export async function uploadToPlayStore(options: EditOptions, releaseFiles: string[]): Promise { const appEdit = await androidPublisher.edits.insert({ auth: options.auth, packageName: options.applicationId }); + + releaseFiles.forEach(async releaseFile => { + core.debug(`Uploading ${releaseFile}`) + await uploadRelease(appEdit.data, options, releaseFile).catch(reason => { + return Promise.reject(reason) + }) + }) - const allTracks = await getAllTracks(appEdit.data!, options); + const res = await androidPublisher.edits.commit({ + auth: options.auth, + editId: appEdit.data.id!, + packageName: options.applicationId + }); + + if (res.data.id != null) { + core.debug(`Successfully committed ${res.data.id}`) + return Promise.resolve(res.data.id!) + } else { + core.setFailed(`Error ${res.status}: ${res.statusText}`) + return Promise.reject(res.status) + } +} + +async function uploadRelease(appEdit: AppEdit, options: EditOptions, releaseFile: string): Promise { + // 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 { + core.setFailed(`${releaseFile} is invalid`) + return Promise.reject(`${releaseFile} is invalid`) + } + } + + const allTracks = await getAllTracks(appEdit!, 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; - releaseFiles.forEach(async releaseFile => { - if (releaseFile.endsWith('.apk')) { - const apk = await uploadApk(appEdit.data, options, releaseFile); - await uploadMappingFile(appEdit.data, apk.versionCode!, options); - track = await trackVersionCode(appEdit.data, options, apk.versionCode!) - } else if (releaseFile.endsWith('.aab')) { - const bundle = await uploadBundle(appEdit.data, options, releaseFile); - await uploadMappingFile(appEdit.data, bundle.versionCode!, options); - track = await trackVersionCode(appEdit.data, options, bundle.versionCode!) - } else { - return Promise.reject("Invalid release file") - } - }) - - if (track != undefined) { - const res = await androidPublisher.edits.commit({ - auth: options.auth, - editId: appEdit.data.id!, - packageName: options.applicationId - }); - - core.debug(`Committed release with Id(${res.data.id}) and Track: ${track}`); + if (releaseFile.endsWith('.apk')) { + const apk = await uploadApk(appEdit, options, releaseFile); + await uploadMappingFile(appEdit, apk.versionCode!, options); + track = await trackVersionCode(appEdit, options, apk.versionCode!) + } else if (releaseFile.endsWith('.aab')) { + const bundle = await uploadBundle(appEdit, options, releaseFile); + await uploadMappingFile(appEdit, bundle.versionCode!, options); + track = await trackVersionCode(appEdit, options, bundle.versionCode!) + } else { + core.setFailed(`${releaseFile} is invalid`) + return Promise.reject(`${releaseFile} is invalid`) } } diff --git a/src/main.ts b/src/main.ts index ef145635..80ec6932 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,6 +1,6 @@ import * as core from '@actions/core'; import * as fs from "fs"; -import {uploadRelease} from "./edits"; +import { uploadToPlayStore } from "./edits"; const {google} = require('googleapis'); const auth = new google.auth.GoogleAuth({ @@ -71,7 +71,7 @@ async function run() { const authClient = await auth.getClient(); - const downloadUrl = await uploadRelease({ + const downloadUrl = await uploadToPlayStore({ auth: authClient, applicationId: packageName, track: track, From fb873d403d221f28dcfa4980ac21822adf931454 Mon Sep 17 00:00:00 2001 From: "Jack Boswell (boswelja)" Date: Tue, 20 Oct 2020 19:51:19 +1300 Subject: [PATCH 09/26] Sttempt to fix invalid action.yml --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 9085d7a2..0f547851 100644 --- a/action.yml +++ b/action.yml @@ -15,7 +15,7 @@ inputs: description: 'The package name, or Application Id, of the app you are uploading' required: true releaseFiles: - description: 'The Android release file(s) to upload (.apk or .aab). Separated by a \',\' for multiple artifacts' + description: "The Android release file(s) to upload (.apk or .aab). Separated by a ',' for multiple artifacts" required: true track: description: 'The track in which you want to assign the uploaded app.' From f5c3d22549cfd7fa238d50efdf9851ef272fe814 Mon Sep 17 00:00:00 2001 From: "Jack Boswell (boswelja)" Date: Fri, 23 Oct 2020 15:20:16 +1300 Subject: [PATCH 10/26] Add some extra log output --- lib/edits.js | 3 +++ src/edits.ts | 3 +++ 2 files changed, 6 insertions(+) diff --git a/lib/edits.js b/lib/edits.js index 1b9c72c3..170b72c8 100644 --- a/lib/edits.js +++ b/lib/edits.js @@ -44,6 +44,7 @@ function uploadToPlayStore(options, releaseFiles) { releaseFiles.forEach((releaseFile) => __awaiter(this, void 0, void 0, function* () { core.debug(`Uploading ${releaseFile}`); yield uploadRelease(appEdit.data, options, releaseFile).catch(reason => { + core.setFailed(reason); return Promise.reject(reason); }); })); @@ -70,10 +71,12 @@ function uploadRelease(appEdit, options, releaseFile) { core.debug("Track is Internal app sharing, switch to special upload api"); if (releaseFile.endsWith('.apk')) { const res = yield internalSharingUploadApk(options, releaseFile); + 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); + console.log(`${releaseFile} uploaded to Internal Sharing, download it with ${res.downloadUrl}`); return Promise.resolve(res.downloadUrl); } else { diff --git a/src/edits.ts b/src/edits.ts index 643e94ca..b1760192 100644 --- a/src/edits.ts +++ b/src/edits.ts @@ -36,6 +36,7 @@ export async function uploadToPlayStore(options: EditOptions, releaseFiles: stri releaseFiles.forEach(async releaseFile => { core.debug(`Uploading ${releaseFile}`) await uploadRelease(appEdit.data, options, releaseFile).catch(reason => { + core.setFailed(reason) return Promise.reject(reason) }) }) @@ -61,9 +62,11 @@ async function uploadRelease(appEdit: AppEdit, options: EditOptions, releaseFile core.debug("Track is Internal app sharing, switch to special upload api") if (releaseFile.endsWith('.apk')) { const res = await internalSharingUploadApk(options, releaseFile) + 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) + console.log(`${releaseFile} uploaded to Internal Sharing, download it with ${res.downloadUrl}`) return Promise.resolve(res.downloadUrl) } else { core.setFailed(`${releaseFile} is invalid`) From 87accbcd4146d863890bcaaff480eae3a88d48eb Mon Sep 17 00:00:00 2001 From: "Jack Boswell (boswelja)" Date: Fri, 23 Oct 2020 16:00:18 +1300 Subject: [PATCH 11/26] Add releases to the edit track correctly --- lib/edits.js | 22 +++++++++++----------- src/edits.ts | 24 ++++++++++++------------ 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/lib/edits.js b/lib/edits.js index 170b72c8..4350deb5 100644 --- a/lib/edits.js +++ b/lib/edits.js @@ -41,13 +41,16 @@ function uploadToPlayStore(options, releaseFiles) { auth: options.auth, packageName: options.applicationId }); + var versionCodes = new Array(); releaseFiles.forEach((releaseFile) => __awaiter(this, void 0, void 0, function* () { core.debug(`Uploading ${releaseFile}`); - yield uploadRelease(appEdit.data, options, releaseFile).catch(reason => { + const versionCode = yield uploadRelease(appEdit.data, options, releaseFile).catch(reason => { core.setFailed(reason); return Promise.reject(reason); }); + versionCodes.push(versionCode); })); + const track = trackVersionCode(appEdit.data, options, versionCodes); const res = yield androidPublisher.edits.commit({ auth: options.auth, editId: appEdit.data.id, @@ -72,12 +75,12 @@ function uploadRelease(appEdit, options, releaseFile) { if (releaseFile.endsWith('.apk')) { const res = yield internalSharingUploadApk(options, releaseFile); console.log(`${releaseFile} uploaded to Internal Sharing, download it with ${res.downloadUrl}`); - return Promise.resolve(res.downloadUrl); + return Promise.resolve(undefined); } else if (releaseFile.endsWith('.aab')) { const res = yield internalSharingUploadBundle(options, releaseFile); console.log(`${releaseFile} uploaded to Internal Sharing, download it with ${res.downloadUrl}`); - return Promise.resolve(res.downloadUrl); + return Promise.resolve(undefined); } else { core.setFailed(`${releaseFile} is invalid`); @@ -89,16 +92,15 @@ function uploadRelease(appEdit, options, releaseFile) { core.setFailed(`Track "${options.track}" could not be found `); return Promise.reject(`No track found for "${options.track}"`); } - let track = undefined; if (releaseFile.endsWith('.apk')) { const apk = yield uploadApk(appEdit, options, releaseFile); yield uploadMappingFile(appEdit, apk.versionCode, options); - track = yield trackVersionCode(appEdit, options, apk.versionCode); + return Promise.resolve(apk.versionCode); } else if (releaseFile.endsWith('.aab')) { const bundle = yield uploadBundle(appEdit, options, releaseFile); yield uploadMappingFile(appEdit, bundle.versionCode, options); - track = yield trackVersionCode(appEdit, options, bundle.versionCode); + return Promise.resolve(bundle.versionCode); } else { core.setFailed(`${releaseFile} is invalid`); @@ -116,7 +118,7 @@ function getAllTracks(appEdit, options) { return res.data.tracks; }); } -function trackVersionCode(appEdit, options, versionCode) { +function trackVersionCode(appEdit, options, versionCodes) { return __awaiter(this, void 0, void 0, function* () { let status; if (options.userFraction != undefined) { @@ -125,7 +127,7 @@ function trackVersionCode(appEdit, options, versionCode) { else { status = 'completed'; } - core.debug(`Creating Track Release for Edit(${appEdit.id}) for Track(${options.track}) with a UserFraction(${options.userFraction}) and VersionCode(${versionCode})`); + core.debug(`Creating Track Release for Edit(${appEdit.id}) for Track(${options.track}) with a UserFraction(${options.userFraction}) and VersionCodes(${versionCodes})`); const res = yield androidPublisher.edits.tracks .update({ auth: options.auth, @@ -139,9 +141,7 @@ function trackVersionCode(appEdit, options, versionCode) { userFraction: options.userFraction, status: status, releaseNotes: yield whatsnew_1.readLocalizedReleaseNotes(options.whatsNewDir), - versionCodes: [ - versionCode.toString() - ] + versionCodes: versionCodes.map(x => x.toString()) } ] } diff --git a/src/edits.ts b/src/edits.ts index b1760192..443536d5 100644 --- a/src/edits.ts +++ b/src/edits.ts @@ -33,14 +33,17 @@ export async function uploadToPlayStore(options: EditOptions, releaseFiles: stri packageName: options.applicationId }); + var versionCodes = new Array() releaseFiles.forEach(async releaseFile => { core.debug(`Uploading ${releaseFile}`) - await uploadRelease(appEdit.data, options, releaseFile).catch(reason => { + const versionCode = await uploadRelease(appEdit.data, options, releaseFile).catch(reason => { core.setFailed(reason) return Promise.reject(reason) }) + versionCodes.push(versionCode!) }) + const track = trackVersionCode(appEdit.data, options, versionCodes) const res = await androidPublisher.edits.commit({ auth: options.auth, editId: appEdit.data.id!, @@ -56,18 +59,18 @@ export async function uploadToPlayStore(options: EditOptions, releaseFiles: stri } } -async function uploadRelease(appEdit: AppEdit, options: EditOptions, releaseFile: string): Promise { +async function uploadRelease(appEdit: AppEdit, options: EditOptions, releaseFile: string): Promise { // 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) console.log(`${releaseFile} uploaded to Internal Sharing, download it with ${res.downloadUrl}`) - return Promise.resolve(res.downloadUrl) + return Promise.resolve(undefined) } else if (releaseFile.endsWith('.aab')) { const res = await internalSharingUploadBundle(options, releaseFile) console.log(`${releaseFile} uploaded to Internal Sharing, download it with ${res.downloadUrl}`) - return Promise.resolve(res.downloadUrl) + return Promise.resolve(undefined) } else { core.setFailed(`${releaseFile} is invalid`) return Promise.reject(`${releaseFile} is invalid`) @@ -80,15 +83,14 @@ async function uploadRelease(appEdit: AppEdit, options: EditOptions, releaseFile return Promise.reject(`No track found for "${options.track}"`) } - let track: Track | undefined = undefined; if (releaseFile.endsWith('.apk')) { const apk = await uploadApk(appEdit, options, releaseFile); await uploadMappingFile(appEdit, apk.versionCode!, options); - track = await trackVersionCode(appEdit, options, apk.versionCode!) + return Promise.resolve(apk.versionCode) } else if (releaseFile.endsWith('.aab')) { const bundle = await uploadBundle(appEdit, options, releaseFile); await uploadMappingFile(appEdit, bundle.versionCode!, options); - track = await trackVersionCode(appEdit, options, bundle.versionCode!) + return Promise.resolve(bundle.versionCode) } else { core.setFailed(`${releaseFile} is invalid`) return Promise.reject(`${releaseFile} is invalid`) @@ -105,7 +107,7 @@ async function getAllTracks(appEdit: AppEdit, options: EditOptions): Promise { +async function trackVersionCode(appEdit: AppEdit, options: EditOptions, versionCodes: number[]): Promise { let status: string; if (options.userFraction != undefined) { status = 'inProgress' @@ -113,7 +115,7 @@ async function trackVersionCode(appEdit: AppEdit, options: EditOptions, versionC status = 'completed' } - core.debug(`Creating Track Release for Edit(${appEdit.id}) for Track(${options.track}) with a UserFraction(${options.userFraction}) and VersionCode(${versionCode})`); + core.debug(`Creating Track Release for Edit(${appEdit.id}) for Track(${options.track}) with a UserFraction(${options.userFraction}) and VersionCodes(${versionCodes})`); const res = await androidPublisher.edits.tracks .update({ auth: options.auth, @@ -127,9 +129,7 @@ async function trackVersionCode(appEdit: AppEdit, options: EditOptions, versionC userFraction: options.userFraction, status: status, releaseNotes: await readLocalizedReleaseNotes(options.whatsNewDir), - versionCodes: [ - versionCode.toString() - ] + versionCodes: versionCodes.map(x => x.toString()) } ] } From fc19501036d6580d4ce38ae7f489fe635784259a Mon Sep 17 00:00:00 2001 From: "Jack Boswell (boswelja)" Date: Fri, 23 Oct 2020 16:12:01 +1300 Subject: [PATCH 12/26] Move track validation to a separate function --- lib/edits.js | 17 ++++++++++------- src/edits.ts | 48 +++++++++++++++++++++++++----------------------- 2 files changed, 35 insertions(+), 30 deletions(-) diff --git a/lib/edits.js b/lib/edits.js index 4350deb5..42470d89 100644 --- a/lib/edits.js +++ b/lib/edits.js @@ -41,6 +41,10 @@ function uploadToPlayStore(options, releaseFiles) { auth: options.auth, packageName: options.applicationId }); + yield validateSelectedTrack(appEdit.data, options).catch(reason => { + core.setFailed(reason); + return Promise.reject(reason); + }); var versionCodes = new Array(); releaseFiles.forEach((releaseFile) => __awaiter(this, void 0, void 0, function* () { core.debug(`Uploading ${releaseFile}`); @@ -87,11 +91,6 @@ function uploadRelease(appEdit, options, releaseFile) { return Promise.reject(`${releaseFile} is invalid`); } } - const allTracks = yield getAllTracks(appEdit, 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}"`); - } if (releaseFile.endsWith('.apk')) { const apk = yield uploadApk(appEdit, options, releaseFile); yield uploadMappingFile(appEdit, apk.versionCode, options); @@ -108,14 +107,18 @@ function uploadRelease(appEdit, options, releaseFile) { } }); } -function getAllTracks(appEdit, options) { +function validateSelectedTrack(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; + const allTracks = res.data.tracks; + 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}"`); + } }); } function trackVersionCode(appEdit, options, versionCodes) { diff --git a/src/edits.ts b/src/edits.ts index 443536d5..bb5ac36a 100644 --- a/src/edits.ts +++ b/src/edits.ts @@ -33,17 +33,22 @@ export async function uploadToPlayStore(options: EditOptions, releaseFiles: stri packageName: options.applicationId }); - var versionCodes = new Array() - releaseFiles.forEach(async releaseFile => { - core.debug(`Uploading ${releaseFile}`) - const versionCode = await uploadRelease(appEdit.data, options, releaseFile).catch(reason => { - core.setFailed(reason) - return Promise.reject(reason) - }) - versionCodes.push(versionCode!) - }) + await validateSelectedTrack(appEdit.data, options).catch(reason => { + core.setFailed(reason); + return Promise.reject(reason); + }); - const track = trackVersionCode(appEdit.data, options, versionCodes) + var versionCodes = new Array(); + releaseFiles.forEach(async releaseFile => { + core.debug(`Uploading ${releaseFile}`); + const versionCode = await uploadRelease(appEdit.data, options, releaseFile).catch(reason => { + core.setFailed(reason); + return Promise.reject(reason); + }); + versionCodes.push(versionCode!); + }); + + const track = trackVersionCode(appEdit.data, options, versionCodes); const res = await androidPublisher.edits.commit({ auth: options.auth, editId: appEdit.data.id!, @@ -51,11 +56,11 @@ export async function uploadToPlayStore(options: EditOptions, releaseFiles: stri }); if (res.data.id != null) { - core.debug(`Successfully committed ${res.data.id}`) - return Promise.resolve(res.data.id!) + core.debug(`Successfully committed ${res.data.id}`); + return Promise.resolve(res.data.id!); } else { - core.setFailed(`Error ${res.status}: ${res.statusText}`) - return Promise.reject(res.status) + core.setFailed(`Error ${res.status}: ${res.statusText}`); + return Promise.reject(res.status); } } @@ -77,12 +82,6 @@ async function uploadRelease(appEdit: AppEdit, options: EditOptions, releaseFile } } - const allTracks = await getAllTracks(appEdit!, 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}"`) - } - if (releaseFile.endsWith('.apk')) { const apk = await uploadApk(appEdit, options, releaseFile); await uploadMappingFile(appEdit, apk.versionCode!, options); @@ -97,14 +96,17 @@ async function uploadRelease(appEdit: AppEdit, options: EditOptions, releaseFile } } -async function getAllTracks(appEdit: AppEdit, options: EditOptions): Promise { +async function validateSelectedTrack(appEdit: AppEdit, options: EditOptions): Promise { const res = await androidPublisher.edits.tracks.list({ auth: options.auth, editId: appEdit.id!, packageName: options.applicationId }); - - return res.data.tracks + const allTracks = res.data.tracks; + 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}"`) + } } async function trackVersionCode(appEdit: AppEdit, options: EditOptions, versionCodes: number[]): Promise { From 32ecfee3156c5e3896088e6c87da395c80044fc3 Mon Sep 17 00:00:00 2001 From: "Jack Boswell (boswelja)" Date: Fri, 23 Oct 2020 16:15:51 +1300 Subject: [PATCH 13/26] Rename trackVersionCode to addReleasesToTrack I feel this better describes what the function does --- lib/edits.js | 4 ++-- src/edits.ts | 22 +++++++++++----------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/edits.js b/lib/edits.js index 42470d89..efc69c51 100644 --- a/lib/edits.js +++ b/lib/edits.js @@ -54,7 +54,7 @@ function uploadToPlayStore(options, releaseFiles) { }); versionCodes.push(versionCode); })); - const track = trackVersionCode(appEdit.data, options, versionCodes); + const track = addReleasesToTrack(appEdit.data, options, versionCodes); const res = yield androidPublisher.edits.commit({ auth: options.auth, editId: appEdit.data.id, @@ -121,7 +121,7 @@ function validateSelectedTrack(appEdit, options) { } }); } -function trackVersionCode(appEdit, options, versionCodes) { +function addReleasesToTrack(appEdit, options, versionCodes) { return __awaiter(this, void 0, void 0, function* () { let status; if (options.userFraction != undefined) { diff --git a/src/edits.ts b/src/edits.ts index bb5ac36a..0bff373b 100644 --- a/src/edits.ts +++ b/src/edits.ts @@ -48,7 +48,7 @@ export async function uploadToPlayStore(options: EditOptions, releaseFiles: stri versionCodes.push(versionCode!); }); - const track = trackVersionCode(appEdit.data, options, versionCodes); + const track = addReleasesToTrack(appEdit.data, options, versionCodes); const res = await androidPublisher.edits.commit({ auth: options.auth, editId: appEdit.data.id!, @@ -85,14 +85,14 @@ async function uploadRelease(appEdit: AppEdit, options: EditOptions, releaseFile if (releaseFile.endsWith('.apk')) { const apk = await uploadApk(appEdit, options, releaseFile); await uploadMappingFile(appEdit, apk.versionCode!, options); - return Promise.resolve(apk.versionCode) + return Promise.resolve(apk.versionCode); } else if (releaseFile.endsWith('.aab')) { const bundle = await uploadBundle(appEdit, options, releaseFile); await uploadMappingFile(appEdit, bundle.versionCode!, options); - return Promise.resolve(bundle.versionCode) + return Promise.resolve(bundle.versionCode); } else { - core.setFailed(`${releaseFile} is invalid`) - return Promise.reject(`${releaseFile} is invalid`) + core.setFailed(`${releaseFile} is invalid`); + return Promise.reject(`${releaseFile} is invalid`); } } @@ -104,17 +104,17 @@ async function validateSelectedTrack(appEdit: AppEdit, options: EditOptions): Pr }); const allTracks = res.data.tracks; 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}"`) + core.setFailed(`Track "${options.track}" could not be found `); + return Promise.reject(`No track found for "${options.track}"`); } } -async function trackVersionCode(appEdit: AppEdit, options: EditOptions, versionCodes: number[]): Promise { +async function addReleasesToTrack(appEdit: AppEdit, options: EditOptions, versionCodes: number[]): Promise { let status: string; if (options.userFraction != undefined) { - status = 'inProgress' + status = 'inProgress'; } else { - status = 'completed' + status = 'completed'; } core.debug(`Creating Track Release for Edit(${appEdit.id}) for Track(${options.track}) with a UserFraction(${options.userFraction}) and VersionCodes(${versionCodes})`); @@ -137,7 +137,7 @@ async function trackVersionCode(appEdit: AppEdit, options: EditOptions, versionC } }); - return res.data + return res.data; } async function uploadMappingFile(appEdit: AppEdit, versionCode: number, options: EditOptions) { From 7774099a1b7f49c72917ed98eae8f6e57df78ff3 Mon Sep 17 00:00:00 2001 From: "Jack Boswell (boswelja)" Date: Fri, 23 Oct 2020 16:26:01 +1300 Subject: [PATCH 14/26] Separate internal sharing uploading into it's own function Also skip unneeded setup when uploading to internal sharing --- lib/edits.js | 103 +++++++++++++++++++++++++++++---------------------- src/edits.ts | 100 +++++++++++++++++++++++++++---------------------- 2 files changed, 113 insertions(+), 90 deletions(-) diff --git a/lib/edits.js b/lib/edits.js index efc69c51..eb907305 100644 --- a/lib/edits.js +++ b/lib/edits.js @@ -37,60 +37,73 @@ const whatsnew_1 = require("./whatsnew"); const androidPublisher = googleapis_1.google.androidpublisher('v3'); function uploadToPlayStore(options, releaseFiles) { return __awaiter(this, void 0, void 0, function* () { - const appEdit = yield androidPublisher.edits.insert({ - auth: options.auth, - packageName: options.applicationId - }); - yield validateSelectedTrack(appEdit.data, options).catch(reason => { - core.setFailed(reason); - return Promise.reject(reason); - }); - var versionCodes = new Array(); - releaseFiles.forEach((releaseFile) => __awaiter(this, void 0, void 0, function* () { - core.debug(`Uploading ${releaseFile}`); - const versionCode = yield uploadRelease(appEdit.data, options, releaseFile).catch(reason => { + if (options.track === 'internalappsharing') { + core.debug("Track is Internal app sharing, switch to special upload api"); + releaseFiles.forEach((releaseFile) => __awaiter(this, void 0, void 0, function* () { + core.debug(`Uploading ${releaseFile}`); + yield uploadInternalSharingRelease(options, releaseFile).catch(reason => { + core.setFailed(reason); + return Promise.reject(reason); + }); + })); + } + else { + const appEdit = yield androidPublisher.edits.insert({ + auth: options.auth, + packageName: options.applicationId + }); + yield validateSelectedTrack(appEdit.data, options).catch(reason => { core.setFailed(reason); return Promise.reject(reason); }); - versionCodes.push(versionCode); - })); - const track = addReleasesToTrack(appEdit.data, options, versionCodes); - const res = yield androidPublisher.edits.commit({ - auth: options.auth, - editId: appEdit.data.id, - packageName: options.applicationId - }); - if (res.data.id != null) { - core.debug(`Successfully committed ${res.data.id}`); - return Promise.resolve(res.data.id); - } - else { - core.setFailed(`Error ${res.status}: ${res.statusText}`); - return Promise.reject(res.status); + // Check the 'track' for 'internalsharing', if so switch to a non-track api + var versionCodes = new Array(); + releaseFiles.forEach((releaseFile) => __awaiter(this, void 0, void 0, function* () { + core.debug(`Uploading ${releaseFile}`); + const versionCode = yield uploadRelease(appEdit.data, options, releaseFile).catch(reason => { + core.setFailed(reason); + return Promise.reject(reason); + }); + versionCodes.push(versionCode); + })); + const track = addReleasesToTrack(appEdit.data, options, versionCodes); + const res = yield androidPublisher.edits.commit({ + auth: options.auth, + editId: appEdit.data.id, + packageName: options.applicationId + }); + if (res.data.id != null) { + core.debug(`Successfully committed ${res.data.id}`); + return Promise.resolve(res.data.id); + } + else { + core.setFailed(`Error ${res.status}: ${res.statusText}`); + return Promise.reject(res.status); + } } }); } exports.uploadToPlayStore = uploadToPlayStore; +function uploadInternalSharingRelease(options, releaseFile) { + return __awaiter(this, void 0, void 0, function* () { + if (releaseFile.endsWith('.apk')) { + const res = yield internalSharingUploadApk(options, releaseFile); + 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); + console.log(`${releaseFile} uploaded to Internal Sharing, download it with ${res.downloadUrl}`); + return Promise.resolve(res.downloadUrl); + } + else { + core.setFailed(`${releaseFile} is invalid`); + return Promise.reject(`${releaseFile} is invalid`); + } + }); +} function uploadRelease(appEdit, 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); - console.log(`${releaseFile} uploaded to Internal Sharing, download it with ${res.downloadUrl}`); - return Promise.resolve(undefined); - } - else if (releaseFile.endsWith('.aab')) { - const res = yield internalSharingUploadBundle(options, releaseFile); - console.log(`${releaseFile} uploaded to Internal Sharing, download it with ${res.downloadUrl}`); - return Promise.resolve(undefined); - } - else { - core.setFailed(`${releaseFile} is invalid`); - return Promise.reject(`${releaseFile} is invalid`); - } - } if (releaseFile.endsWith('.apk')) { const apk = yield uploadApk(appEdit, options, releaseFile); yield uploadMappingFile(appEdit, apk.versionCode, options); diff --git a/src/edits.ts b/src/edits.ts index 0bff373b..d517c92c 100644 --- a/src/edits.ts +++ b/src/edits.ts @@ -28,60 +28,70 @@ export interface EditOptions { } export async function uploadToPlayStore(options: EditOptions, releaseFiles: string[]): Promise { - const appEdit = await androidPublisher.edits.insert({ - auth: options.auth, - packageName: options.applicationId - }); - - await validateSelectedTrack(appEdit.data, options).catch(reason => { - core.setFailed(reason); - return Promise.reject(reason); - }); - - var versionCodes = new Array(); - releaseFiles.forEach(async releaseFile => { - core.debug(`Uploading ${releaseFile}`); - const versionCode = await uploadRelease(appEdit.data, options, releaseFile).catch(reason => { + if (options.track === 'internalappsharing') { + core.debug("Track is Internal app sharing, switch to special upload api") + releaseFiles.forEach(async releaseFile => { + core.debug(`Uploading ${releaseFile}`); + await uploadInternalSharingRelease(options, releaseFile).catch(reason => { + core.setFailed(reason); + return Promise.reject(reason); + }); + }); + } else { + const appEdit = await androidPublisher.edits.insert({ + auth: options.auth, + packageName: options.applicationId + }); + + await validateSelectedTrack(appEdit.data, options).catch(reason => { core.setFailed(reason); return Promise.reject(reason); }); - versionCodes.push(versionCode!); - }); + + // Check the 'track' for 'internalsharing', if so switch to a non-track api + var versionCodes = new Array(); + releaseFiles.forEach(async releaseFile => { + core.debug(`Uploading ${releaseFile}`); + const versionCode = await uploadRelease(appEdit.data, options, releaseFile).catch(reason => { + core.setFailed(reason); + return Promise.reject(reason); + }); + versionCodes.push(versionCode!); + }); + + const track = addReleasesToTrack(appEdit.data, options, versionCodes); + const res = await androidPublisher.edits.commit({ + auth: options.auth, + editId: appEdit.data.id!, + packageName: options.applicationId + }); + + if (res.data.id != null) { + core.debug(`Successfully committed ${res.data.id}`); + return Promise.resolve(res.data.id!); + } else { + core.setFailed(`Error ${res.status}: ${res.statusText}`); + return Promise.reject(res.status); + } + } +} - const track = addReleasesToTrack(appEdit.data, options, versionCodes); - const res = await androidPublisher.edits.commit({ - auth: options.auth, - editId: appEdit.data.id!, - packageName: options.applicationId - }); - - if (res.data.id != null) { - core.debug(`Successfully committed ${res.data.id}`); - return Promise.resolve(res.data.id!); +async function uploadInternalSharingRelease(options: EditOptions, releaseFile: string): Promise { + if (releaseFile.endsWith('.apk')) { + const res = await internalSharingUploadApk(options, releaseFile) + 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) + console.log(`${releaseFile} uploaded to Internal Sharing, download it with ${res.downloadUrl}`) + return Promise.resolve(res.downloadUrl) } else { - core.setFailed(`Error ${res.status}: ${res.statusText}`); - return Promise.reject(res.status); + core.setFailed(`${releaseFile} is invalid`) + return Promise.reject(`${releaseFile} is invalid`) } } async function uploadRelease(appEdit: AppEdit, options: EditOptions, releaseFile: string): Promise { - // 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) - console.log(`${releaseFile} uploaded to Internal Sharing, download it with ${res.downloadUrl}`) - return Promise.resolve(undefined) - } else if (releaseFile.endsWith('.aab')) { - const res = await internalSharingUploadBundle(options, releaseFile) - console.log(`${releaseFile} uploaded to Internal Sharing, download it with ${res.downloadUrl}`) - return Promise.resolve(undefined) - } else { - core.setFailed(`${releaseFile} is invalid`) - return Promise.reject(`${releaseFile} is invalid`) - } - } - if (releaseFile.endsWith('.apk')) { const apk = await uploadApk(appEdit, options, releaseFile); await uploadMappingFile(appEdit, apk.versionCode!, options); From 84e140d18c3f7a5b314d81074ce29af0949c8fda Mon Sep 17 00:00:00 2001 From: "Jack Boswell (boswelja)" Date: Fri, 23 Oct 2020 16:29:23 +1300 Subject: [PATCH 15/26] Update README --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 869fbd1b..17c2ca5d 100644 --- a/README.md +++ b/README.md @@ -18,9 +18,9 @@ The service account json in plain text, provided via a secret, etc. **Required:** The package name, or Application Id, of the app you are uploading -### `releaseFile` +### `releaseFiles` -**Required:** The Android release file to upload (.apk or .aab) +**Required:** The Android release file(s) to upload (.apk or .aab). Multiple files are separated by ','. ### `track` From 23c3f21aa0f6fc04428c829b514c20b7346e536d Mon Sep 17 00:00:00 2001 From: "Jack Boswell (boswelja)" Date: Wed, 4 Nov 2020 21:18:33 +1300 Subject: [PATCH 16/26] Drop internal app sharing URL exporting for now --- src/main.ts | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/main.ts b/src/main.ts index 80ec6932..8e71ddd2 100644 --- a/src/main.ts +++ b/src/main.ts @@ -71,7 +71,7 @@ async function run() { const authClient = await auth.getClient(); - const downloadUrl = await uploadToPlayStore({ + await uploadToPlayStore({ auth: authClient, applicationId: packageName, track: track, @@ -80,11 +80,6 @@ async function run() { mappingFile: mappingFile }, releaseFiles); - if (downloadUrl) { - core.setOutput('internalSharingDownloadUrl', downloadUrl); - core.exportVariable('INTERNAL_SHARING_DOWNLOAD_URL', downloadUrl); - } - console.log(`Finished uploading to the Play Store`) } catch (error) { core.setFailed(error.message) From e219a80fabf89a7605698c9689bc7a1cecd962e0 Mon Sep 17 00:00:00 2001 From: "Jack Boswell (boswelja)" Date: Wed, 4 Nov 2020 21:33:08 +1300 Subject: [PATCH 17/26] Comment code a bit --- lib/edits.js | 8 +++++++- lib/main.js | 6 +----- src/edits.ts | 9 ++++++++- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/lib/edits.js b/lib/edits.js index eb907305..4c513f58 100644 --- a/lib/edits.js +++ b/lib/edits.js @@ -37,6 +37,7 @@ const whatsnew_1 = require("./whatsnew"); const androidPublisher = googleapis_1.google.androidpublisher('v3'); function uploadToPlayStore(options, releaseFiles) { return __awaiter(this, void 0, void 0, function* () { + // Check the 'track' for 'internalsharing', if so switch to a non-track api if (options.track === 'internalappsharing') { core.debug("Track is Internal app sharing, switch to special upload api"); releaseFiles.forEach((releaseFile) => __awaiter(this, void 0, void 0, function* () { @@ -48,15 +49,17 @@ function uploadToPlayStore(options, releaseFiles) { })); } else { + // Create a new Edit const appEdit = yield androidPublisher.edits.insert({ auth: options.auth, packageName: options.applicationId }); + // Validate the given track yield validateSelectedTrack(appEdit.data, options).catch(reason => { core.setFailed(reason); return Promise.reject(reason); }); - // Check the 'track' for 'internalsharing', if so switch to a non-track api + // Upload artifacts to Google Play, and store their version codes var versionCodes = new Array(); releaseFiles.forEach((releaseFile) => __awaiter(this, void 0, void 0, function* () { core.debug(`Uploading ${releaseFile}`); @@ -66,12 +69,15 @@ function uploadToPlayStore(options, releaseFiles) { }); versionCodes.push(versionCode); })); + // Add the uploaded artifacts to the Edit track const track = addReleasesToTrack(appEdit.data, options, versionCodes); + // Commit the pending Edit const res = yield androidPublisher.edits.commit({ auth: options.auth, editId: appEdit.data.id, packageName: options.applicationId }); + // Simple check to see whether commit was successful if (res.data.id != null) { core.debug(`Successfully committed ${res.data.id}`); return Promise.resolve(res.data.id); diff --git a/lib/main.js b/lib/main.js index 4b0a2759..1ab7a519 100644 --- a/lib/main.js +++ b/lib/main.js @@ -91,7 +91,7 @@ function run() { return; } const authClient = yield auth.getClient(); - const downloadUrl = yield edits_1.uploadToPlayStore({ + yield edits_1.uploadToPlayStore({ auth: authClient, applicationId: packageName, track: track, @@ -99,10 +99,6 @@ function run() { whatsNewDir: whatsNewDir, mappingFile: mappingFile }, releaseFiles); - if (downloadUrl) { - core.setOutput('internalSharingDownloadUrl', downloadUrl); - core.exportVariable('INTERNAL_SHARING_DOWNLOAD_URL', downloadUrl); - } console.log(`Finished uploading to the Play Store`); } catch (error) { diff --git a/src/edits.ts b/src/edits.ts index d517c92c..5f57ecfd 100644 --- a/src/edits.ts +++ b/src/edits.ts @@ -28,6 +28,7 @@ export interface EditOptions { } export async function uploadToPlayStore(options: EditOptions, releaseFiles: string[]): Promise { + // Check the 'track' for 'internalsharing', if so switch to a non-track api if (options.track === 'internalappsharing') { core.debug("Track is Internal app sharing, switch to special upload api") releaseFiles.forEach(async releaseFile => { @@ -38,17 +39,19 @@ export async function uploadToPlayStore(options: EditOptions, releaseFiles: stri }); }); } else { + // Create a new Edit const appEdit = await androidPublisher.edits.insert({ auth: options.auth, packageName: options.applicationId }); + // Validate the given track await validateSelectedTrack(appEdit.data, options).catch(reason => { core.setFailed(reason); return Promise.reject(reason); }); - // Check the 'track' for 'internalsharing', if so switch to a non-track api + // Upload artifacts to Google Play, and store their version codes var versionCodes = new Array(); releaseFiles.forEach(async releaseFile => { core.debug(`Uploading ${releaseFile}`); @@ -59,13 +62,17 @@ export async function uploadToPlayStore(options: EditOptions, releaseFiles: stri versionCodes.push(versionCode!); }); + // Add the uploaded artifacts to the Edit track const track = addReleasesToTrack(appEdit.data, options, versionCodes); + + // Commit the pending Edit const res = await androidPublisher.edits.commit({ auth: options.auth, editId: appEdit.data.id!, packageName: options.applicationId }); + // Simple check to see whether commit was successful if (res.data.id != null) { core.debug(`Successfully committed ${res.data.id}`); return Promise.resolve(res.data.id!); From 1d8ec1dc086f04e268f96baec121e7323bf2d665 Mon Sep 17 00:00:00 2001 From: "Jack Boswell (boswelja)" Date: Thu, 5 Nov 2020 10:14:33 +1300 Subject: [PATCH 18/26] Fix internal sharing branch name --- lib/edits.js | 2 +- src/edits.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/edits.js b/lib/edits.js index 4c513f58..736b20e4 100644 --- a/lib/edits.js +++ b/lib/edits.js @@ -38,7 +38,7 @@ const androidPublisher = googleapis_1.google.androidpublisher('v3'); function uploadToPlayStore(options, releaseFiles) { return __awaiter(this, void 0, void 0, function* () { // Check the 'track' for 'internalsharing', if so switch to a non-track api - if (options.track === 'internalappsharing') { + if (options.track === 'internalsharing') { core.debug("Track is Internal app sharing, switch to special upload api"); releaseFiles.forEach((releaseFile) => __awaiter(this, void 0, void 0, function* () { core.debug(`Uploading ${releaseFile}`); diff --git a/src/edits.ts b/src/edits.ts index 5f57ecfd..2f3d917d 100644 --- a/src/edits.ts +++ b/src/edits.ts @@ -29,7 +29,7 @@ export interface EditOptions { export async function uploadToPlayStore(options: EditOptions, releaseFiles: string[]): Promise { // Check the 'track' for 'internalsharing', if so switch to a non-track api - if (options.track === 'internalappsharing') { + if (options.track === 'internalsharing') { core.debug("Track is Internal app sharing, switch to special upload api") releaseFiles.forEach(async releaseFile => { core.debug(`Uploading ${releaseFile}`); From b88b48212e1363ac6c587d232676006925e49881 Mon Sep 17 00:00:00 2001 From: "Jack Boswell (boswelja)" Date: Thu, 5 Nov 2020 10:17:49 +1300 Subject: [PATCH 19/26] Fix artifact uploads possibly occurring after committing the edit --- src/edits.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/edits.ts b/src/edits.ts index 2f3d917d..11d7a77e 100644 --- a/src/edits.ts +++ b/src/edits.ts @@ -31,13 +31,13 @@ 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") - releaseFiles.forEach(async releaseFile => { + for (const releaseFile in releaseFiles) { core.debug(`Uploading ${releaseFile}`); await uploadInternalSharingRelease(options, releaseFile).catch(reason => { core.setFailed(reason); return Promise.reject(reason); }); - }); + } } else { // Create a new Edit const appEdit = await androidPublisher.edits.insert({ @@ -53,14 +53,14 @@ export async function uploadToPlayStore(options: EditOptions, releaseFiles: stri // Upload artifacts to Google Play, and store their version codes var versionCodes = new Array(); - releaseFiles.forEach(async releaseFile => { + for (const releaseFile in releaseFiles) { core.debug(`Uploading ${releaseFile}`); const versionCode = await uploadRelease(appEdit.data, options, releaseFile).catch(reason => { core.setFailed(reason); return Promise.reject(reason); }); versionCodes.push(versionCode!); - }); + } // Add the uploaded artifacts to the Edit track const track = addReleasesToTrack(appEdit.data, options, versionCodes); From a0b5e05df44cb87a7ea360a1bb280c40b47a5354 Mon Sep 17 00:00:00 2001 From: "Jack Boswell (boswelja)" Date: Thu, 5 Nov 2020 11:43:31 +1300 Subject: [PATCH 20/26] Add missing await to track setup --- src/edits.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/edits.ts b/src/edits.ts index 11d7a77e..58406e5c 100644 --- a/src/edits.ts +++ b/src/edits.ts @@ -63,7 +63,7 @@ export async function uploadToPlayStore(options: EditOptions, releaseFiles: stri } // Add the uploaded artifacts to the Edit track - const track = addReleasesToTrack(appEdit.data, options, versionCodes); + const track = await addReleasesToTrack(appEdit.data, options, versionCodes); // Commit the pending Edit const res = await androidPublisher.edits.commit({ From d2ed26efd5b802094973cbe68aeada9ce70224d0 Mon Sep 17 00:00:00 2001 From: "Jack Boswell (boswelja)" Date: Thu, 5 Nov 2020 11:47:39 +1300 Subject: [PATCH 21/26] Build latest changes Forgot to do this before --- lib/edits.js | 10 +++++----- src/edits.ts | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/edits.js b/lib/edits.js index 736b20e4..7a36c7fd 100644 --- a/lib/edits.js +++ b/lib/edits.js @@ -40,13 +40,13 @@ 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"); - releaseFiles.forEach((releaseFile) => __awaiter(this, void 0, void 0, function* () { + for (const releaseFile in releaseFiles) { core.debug(`Uploading ${releaseFile}`); yield uploadInternalSharingRelease(options, releaseFile).catch(reason => { core.setFailed(reason); return Promise.reject(reason); }); - })); + } } else { // Create a new Edit @@ -61,16 +61,16 @@ function uploadToPlayStore(options, releaseFiles) { }); // Upload artifacts to Google Play, and store their version codes var versionCodes = new Array(); - releaseFiles.forEach((releaseFile) => __awaiter(this, void 0, void 0, function* () { + for (const releaseFile in releaseFiles) { core.debug(`Uploading ${releaseFile}`); const versionCode = yield uploadRelease(appEdit.data, options, releaseFile).catch(reason => { core.setFailed(reason); return Promise.reject(reason); }); versionCodes.push(versionCode); - })); + } // Add the uploaded artifacts to the Edit track - const track = addReleasesToTrack(appEdit.data, options, versionCodes); + const track = yield addReleasesToTrack(appEdit.data, options, versionCodes); // Commit the pending Edit const res = yield androidPublisher.edits.commit({ auth: options.auth, diff --git a/src/edits.ts b/src/edits.ts index 58406e5c..e652d297 100644 --- a/src/edits.ts +++ b/src/edits.ts @@ -44,13 +44,13 @@ export async function uploadToPlayStore(options: EditOptions, releaseFiles: stri auth: options.auth, packageName: options.applicationId }); - + // Validate the given 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(); for (const releaseFile in releaseFiles) { @@ -61,7 +61,7 @@ export async function uploadToPlayStore(options: EditOptions, releaseFiles: stri }); versionCodes.push(versionCode!); } - + // Add the uploaded artifacts to the Edit track const track = await addReleasesToTrack(appEdit.data, options, versionCodes); @@ -71,7 +71,7 @@ export async function uploadToPlayStore(options: EditOptions, releaseFiles: stri editId: appEdit.data.id!, packageName: options.applicationId }); - + // Simple check to see whether commit was successful if (res.data.id != null) { core.debug(`Successfully committed ${res.data.id}`); From cdd4e28c7197ca738e6d07af4023b1e481b4f766 Mon Sep 17 00:00:00 2001 From: "Jack Boswell (boswelja)" Date: Thu, 5 Nov 2020 19:16:32 +1300 Subject: [PATCH 22/26] Remove setFailed calls from functionsThese are handled in the catch block on each call in uploadToPlayStore --- lib/edits.js | 7 ++----- src/edits.ts | 7 ++----- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/lib/edits.js b/lib/edits.js index 7a36c7fd..4709b179 100644 --- a/lib/edits.js +++ b/lib/edits.js @@ -103,7 +103,6 @@ function uploadInternalSharingRelease(options, releaseFile) { return Promise.resolve(res.downloadUrl); } else { - core.setFailed(`${releaseFile} is invalid`); return Promise.reject(`${releaseFile} is invalid`); } }); @@ -121,7 +120,6 @@ function uploadRelease(appEdit, options, releaseFile) { return Promise.resolve(bundle.versionCode); } else { - core.setFailed(`${releaseFile} is invalid`); return Promise.reject(`${releaseFile} is invalid`); } }); @@ -135,8 +133,7 @@ function validateSelectedTrack(appEdit, options) { }); const allTracks = res.data.tracks; 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}"`); + return Promise.reject(`Track "${options.track}" could not be found `); } }); } @@ -163,7 +160,7 @@ function addReleasesToTrack(appEdit, options, versionCodes) { userFraction: options.userFraction, status: status, releaseNotes: yield whatsnew_1.readLocalizedReleaseNotes(options.whatsNewDir), - versionCodes: versionCodes.map(x => x.toString()) + versionCodes: versionCodes.filter(x => x != 0).map(x => x.toString()) } ] } diff --git a/src/edits.ts b/src/edits.ts index e652d297..f3634291 100644 --- a/src/edits.ts +++ b/src/edits.ts @@ -93,7 +93,6 @@ async function uploadInternalSharingRelease(options: EditOptions, releaseFile: s console.log(`${releaseFile} uploaded to Internal Sharing, download it with ${res.downloadUrl}`) return Promise.resolve(res.downloadUrl) } else { - core.setFailed(`${releaseFile} is invalid`) return Promise.reject(`${releaseFile} is invalid`) } } @@ -108,7 +107,6 @@ async function uploadRelease(appEdit: AppEdit, options: EditOptions, releaseFile await uploadMappingFile(appEdit, bundle.versionCode!, options); return Promise.resolve(bundle.versionCode); } else { - core.setFailed(`${releaseFile} is invalid`); return Promise.reject(`${releaseFile} is invalid`); } } @@ -121,8 +119,7 @@ async function validateSelectedTrack(appEdit: AppEdit, options: EditOptions): Pr }); const allTracks = res.data.tracks; 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}"`); + return Promise.reject(`Track "${options.track}" could not be found `); } } @@ -148,7 +145,7 @@ async function addReleasesToTrack(appEdit: AppEdit, options: EditOptions, versio userFraction: options.userFraction, status: status, releaseNotes: await readLocalizedReleaseNotes(options.whatsNewDir), - versionCodes: versionCodes.map(x => x.toString()) + versionCodes: versionCodes.filter(x => x != 0).map(x => x.toString()) } ] } From d522a8f9de385923b75ab4069f2b15ab995ef011 Mon Sep 17 00:00:00 2001 From: "Jack Boswell (boswelja)" Date: Fri, 6 Nov 2020 20:44:43 +1300 Subject: [PATCH 23/26] Convert last forEach call to a for loop --- lib/main.js | 4 ++-- src/main.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/main.js b/lib/main.js index 1ab7a519..e05d19b2 100644 --- a/lib/main.js +++ b/lib/main.js @@ -76,12 +76,12 @@ function run() { userFractionFloat = undefined; } // Check release files - releaseFiles.forEach(releaseFile => { + for (const releaseFile in releaseFiles) { 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; diff --git a/src/main.ts b/src/main.ts index 8e71ddd2..a84f8e89 100644 --- a/src/main.ts +++ b/src/main.ts @@ -52,12 +52,12 @@ async function run() { } // Check release files - releaseFiles.forEach(releaseFile => { + for (const releaseFile in releaseFiles) { 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}`); From 381598c5197a29356ebea67d7466f163341c0989 Mon Sep 17 00:00:00 2001 From: "Jack Boswell (boswelja)" Date: Tue, 10 Nov 2020 13:13:48 +1300 Subject: [PATCH 24/26] Add debug output to show what releaseFiles the script interpreted from input --- lib/main.js | 1 + src/main.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/lib/main.js b/lib/main.js index e05d19b2..fa0c5f66 100644 --- a/lib/main.js +++ b/lib/main.js @@ -76,6 +76,7 @@ function run() { userFractionFloat = undefined; } // Check release files + core.debug(`Checking release files ${releaseFiles}`); for (const releaseFile in releaseFiles) { if (!fs.existsSync(releaseFile)) { core.setFailed(`Unable to find release file @ ${releaseFile}`); diff --git a/src/main.ts b/src/main.ts index a84f8e89..61c5d92a 100644 --- a/src/main.ts +++ b/src/main.ts @@ -52,6 +52,7 @@ async function run() { } // Check release files + core.debug(`Checking release files ${releaseFiles}`); for (const releaseFile in releaseFiles) { if (!fs.existsSync(releaseFile)) { core.setFailed(`Unable to find release file @ ${releaseFile}`); From 651ca992ef82bd080f612c3d59606aed28f05e14 Mon Sep 17 00:00:00 2001 From: "Jack Boswell (boswelja)" Date: Tue, 10 Nov 2020 18:11:35 +1300 Subject: [PATCH 25/26] More debug logging for release file validation --- lib/main.js | 1 + src/main.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/lib/main.js b/lib/main.js index fa0c5f66..8493b1bd 100644 --- a/lib/main.js +++ b/lib/main.js @@ -78,6 +78,7 @@ function run() { // Check release files core.debug(`Checking release files ${releaseFiles}`); for (const releaseFile in releaseFiles) { + core.debug(`Validating ${releaseFile} exists`); if (!fs.existsSync(releaseFile)) { core.setFailed(`Unable to find release file @ ${releaseFile}`); return; diff --git a/src/main.ts b/src/main.ts index 61c5d92a..0aa4343a 100644 --- a/src/main.ts +++ b/src/main.ts @@ -54,6 +54,7 @@ async function run() { // Check release files core.debug(`Checking release files ${releaseFiles}`); for (const releaseFile in releaseFiles) { + core.debug(`Validating ${releaseFile} exists`) if (!fs.existsSync(releaseFile)) { core.setFailed(`Unable to find release file @ ${releaseFile}`); return From 308a7485f233ca23e1ed35d624af7800643df0d8 Mon Sep 17 00:00:00 2001 From: "Jack Boswell (boswelja)" Date: Tue, 10 Nov 2020 18:44:09 +1300 Subject: [PATCH 26/26] Try using for/of instead of for/in --- lib/edits.js | 4 ++-- lib/main.js | 3 +-- src/edits.ts | 4 ++-- src/main.ts | 3 +-- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/lib/edits.js b/lib/edits.js index 4709b179..69ee329b 100644 --- a/lib/edits.js +++ b/lib/edits.js @@ -40,7 +40,7 @@ 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"); - for (const releaseFile in releaseFiles) { + for (const releaseFile of releaseFiles) { core.debug(`Uploading ${releaseFile}`); yield uploadInternalSharingRelease(options, releaseFile).catch(reason => { core.setFailed(reason); @@ -61,7 +61,7 @@ function uploadToPlayStore(options, releaseFiles) { }); // Upload artifacts to Google Play, and store their version codes var versionCodes = new Array(); - for (const releaseFile in releaseFiles) { + for (const releaseFile of releaseFiles) { core.debug(`Uploading ${releaseFile}`); const versionCode = yield uploadRelease(appEdit.data, options, releaseFile).catch(reason => { core.setFailed(reason); diff --git a/lib/main.js b/lib/main.js index 8493b1bd..6c8cd1c7 100644 --- a/lib/main.js +++ b/lib/main.js @@ -76,8 +76,7 @@ function run() { userFractionFloat = undefined; } // Check release files - core.debug(`Checking release files ${releaseFiles}`); - for (const releaseFile in releaseFiles) { + for (const releaseFile of releaseFiles) { core.debug(`Validating ${releaseFile} exists`); if (!fs.existsSync(releaseFile)) { core.setFailed(`Unable to find release file @ ${releaseFile}`); diff --git a/src/edits.ts b/src/edits.ts index f3634291..7d65e414 100644 --- a/src/edits.ts +++ b/src/edits.ts @@ -31,7 +31,7 @@ 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") - for (const releaseFile in releaseFiles) { + for (const releaseFile of releaseFiles) { core.debug(`Uploading ${releaseFile}`); await uploadInternalSharingRelease(options, releaseFile).catch(reason => { core.setFailed(reason); @@ -53,7 +53,7 @@ export async function uploadToPlayStore(options: EditOptions, releaseFiles: stri // Upload artifacts to Google Play, and store their version codes var versionCodes = new Array(); - for (const releaseFile in releaseFiles) { + for (const releaseFile of releaseFiles) { core.debug(`Uploading ${releaseFile}`); const versionCode = await uploadRelease(appEdit.data, options, releaseFile).catch(reason => { core.setFailed(reason); diff --git a/src/main.ts b/src/main.ts index 0aa4343a..774316ee 100644 --- a/src/main.ts +++ b/src/main.ts @@ -52,8 +52,7 @@ async function run() { } // Check release files - core.debug(`Checking release files ${releaseFiles}`); - for (const releaseFile in releaseFiles) { + for (const releaseFile of releaseFiles) { core.debug(`Validating ${releaseFile} exists`) if (!fs.existsSync(releaseFile)) { core.setFailed(`Unable to find release file @ ${releaseFile}`);