test if version upgraded: Beta release independent from regular release

This commit is contained in:
garronej 2022-08-02 14:19:50 +02:00
parent 66b83c9642
commit 6a267b716c
4 changed files with 52 additions and 21 deletions

View file

@ -1,24 +1,24 @@
import { listTagsFactory } from "./listTags";
import type { Octokit } from "@octokit/rest";
import { NpmModuleVersion } from "../NpmModuleVersion";
import { NpmModuleVersion } from "../NpmModuleVersion";
export function getLatestSemVersionedTagFactory(params: { octokit: Octokit; }) {
const { octokit } = params;
async function getLatestSemVersionedTag(
params: {
owner: string;
repo: string;
doIgnoreBeta: boolean;
params: {
owner: string;
repo: string;
beta: "ONLY LOOK FOR BETA" | "IGNORE BETA" | "BETA OR REGULAR RELEASE";
}
): Promise<{
tag: string;
version: NpmModuleVersion;
): Promise<{
tag: string;
version: NpmModuleVersion;
} | undefined> {
const { owner, repo, doIgnoreBeta } = params;
const { owner, repo, beta } = params;
const semVersionedTags: { tag: string; version: NpmModuleVersion; }[] = [];
@ -28,16 +28,26 @@ export function getLatestSemVersionedTagFactory(params: { octokit: Octokit; }) {
let version: NpmModuleVersion;
try{
try {
version = NpmModuleVersion.parse(tag.replace(/^[vV]?/, ""));
}catch{
} catch {
continue;
}
if( doIgnoreBeta && version.betaPreRelease !== undefined ){
continue;
switch (beta) {
case "IGNORE BETA":
if (version.betaPreRelease !== undefined) {
continue;
}
break;
case "ONLY LOOK FOR BETA":
if (version.betaPreRelease === undefined) {
continue;
}
case "BETA OR REGULAR RELEASE":
break;
}
semVersionedTags.push({ tag, version });