Fixed #1 - Fixed the whatsnew-** script for loading release notes into builds

Added test to ensure that release notes are parsed properly
Updated to latest dependencies to fix security vulnerability
Updated GH Actions Workflow to run test before updating tag
Updated README.md to reflect proper whatsnew documentation.
This commit is contained in:
Drew Heavner
2020-01-30 11:14:51 -05:00
parent b6496ac4e3
commit bdde081050
2660 changed files with 251487 additions and 213182 deletions

View File

@@ -9,12 +9,11 @@ import AndroidPublisher = androidpublisher_v3.Androidpublisher;
import AppEdit = androidpublisher_v3.Schema$AppEdit;
import Apk = androidpublisher_v3.Schema$Apk;
import Bundle = androidpublisher_v3.Schema$Bundle;
import LocalizedText = androidpublisher_v3.Schema$LocalizedText;
import Track = androidpublisher_v3.Schema$Track;
import {Compute} from "google-auth-library/build/src/auth/computeclient";
import {JWT} from "google-auth-library/build/src/auth/jwtclient";
import {UserRefreshClient} from "google-auth-library/build/src/auth/refreshclient";
import {readLocalizedReleaseNotes} from "./whatsnew";
const androidPublisher: AndroidPublisher = google.androidpublisher('v3');
@@ -105,36 +104,6 @@ async function trackVersionCode(appEdit: AppEdit, options: EditOptions, versionC
return res.data
}
async function readLocalizedReleaseNotes(whatsNewDir: string | undefined): Promise<LocalizedText[] | undefined> {
if (whatsNewDir != undefined && whatsNewDir.length > 0) {
const releaseNotes = fs.readdirSync(whatsNewDir).filter(value => /whatsnew-*-*/.test(value));
const pattern = /whatsnew-(?<local>.*-.*)/.compile();
let localizedReleaseNotes: LocalizedText[] = [];
releaseNotes.forEach(value => {
const matches = value.match(pattern);
if (matches != undefined && matches.length == 2) {
const lang = matches[1];
const content = readFileSync(value, 'utf-8');
if (content != undefined) {
core.debug(`Found localized 'whatsnew-*-*' for Lang(${lang})`);
localizedReleaseNotes.push(
{
language: lang,
text: content
}
)
}
}
});
return localizedReleaseNotes
}
return undefined
}
async function uploadMappingFile(appEdit: AppEdit, versionCode: number, options: EditOptions) {
if (options.mappingFile != undefined && options.mappingFile.length > 0) {
const mapping = readFileSync(options.mappingFile, 'utf-8');

40
src/whatsnew.ts Normal file
View File

@@ -0,0 +1,40 @@
import * as core from '@actions/core';
import * as fs from "fs";
import * as path from "path";
import {readFileSync} from "fs";
import {androidpublisher_v3} from "googleapis";
import LocalizedText = androidpublisher_v3.Schema$LocalizedText;
export async function readLocalizedReleaseNotes(whatsNewDir: string | undefined): Promise<LocalizedText[] | undefined> {
if (whatsNewDir != undefined && whatsNewDir.length > 0) {
const releaseNotes = fs.readdirSync(whatsNewDir)
.filter(value => /whatsnew-.*-.{2}\b/.test(value));
const pattern = /whatsnew-(?<local>.*-.*)/;
let localizedReleaseNotes: LocalizedText[] = [];
core.debug(`Found files: ${releaseNotes}`);
releaseNotes.forEach(value => {
const matches = value.match(pattern);
core.debug(`Matches for ${value} = ${matches}`);
if (matches != undefined && matches.length == 2) {
const lang = matches[1];
const filePath = path.join(whatsNewDir, value);
const content = readFileSync(filePath, 'utf-8');
if (content != undefined) {
core.debug(`Found localized 'whatsnew-*-*' for Lang(${lang})`);
localizedReleaseNotes.push(
{
language: lang,
text: content
}
)
}
}
});
return localizedReleaseNotes
}
return undefined
}