mirror of
https://github.com/garronej/ts-ci.git
synced 2025-11-30 21:43:05 +00:00
Use rc instead of beta
This commit is contained in:
parent
c9d3057053
commit
a75bdd36de
7 changed files with 57 additions and 57 deletions
|
|
@ -24,7 +24,7 @@ type CoreLike = {
|
|||
debug: (message: string) => void;
|
||||
};
|
||||
|
||||
export const { setOutput } = setOutputFactory<"from_version" | "to_version" | "is_upgraded_version" | "is_release_beta">();
|
||||
export const { setOutput } = setOutputFactory<"from_version" | "to_version" | "is_upgraded_version" | "is_pre_release">();
|
||||
|
||||
export async function action(
|
||||
_actionName: "is_package_json_version_upgraded",
|
||||
|
|
@ -59,8 +59,8 @@ export async function action(
|
|||
const getLatestSemVersionedTagParam: Param0<typeof getLatestSemVersionedTag> = {
|
||||
owner,
|
||||
repo,
|
||||
"beta": to_version.betaPreRelease !== undefined ?
|
||||
"ONLY LOOK FOR BETA" : "IGNORE BETA",
|
||||
"rcPolicy": to_version.rc !== undefined ?
|
||||
"ONLY LOOK FOR RC" : "IGNORE RC",
|
||||
"major": to_version.major
|
||||
};
|
||||
|
||||
|
|
@ -89,15 +89,15 @@ export async function action(
|
|||
|
||||
core.debug(`Is version upgraded: ${is_upgraded_version}`);
|
||||
|
||||
const is_release_beta = is_upgraded_version === "false" ? "false" : to_version.betaPreRelease !== undefined ? "true" : "false";
|
||||
const is_pre_release = is_upgraded_version === "false" ? "false" : to_version.rc !== undefined ? "true" : "false";
|
||||
|
||||
core.debug(`Is release beta: ${is_release_beta}`);
|
||||
core.debug(`Is pre release: ${is_pre_release}`);
|
||||
|
||||
return {
|
||||
"to_version": NpmModuleVersion.stringify(to_version),
|
||||
"from_version": NpmModuleVersion.stringify(from_version),
|
||||
is_upgraded_version,
|
||||
is_release_beta
|
||||
is_pre_release
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ export const outputNames = [
|
|||
"from_version",
|
||||
"to_version",
|
||||
"is_upgraded_version",
|
||||
"is_release_beta"
|
||||
"is_pre_release"
|
||||
] as const;
|
||||
|
||||
|
||||
|
|
@ -35,7 +35,7 @@ export function getOutputDescription(inputName: typeof outputNames[number]): str
|
|||
case "from_version": return "Output of is_package_json_version_upgraded, string";
|
||||
case "to_version": return "Output of is_package_json_version_upgraded, string";
|
||||
case "is_upgraded_version": return "Output of is_package_json_version_upgraded, true|false";
|
||||
case "is_release_beta": return "Output of is_package_json_version_upgraded, true|false";
|
||||
case "is_pre_release": return "Output of is_package_json_version_upgraded, true|false";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,14 +4,14 @@ export type NpmModuleVersion = {
|
|||
major: number;
|
||||
minor: number;
|
||||
patch: number;
|
||||
betaPreRelease?: number;
|
||||
rc?: number;
|
||||
};
|
||||
|
||||
export namespace NpmModuleVersion {
|
||||
|
||||
export function parse(versionStr: string): NpmModuleVersion {
|
||||
|
||||
const match = versionStr.match(/^([0-9]+)\.([0-9]+)\.([0-9]+)(?:-beta.([0-9]+))?/);
|
||||
const match = versionStr.match(/^([0-9]+)\.([0-9]+)\.([0-9]+)(?:-rc.([0-9]+))?/);
|
||||
|
||||
if (!match) {
|
||||
throw new Error(`${versionStr} is not a valid NPM version`);
|
||||
|
|
@ -26,7 +26,7 @@ export namespace NpmModuleVersion {
|
|||
const str = match[4];
|
||||
return str === undefined ?
|
||||
{} :
|
||||
{ "betaPreRelease": parseInt(str) };
|
||||
{ "rc": parseInt(str) };
|
||||
|
||||
})()
|
||||
};
|
||||
|
|
@ -34,7 +34,7 @@ export namespace NpmModuleVersion {
|
|||
};
|
||||
|
||||
export function stringify(v: NpmModuleVersion) {
|
||||
return `${v.major}.${v.minor}.${v.patch}${v.betaPreRelease === undefined ? "" : `-beta.${v.betaPreRelease}`}`;
|
||||
return `${v.major}.${v.minor}.${v.patch}${v.rc === undefined ? "" : `-rc.${v.rc}`}`;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -49,7 +49,7 @@ export namespace NpmModuleVersion {
|
|||
const sign = (diff: number): -1 | 0 | 1 => diff === 0 ? 0 : (diff < 0 ? -1 : 1);
|
||||
const noUndefined= (n: number | undefined)=> n ?? Infinity;
|
||||
|
||||
for (const level of ["major", "minor", "patch", "betaPreRelease"] as const) {
|
||||
for (const level of ["major", "minor", "patch", "rc"] as const) {
|
||||
if (noUndefined(v1[level]) !== noUndefined(v2[level])) {
|
||||
return sign(noUndefined(v1[level]) - noUndefined(v2[level]));
|
||||
}
|
||||
|
|
@ -60,9 +60,9 @@ export namespace NpmModuleVersion {
|
|||
}
|
||||
|
||||
/*
|
||||
console.log(compare(parse("3.0.0-beta.3"), parse("3.0.0")) === -1 )
|
||||
console.log(compare(parse("3.0.0-beta.3"), parse("3.0.0-beta.4")) === -1 )
|
||||
console.log(compare(parse("3.0.0-beta.3"), parse("4.0.0")) === -1 )
|
||||
console.log(compare(parse("3.0.0-rc.3"), parse("3.0.0")) === -1 )
|
||||
console.log(compare(parse("3.0.0-rc.3"), parse("3.0.0-rc.4")) === -1 )
|
||||
console.log(compare(parse("3.0.0-rc.3"), parse("4.0.0")) === -1 )
|
||||
*/
|
||||
|
||||
export function bumpType(
|
||||
|
|
@ -70,7 +70,7 @@ export namespace NpmModuleVersion {
|
|||
versionBehindStr: string;
|
||||
versionAheadStr: string;
|
||||
}
|
||||
): "major" | "minor" | "patch" | "betaPreRelease" | "same" {
|
||||
): "major" | "minor" | "patch" | "rc" | "same" {
|
||||
|
||||
|
||||
const versionAhead = parse(params.versionAheadStr);
|
||||
|
|
@ -80,7 +80,7 @@ export namespace NpmModuleVersion {
|
|||
throw new Error(`Version regression ${versionBehind} -> ${versionAhead}`);
|
||||
}
|
||||
|
||||
for (const level of ["major", "minor", "patch", "betaPreRelease"] as const) {
|
||||
for (const level of ["major", "minor", "patch", "rc"] as const) {
|
||||
if (versionBehind[level] !== versionAhead[level]) {
|
||||
return level;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ export function getLatestSemVersionedTagFactory(params: { octokit: Octokit; }) {
|
|||
params: {
|
||||
owner: string;
|
||||
repo: string;
|
||||
beta: "ONLY LOOK FOR BETA" | "IGNORE BETA" | "BETA OR REGULAR RELEASE";
|
||||
rcPolicy: "ONLY LOOK FOR RC" | "IGNORE RC" | "RC OR REGULAR RELEASE";
|
||||
major: number | undefined;
|
||||
}
|
||||
): Promise<{
|
||||
|
|
@ -19,7 +19,7 @@ export function getLatestSemVersionedTagFactory(params: { octokit: Octokit; }) {
|
|||
version: NpmModuleVersion;
|
||||
} | undefined> {
|
||||
|
||||
const { owner, repo, beta, major } = params;
|
||||
const { owner, repo, rcPolicy, major } = params;
|
||||
|
||||
const semVersionedTags: { tag: string; version: NpmModuleVersion; }[] = [];
|
||||
|
||||
|
|
@ -41,17 +41,17 @@ export function getLatestSemVersionedTagFactory(params: { octokit: Octokit; }) {
|
|||
continue;
|
||||
}
|
||||
|
||||
switch (beta) {
|
||||
case "IGNORE BETA":
|
||||
if (version.betaPreRelease !== undefined) {
|
||||
switch (rcPolicy) {
|
||||
case "IGNORE RC":
|
||||
if (version.rc !== undefined) {
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
case "ONLY LOOK FOR BETA":
|
||||
if (version.betaPreRelease === undefined) {
|
||||
case "ONLY LOOK FOR RC":
|
||||
if (version.rc === undefined) {
|
||||
continue;
|
||||
}
|
||||
case "BETA OR REGULAR RELEASE":
|
||||
case "RC OR REGULAR RELEASE":
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ export async function action(
|
|||
|
||||
const { getLatestSemVersionedTag } = getLatestSemVersionedTagFactory({ octokit });
|
||||
|
||||
const { tag: branchBehind } = (await getLatestSemVersionedTag({ owner, repo, "beta": "IGNORE BETA", "major": undefined })) ?? {};
|
||||
const { tag: branchBehind } = (await getLatestSemVersionedTag({ owner, repo, "rcPolicy": "IGNORE RC", "major": undefined })) ?? {};
|
||||
|
||||
if( branchBehind === undefined ){
|
||||
|
||||
|
|
@ -101,9 +101,9 @@ export async function action(
|
|||
)
|
||||
);
|
||||
|
||||
if( NpmModuleVersion.parse(branchAheadVersion).betaPreRelease !== undefined ){
|
||||
if( NpmModuleVersion.parse(branchAheadVersion).rc !== undefined ){
|
||||
|
||||
core.warning(`Version on ${branch} is ${branchAheadVersion} it's a beta release, we do not update the CHANGELOG.md`);
|
||||
core.warning(`Version on ${branch} is ${branchAheadVersion} it's a release candidate, we do not update the CHANGELOG.md`);
|
||||
|
||||
return;
|
||||
|
||||
|
|
@ -114,7 +114,7 @@ export async function action(
|
|||
"versionBehindStr": branchBehindVersion || "0.0.0"
|
||||
});
|
||||
|
||||
assert(bumpType !== "betaPreRelease");
|
||||
assert(bumpType !== "rc");
|
||||
|
||||
if( bumpType === "same" ){
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue