Use rc instead of beta

This commit is contained in:
garronej 2022-10-11 16:50:23 +02:00
parent c9d3057053
commit a75bdd36de
7 changed files with 57 additions and 57 deletions

View file

@ -77,7 +77,7 @@ outputs:
description: 'Output of is_package_json_version_upgraded, string' description: 'Output of is_package_json_version_upgraded, string'
is_upgraded_version: is_upgraded_version:
description: 'Output of is_package_json_version_upgraded, true|false' description: 'Output of is_package_json_version_upgraded, true|false'
is_release_beta: is_pre_release:
description: 'Output of is_package_json_version_upgraded, true|false' description: 'Output of is_package_json_version_upgraded, true|false'
runs: runs:
using: 'node16' using: 'node16'

52
dist/index.js vendored
View file

@ -5420,7 +5420,7 @@ exports.NpmModuleVersion = void 0;
var NpmModuleVersion; var NpmModuleVersion;
(function (NpmModuleVersion) { (function (NpmModuleVersion) {
function parse(versionStr) { function parse(versionStr) {
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) { if (!match) {
throw new Error(`${versionStr} is not a valid NPM version`); throw new Error(`${versionStr} is not a valid NPM version`);
} }
@ -5428,13 +5428,13 @@ var NpmModuleVersion;
const str = match[4]; const str = match[4];
return str === undefined ? return str === undefined ?
{} : {} :
{ "betaPreRelease": parseInt(str) }; { "rc": parseInt(str) };
})()); })());
} }
NpmModuleVersion.parse = parse; NpmModuleVersion.parse = parse;
; ;
function stringify(v) { function stringify(v) {
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}`}`;
} }
NpmModuleVersion.stringify = stringify; NpmModuleVersion.stringify = stringify;
/** /**
@ -5447,7 +5447,7 @@ var NpmModuleVersion;
function compare(v1, v2) { function compare(v1, v2) {
const sign = (diff) => diff === 0 ? 0 : (diff < 0 ? -1 : 1); const sign = (diff) => diff === 0 ? 0 : (diff < 0 ? -1 : 1);
const noUndefined = (n) => n !== null && n !== void 0 ? n : Infinity; const noUndefined = (n) => n !== null && n !== void 0 ? n : Infinity;
for (const level of ["major", "minor", "patch", "betaPreRelease"]) { for (const level of ["major", "minor", "patch", "rc"]) {
if (noUndefined(v1[level]) !== noUndefined(v2[level])) { if (noUndefined(v1[level]) !== noUndefined(v2[level])) {
return sign(noUndefined(v1[level]) - noUndefined(v2[level])); return sign(noUndefined(v1[level]) - noUndefined(v2[level]));
} }
@ -5456,9 +5456,9 @@ var NpmModuleVersion;
} }
NpmModuleVersion.compare = compare; NpmModuleVersion.compare = compare;
/* /*
console.log(compare(parse("3.0.0-beta.3"), parse("3.0.0")) === -1 ) console.log(compare(parse("3.0.0-rc.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-rc.3"), parse("3.0.0-rc.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("4.0.0")) === -1 )
*/ */
function bumpType(params) { function bumpType(params) {
const versionAhead = parse(params.versionAheadStr); const versionAhead = parse(params.versionAheadStr);
@ -5466,7 +5466,7 @@ var NpmModuleVersion;
if (compare(versionBehind, versionAhead) === 1) { if (compare(versionBehind, versionAhead) === 1) {
throw new Error(`Version regression ${versionBehind} -> ${versionAhead}`); throw new Error(`Version regression ${versionBehind} -> ${versionAhead}`);
} }
for (const level of ["major", "minor", "patch", "betaPreRelease"]) { for (const level of ["major", "minor", "patch", "rc"]) {
if (versionBehind[level] !== versionAhead[level]) { if (versionBehind[level] !== versionAhead[level]) {
return level; return level;
} }
@ -9673,7 +9673,7 @@ function getLatestSemVersionedTagFactory(params) {
function getLatestSemVersionedTag(params) { function getLatestSemVersionedTag(params) {
var e_1, _a; var e_1, _a;
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
const { owner, repo, beta, major } = params; const { owner, repo, rcPolicy, major } = params;
const semVersionedTags = []; const semVersionedTags = [];
const { listTags } = listTags_1.listTagsFactory({ octokit }); const { listTags } = listTags_1.listTagsFactory({ octokit });
try { try {
@ -9689,17 +9689,17 @@ function getLatestSemVersionedTagFactory(params) {
catch (_d) { catch (_d) {
continue; continue;
} }
switch (beta) { switch (rcPolicy) {
case "IGNORE BETA": case "IGNORE RC":
if (version.betaPreRelease !== undefined) { if (version.rc !== undefined) {
continue; continue;
} }
break; break;
case "ONLY LOOK FOR BETA": case "ONLY LOOK FOR RC":
if (version.betaPreRelease === undefined) { if (version.rc === undefined) {
continue; continue;
} }
case "BETA OR REGULAR RELEASE": case "RC OR REGULAR RELEASE":
break; break;
} }
semVersionedTags.push({ tag, version }); semVersionedTags.push({ tag, version });
@ -11287,7 +11287,7 @@ function action(_actionName, params, core) {
const octokit = createOctokit_1.createOctokit({ github_token }); const octokit = createOctokit_1.createOctokit({ github_token });
const { getCommitAhead } = getCommitAhead_1.getCommitAheadFactory({ octokit }); const { getCommitAhead } = getCommitAhead_1.getCommitAheadFactory({ octokit });
const { getLatestSemVersionedTag } = getLatestSemVersionedTag_1.getLatestSemVersionedTagFactory({ octokit }); const { getLatestSemVersionedTag } = getLatestSemVersionedTag_1.getLatestSemVersionedTagFactory({ octokit });
const { tag: branchBehind } = (_a = (yield getLatestSemVersionedTag({ owner, repo, "beta": "IGNORE BETA", "major": undefined }))) !== null && _a !== void 0 ? _a : {}; const { tag: branchBehind } = (_a = (yield getLatestSemVersionedTag({ owner, repo, "rcPolicy": "IGNORE RC", "major": undefined }))) !== null && _a !== void 0 ? _a : {};
if (branchBehind === undefined) { if (branchBehind === undefined) {
core.warning(`It's the first release, not editing the CHANGELOG.md`); core.warning(`It's the first release, not editing the CHANGELOG.md`);
return; return;
@ -11309,15 +11309,15 @@ function action(_actionName, params, core) {
branch, branch,
"compare_to_version": "0.0.0" "compare_to_version": "0.0.0"
}, core).then(({ version }) => version))); }, core).then(({ version }) => version)));
if (NpmModuleVersion_1.NpmModuleVersion.parse(branchAheadVersion).betaPreRelease !== undefined) { if (NpmModuleVersion_1.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; return;
} }
const bumpType = NpmModuleVersion_1.NpmModuleVersion.bumpType({ const bumpType = NpmModuleVersion_1.NpmModuleVersion.bumpType({
"versionAheadStr": branchAheadVersion, "versionAheadStr": branchAheadVersion,
"versionBehindStr": branchBehindVersion || "0.0.0" "versionBehindStr": branchBehindVersion || "0.0.0"
}); });
assert_1.assert(bumpType !== "betaPreRelease"); assert_1.assert(bumpType !== "rc");
if (bumpType === "same") { if (bumpType === "same") {
core.warning(`Version on ${branch} and ${branchBehind} are the same, not editing CHANGELOG.md`); core.warning(`Version on ${branch} and ${branchBehind} are the same, not editing CHANGELOG.md`);
return; return;
@ -12287,7 +12287,7 @@ exports.outputNames = [
"from_version", "from_version",
"to_version", "to_version",
"is_upgraded_version", "is_upgraded_version",
"is_release_beta" "is_pre_release"
]; ];
function getOutputDescription(inputName) { function getOutputDescription(inputName) {
switch (inputName) { switch (inputName) {
@ -12304,7 +12304,7 @@ function getOutputDescription(inputName) {
case "from_version": return "Output of is_package_json_version_upgraded, string"; 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 "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_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";
} }
} }
exports.getOutputDescription = getOutputDescription; exports.getOutputDescription = getOutputDescription;
@ -14651,8 +14651,8 @@ function action(_actionName, params, core) {
const getLatestSemVersionedTagParam = { const getLatestSemVersionedTagParam = {
owner, owner,
repo, repo,
"beta": to_version.betaPreRelease !== undefined ? "rcPolicy": to_version.rc !== undefined ?
"ONLY LOOK FOR BETA" : "IGNORE BETA", "ONLY LOOK FOR RC" : "IGNORE RC",
"major": to_version.major "major": to_version.major
}; };
let wrap = yield getLatestSemVersionedTag(getLatestSemVersionedTagParam); let wrap = yield getLatestSemVersionedTag(getLatestSemVersionedTagParam);
@ -14668,13 +14668,13 @@ function action(_actionName, params, core) {
core.debug(`Last version was ${NpmModuleVersion_1.NpmModuleVersion.stringify(from_version)}`); core.debug(`Last version was ${NpmModuleVersion_1.NpmModuleVersion.stringify(from_version)}`);
const is_upgraded_version = NpmModuleVersion_1.NpmModuleVersion.compare(to_version, from_version) === 1 ? "true" : "false"; const is_upgraded_version = NpmModuleVersion_1.NpmModuleVersion.compare(to_version, from_version) === 1 ? "true" : "false";
core.debug(`Is version upgraded: ${is_upgraded_version}`); 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 { return {
"to_version": NpmModuleVersion_1.NpmModuleVersion.stringify(to_version), "to_version": NpmModuleVersion_1.NpmModuleVersion.stringify(to_version),
"from_version": NpmModuleVersion_1.NpmModuleVersion.stringify(from_version), "from_version": NpmModuleVersion_1.NpmModuleVersion.stringify(from_version),
is_upgraded_version, is_upgraded_version,
is_release_beta is_pre_release
}; };
}); });
} }

View file

@ -24,7 +24,7 @@ type CoreLike = {
debug: (message: string) => void; 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( export async function action(
_actionName: "is_package_json_version_upgraded", _actionName: "is_package_json_version_upgraded",
@ -59,8 +59,8 @@ export async function action(
const getLatestSemVersionedTagParam: Param0<typeof getLatestSemVersionedTag> = { const getLatestSemVersionedTagParam: Param0<typeof getLatestSemVersionedTag> = {
owner, owner,
repo, repo,
"beta": to_version.betaPreRelease !== undefined ? "rcPolicy": to_version.rc !== undefined ?
"ONLY LOOK FOR BETA" : "IGNORE BETA", "ONLY LOOK FOR RC" : "IGNORE RC",
"major": to_version.major "major": to_version.major
}; };
@ -89,15 +89,15 @@ export async function action(
core.debug(`Is version upgraded: ${is_upgraded_version}`); 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 { return {
"to_version": NpmModuleVersion.stringify(to_version), "to_version": NpmModuleVersion.stringify(to_version),
"from_version": NpmModuleVersion.stringify(from_version), "from_version": NpmModuleVersion.stringify(from_version),
is_upgraded_version, is_upgraded_version,
is_release_beta is_pre_release
}; };
} }

View file

@ -16,7 +16,7 @@ export const outputNames = [
"from_version", "from_version",
"to_version", "to_version",
"is_upgraded_version", "is_upgraded_version",
"is_release_beta" "is_pre_release"
] as const; ] 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 "from_version": return "Output of is_package_json_version_upgraded, string";
case "to_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_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";
} }
} }

View file

@ -4,14 +4,14 @@ export type NpmModuleVersion = {
major: number; major: number;
minor: number; minor: number;
patch: number; patch: number;
betaPreRelease?: number; rc?: number;
}; };
export namespace NpmModuleVersion { export namespace NpmModuleVersion {
export function parse(versionStr: string): 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) { if (!match) {
throw new Error(`${versionStr} is not a valid NPM version`); throw new Error(`${versionStr} is not a valid NPM version`);
@ -26,7 +26,7 @@ export namespace NpmModuleVersion {
const str = match[4]; const str = match[4];
return str === undefined ? return str === undefined ?
{} : {} :
{ "betaPreRelease": parseInt(str) }; { "rc": parseInt(str) };
})() })()
}; };
@ -34,7 +34,7 @@ export namespace NpmModuleVersion {
}; };
export function stringify(v: 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 sign = (diff: number): -1 | 0 | 1 => diff === 0 ? 0 : (diff < 0 ? -1 : 1);
const noUndefined= (n: number | undefined)=> n ?? Infinity; 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])) { if (noUndefined(v1[level]) !== noUndefined(v2[level])) {
return sign(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-rc.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-rc.3"), parse("3.0.0-rc.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("4.0.0")) === -1 )
*/ */
export function bumpType( export function bumpType(
@ -70,7 +70,7 @@ export namespace NpmModuleVersion {
versionBehindStr: string; versionBehindStr: string;
versionAheadStr: string; versionAheadStr: string;
} }
): "major" | "minor" | "patch" | "betaPreRelease" | "same" { ): "major" | "minor" | "patch" | "rc" | "same" {
const versionAhead = parse(params.versionAheadStr); const versionAhead = parse(params.versionAheadStr);
@ -80,7 +80,7 @@ export namespace NpmModuleVersion {
throw new Error(`Version regression ${versionBehind} -> ${versionAhead}`); 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]) { if (versionBehind[level] !== versionAhead[level]) {
return level; return level;
} }

View file

@ -11,7 +11,7 @@ export function getLatestSemVersionedTagFactory(params: { octokit: Octokit; }) {
params: { params: {
owner: string; owner: string;
repo: 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; major: number | undefined;
} }
): Promise<{ ): Promise<{
@ -19,7 +19,7 @@ export function getLatestSemVersionedTagFactory(params: { octokit: Octokit; }) {
version: NpmModuleVersion; version: NpmModuleVersion;
} | undefined> { } | undefined> {
const { owner, repo, beta, major } = params; const { owner, repo, rcPolicy, major } = params;
const semVersionedTags: { tag: string; version: NpmModuleVersion; }[] = []; const semVersionedTags: { tag: string; version: NpmModuleVersion; }[] = [];
@ -41,17 +41,17 @@ export function getLatestSemVersionedTagFactory(params: { octokit: Octokit; }) {
continue; continue;
} }
switch (beta) { switch (rcPolicy) {
case "IGNORE BETA": case "IGNORE RC":
if (version.betaPreRelease !== undefined) { if (version.rc !== undefined) {
continue; continue;
} }
break; break;
case "ONLY LOOK FOR BETA": case "ONLY LOOK FOR RC":
if (version.betaPreRelease === undefined) { if (version.rc === undefined) {
continue; continue;
} }
case "BETA OR REGULAR RELEASE": case "RC OR REGULAR RELEASE":
break; break;
} }

View file

@ -57,7 +57,7 @@ export async function action(
const { getLatestSemVersionedTag } = getLatestSemVersionedTagFactory({ octokit }); 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 ){ 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; return;
@ -114,7 +114,7 @@ export async function action(
"versionBehindStr": branchBehindVersion || "0.0.0" "versionBehindStr": branchBehindVersion || "0.0.0"
}); });
assert(bumpType !== "betaPreRelease"); assert(bumpType !== "rc");
if( bumpType === "same" ){ if( bumpType === "same" ){