mirror of
https://github.com/garronej/ts-ci.git
synced 2025-11-30 21:43:05 +00:00
Add is_release_beta output in is_package_json_version_upgraded
This commit is contained in:
parent
5297ab00ab
commit
e8c1eb1074
9 changed files with 324 additions and 84 deletions
|
|
@ -77,6 +77,8 @@ 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:
|
||||||
|
description: 'Output of is_package_json_version_upgraded, true|false'
|
||||||
runs:
|
runs:
|
||||||
using: 'node12'
|
using: 'node12'
|
||||||
main: 'dist/index.js'
|
main: 'dist/index.js'
|
||||||
291
dist/index.js
vendored
291
dist/index.js
vendored
|
|
@ -3449,16 +3449,17 @@ var NpmModuleVersion;
|
||||||
if (!match) {
|
if (!match) {
|
||||||
throw new Error(`${versionStr} is not a valid NPM version`);
|
throw new Error(`${versionStr} is not a valid NPM version`);
|
||||||
}
|
}
|
||||||
return {
|
return Object.assign({ "major": parseInt(match[1]), "minor": parseInt(match[2]), "patch": parseInt(match[3]) }, (() => {
|
||||||
"major": parseInt(match[1]),
|
const str = match[4];
|
||||||
"minor": parseInt(match[2]),
|
return str === undefined ?
|
||||||
"patch": parseInt(match[3])
|
{} :
|
||||||
};
|
{ "betaPreRelease": parseInt(str) };
|
||||||
|
})());
|
||||||
}
|
}
|
||||||
NpmModuleVersion.parse = parse;
|
NpmModuleVersion.parse = parse;
|
||||||
;
|
;
|
||||||
function stringify(v) {
|
function stringify(v) {
|
||||||
return `${v.major}.${v.minor}.${v.patch}`;
|
return `${v.major}.${v.minor}.${v.patch}${v.betaPreRelease === undefined ? "" : `-beta.${v.betaPreRelease}`}`;
|
||||||
}
|
}
|
||||||
NpmModuleVersion.stringify = stringify;
|
NpmModuleVersion.stringify = stringify;
|
||||||
/**
|
/**
|
||||||
|
|
@ -3469,18 +3470,14 @@ var NpmModuleVersion;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function compare(v1, v2) {
|
function compare(v1, v2) {
|
||||||
const sign = (n) => n === 0 ? 0 : (n < 0 ? -1 : 1);
|
const sign = (diff) => diff === 0 ? 0 : (diff < 0 ? -1 : 1);
|
||||||
if (v1.major === v2.major) {
|
const noUndefined = (n) => n !== null && n !== void 0 ? n : -1;
|
||||||
if (v1.minor === v2.minor) {
|
for (const level of ["major", "minor", "patch", "betaPreRelease"]) {
|
||||||
return sign(v1.patch - v2.patch);
|
if (noUndefined(v1[level]) !== noUndefined(v2[level])) {
|
||||||
}
|
return sign(noUndefined(v1[level]) - noUndefined(v2[level]));
|
||||||
else {
|
|
||||||
return sign(v1.minor - v2.minor);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
return 0;
|
||||||
return sign(v1.major - v2.major);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
NpmModuleVersion.compare = compare;
|
NpmModuleVersion.compare = compare;
|
||||||
function bumpType(params) {
|
function bumpType(params) {
|
||||||
|
|
@ -3489,18 +3486,12 @@ 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}`);
|
||||||
}
|
}
|
||||||
if (versionBehind.major !== versionAhead.major) {
|
for (const level of ["major", "minor", "patch", "betaPreRelease"]) {
|
||||||
return "MAJOR";
|
if (versionBehind[level] !== versionAhead[level]) {
|
||||||
|
return level;
|
||||||
}
|
}
|
||||||
else if (versionBehind.minor !== versionAhead.minor) {
|
|
||||||
return "MINOR";
|
|
||||||
}
|
|
||||||
else if (versionBehind.patch !== versionAhead.patch) {
|
|
||||||
return "PATCH";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return "SAME";
|
|
||||||
}
|
}
|
||||||
|
return "same";
|
||||||
}
|
}
|
||||||
NpmModuleVersion.bumpType = bumpType;
|
NpmModuleVersion.bumpType = bumpType;
|
||||||
})(NpmModuleVersion = exports.NpmModuleVersion || (exports.NpmModuleVersion = {}));
|
})(NpmModuleVersion = exports.NpmModuleVersion || (exports.NpmModuleVersion = {}));
|
||||||
|
|
@ -5564,6 +5555,20 @@ function getCommitAheadFactory(params) {
|
||||||
exports.getCommitAheadFactory = getCommitAheadFactory;
|
exports.getCommitAheadFactory = getCommitAheadFactory;
|
||||||
|
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 440:
|
||||||
|
/***/ (function(__unusedmodule, exports) {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.id = void 0;
|
||||||
|
/** https://docs.tsafe.dev/id */
|
||||||
|
var id = function (x) { return x; };
|
||||||
|
exports.id = id;
|
||||||
|
//# sourceMappingURL=id.js.map
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
/***/ 448:
|
/***/ 448:
|
||||||
|
|
@ -7886,20 +7891,23 @@ 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 } = params;
|
const { owner, repo, doIgnoreBeta } = params;
|
||||||
const semVersionedTags = [];
|
const semVersionedTags = [];
|
||||||
const { listTags } = listTags_1.listTagsFactory({ octokit });
|
const { listTags } = listTags_1.listTagsFactory({ octokit });
|
||||||
try {
|
try {
|
||||||
for (var _b = __asyncValues(listTags({ owner, repo })), _c; _c = yield _b.next(), !_c.done;) {
|
for (var _b = __asyncValues(listTags({ owner, repo })), _c; _c = yield _b.next(), !_c.done;) {
|
||||||
const tag = _c.value;
|
const tag = _c.value;
|
||||||
const match = tag.match(/^v?([0-9]+\.[0-9]+\.[0-9]+)$/);
|
let version;
|
||||||
if (!match) {
|
try {
|
||||||
|
version = NpmModuleVersion_1.NpmModuleVersion.parse(tag.replace(/^[vV]?/, ""));
|
||||||
|
}
|
||||||
|
catch (_d) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
semVersionedTags.push({
|
if (doIgnoreBeta && version.betaPreRelease !== undefined) {
|
||||||
tag,
|
continue;
|
||||||
"version": NpmModuleVersion_1.NpmModuleVersion.parse(match[1])
|
}
|
||||||
});
|
semVersionedTags.push({ tag, version });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
||||||
|
|
@ -8610,6 +8618,94 @@ module.exports = require("http");
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 606:
|
||||||
|
/***/ (function(__unusedmodule, exports, __webpack_require__) {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
var __extends = (this && this.__extends) || (function () {
|
||||||
|
var extendStatics = function (d, b) {
|
||||||
|
extendStatics = Object.setPrototypeOf ||
|
||||||
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||||
|
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
||||||
|
return extendStatics(d, b);
|
||||||
|
};
|
||||||
|
return function (d, b) {
|
||||||
|
if (typeof b !== "function" && b !== null)
|
||||||
|
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
||||||
|
extendStatics(d, b);
|
||||||
|
function __() { this.constructor = d; }
|
||||||
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||||
|
};
|
||||||
|
})();
|
||||||
|
var __read = (this && this.__read) || function (o, n) {
|
||||||
|
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
||||||
|
if (!m) return o;
|
||||||
|
var i = m.call(o), r, ar = [], e;
|
||||||
|
try {
|
||||||
|
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
||||||
|
}
|
||||||
|
catch (error) { e = { error: error }; }
|
||||||
|
finally {
|
||||||
|
try {
|
||||||
|
if (r && !r.done && (m = i["return"])) m.call(i);
|
||||||
|
}
|
||||||
|
finally { if (e) throw e.error; }
|
||||||
|
}
|
||||||
|
return ar;
|
||||||
|
};
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.assert = exports.AssertionError = void 0;
|
||||||
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
||||||
|
var overwriteReadonlyProp_1 = __webpack_require__(983);
|
||||||
|
var assertIsRefWrapper_1 = __webpack_require__(723);
|
||||||
|
/** @see <https://docs.tsafe.dev/assert#error-thrown> */
|
||||||
|
var AssertionError = /** @class */ (function (_super) {
|
||||||
|
__extends(AssertionError, _super);
|
||||||
|
function AssertionError(msg) {
|
||||||
|
var _newTarget = this.constructor;
|
||||||
|
var _this = _super.call(this, "Wrong assertion encountered" + (!msg ? "" : ": \"" + msg + "\"")) || this;
|
||||||
|
Object.setPrototypeOf(_this, _newTarget.prototype);
|
||||||
|
if (!_this.stack) {
|
||||||
|
return _this;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
(0, overwriteReadonlyProp_1.overwriteReadonlyProp)(_this, "stack", _this.stack
|
||||||
|
.split("\n")
|
||||||
|
.filter(function () {
|
||||||
|
var _a = [];
|
||||||
|
for (var _i = 0; _i < arguments.length; _i++) {
|
||||||
|
_a[_i] = arguments[_i];
|
||||||
|
}
|
||||||
|
var _b = __read(_a, 2), i = _b[1];
|
||||||
|
return i !== 1 && i !== 2;
|
||||||
|
})
|
||||||
|
.join("\n"));
|
||||||
|
// eslint-disable-next-line no-empty
|
||||||
|
}
|
||||||
|
catch (_a) { }
|
||||||
|
return _this;
|
||||||
|
}
|
||||||
|
return AssertionError;
|
||||||
|
}(Error));
|
||||||
|
exports.AssertionError = AssertionError;
|
||||||
|
/** https://docs.tsafe.dev/assert */
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
|
function assert(condition, msg) {
|
||||||
|
if (condition === void 0) { condition = true; }
|
||||||
|
if (assertIsRefWrapper_1.assertIsRefWrapper.ref !== undefined) {
|
||||||
|
assertIsRefWrapper_1.assertIsRefWrapper.ref = undefined;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!condition) {
|
||||||
|
throw new AssertionError(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.assert = assert;
|
||||||
|
//# sourceMappingURL=assert.js.map
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
/***/ 614:
|
/***/ 614:
|
||||||
/***/ (function(module) {
|
/***/ (function(module) {
|
||||||
|
|
||||||
|
|
@ -9053,6 +9149,7 @@ const NpmModuleVersion_1 = __webpack_require__(395);
|
||||||
const gitCommit_1 = __webpack_require__(503);
|
const gitCommit_1 = __webpack_require__(503);
|
||||||
const getLatestSemVersionedTag_1 = __webpack_require__(472);
|
const getLatestSemVersionedTag_1 = __webpack_require__(472);
|
||||||
const createOctokit_1 = __webpack_require__(906);
|
const createOctokit_1 = __webpack_require__(906);
|
||||||
|
const assert_1 = __webpack_require__(606);
|
||||||
exports.getActionParams = inputHelper_1.getActionParamsFactory({
|
exports.getActionParams = inputHelper_1.getActionParamsFactory({
|
||||||
"inputNameSubset": [
|
"inputNameSubset": [
|
||||||
"owner",
|
"owner",
|
||||||
|
|
@ -9072,7 +9169,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 }))) !== null && _a !== void 0 ? _a : {};
|
const { tag: branchBehind } = (_a = (yield getLatestSemVersionedTag({ owner, repo, "doIgnoreBeta": true }))) !== 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;
|
||||||
|
|
@ -9094,11 +9191,16 @@ 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) {
|
||||||
|
core.warning(`Version on ${branch} is ${branchAheadVersion} it's a beta release, we do not update the CHANGELOG.md`);
|
||||||
|
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"
|
||||||
});
|
});
|
||||||
if (bumpType === "SAME") {
|
assert_1.assert(bumpType !== "betaPreRelease");
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
|
|
@ -9147,7 +9249,7 @@ function updateChangelog(params) {
|
||||||
.split("T")[0];
|
.split("T")[0];
|
||||||
})();
|
})();
|
||||||
const changelogRaw = [
|
const changelogRaw = [
|
||||||
`${bumpType === "MAJOR" ? "#" : (bumpType === "MINOR" ? "##" : "###")}`,
|
`${bumpType === "major" ? "#" : (bumpType === "minor" ? "##" : "###")}`,
|
||||||
` **${version}** (${dateString}) \n \n`,
|
` **${version}** (${dateString}) \n \n`,
|
||||||
`${body} \n \n`,
|
`${body} \n \n`,
|
||||||
params.changelogRaw
|
params.changelogRaw
|
||||||
|
|
@ -9217,6 +9319,21 @@ function getCommonOriginFactory(params) {
|
||||||
exports.getCommonOriginFactory = getCommonOriginFactory;
|
exports.getCommonOriginFactory = getCommonOriginFactory;
|
||||||
|
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 723:
|
||||||
|
/***/ (function(__unusedmodule, exports, __webpack_require__) {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.assertIsRefWrapper = void 0;
|
||||||
|
var id_1 = __webpack_require__(440);
|
||||||
|
exports.assertIsRefWrapper = {
|
||||||
|
"ref": (0, id_1.id)(undefined),
|
||||||
|
};
|
||||||
|
//# sourceMappingURL=assertIsRefWrapper.js.map
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
/***/ 742:
|
/***/ 742:
|
||||||
|
|
@ -9501,7 +9618,8 @@ exports.outputNames = [
|
||||||
"npm_or_yarn",
|
"npm_or_yarn",
|
||||||
"from_version",
|
"from_version",
|
||||||
"to_version",
|
"to_version",
|
||||||
"is_upgraded_version"
|
"is_upgraded_version",
|
||||||
|
"is_release_beta"
|
||||||
];
|
];
|
||||||
function getOutputDescription(inputName) {
|
function getOutputDescription(inputName) {
|
||||||
switch (inputName) {
|
switch (inputName) {
|
||||||
|
|
@ -9518,6 +9636,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";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.getOutputDescription = getOutputDescription;
|
exports.getOutputDescription = getOutputDescription;
|
||||||
|
|
@ -10016,6 +10135,39 @@ function action(_actionName, params, core) {
|
||||||
exports.action = action;
|
exports.action = action;
|
||||||
|
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 834:
|
||||||
|
/***/ (function(__unusedmodule, exports, __webpack_require__) {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
/* eslint-disable @typescript-eslint/no-namespace */
|
||||||
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.is = void 0;
|
||||||
|
var assertIsRefWrapper_1 = __webpack_require__(723);
|
||||||
|
var errorMessage = [
|
||||||
|
"Wrong usage of the " + is.name + " function refer to",
|
||||||
|
"https://docs.tsafe.dev/" + is.name.toLowerCase(),
|
||||||
|
].join(" ");
|
||||||
|
function is(_value) {
|
||||||
|
var ref = {};
|
||||||
|
if (assertIsRefWrapper_1.assertIsRefWrapper.ref !== undefined) {
|
||||||
|
assertIsRefWrapper_1.assertIsRefWrapper.ref = undefined;
|
||||||
|
throw new Error(errorMessage);
|
||||||
|
}
|
||||||
|
assertIsRefWrapper_1.assertIsRefWrapper.ref = ref;
|
||||||
|
Promise.resolve().then(function () {
|
||||||
|
if (assertIsRefWrapper_1.assertIsRefWrapper.ref === ref) {
|
||||||
|
throw new Error(errorMessage);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
exports.is = is;
|
||||||
|
//# sourceMappingURL=is.js.map
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
/***/ 835:
|
/***/ 835:
|
||||||
|
|
@ -12236,15 +12388,17 @@ function action(_actionName, params, core) {
|
||||||
core.debug(`Version on ${owner}/${repo}#${branch} is ${NpmModuleVersion_1.NpmModuleVersion.stringify(to_version)}`);
|
core.debug(`Version on ${owner}/${repo}#${branch} is ${NpmModuleVersion_1.NpmModuleVersion.stringify(to_version)}`);
|
||||||
const octokit = createOctokit_1.createOctokit({ github_token });
|
const octokit = createOctokit_1.createOctokit({ github_token });
|
||||||
const { getLatestSemVersionedTag } = getLatestSemVersionedTag_1.getLatestSemVersionedTagFactory({ octokit });
|
const { getLatestSemVersionedTag } = getLatestSemVersionedTag_1.getLatestSemVersionedTagFactory({ octokit });
|
||||||
const { version: from_version } = yield getLatestSemVersionedTag({ owner, repo })
|
const { version: from_version } = yield getLatestSemVersionedTag({ owner, repo, "doIgnoreBeta": false })
|
||||||
.then(wrap => wrap === undefined ? { "version": NpmModuleVersion_1.NpmModuleVersion.parse("0.0.0") } : wrap);
|
.then(wrap => wrap === undefined ? { "version": NpmModuleVersion_1.NpmModuleVersion.parse("0.0.0") } : wrap);
|
||||||
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";
|
||||||
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
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -12743,6 +12897,65 @@ function onceStrict (fn) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 983:
|
||||||
|
/***/ (function(__unusedmodule, exports, __webpack_require__) {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
var __assign = (this && this.__assign) || function () {
|
||||||
|
__assign = Object.assign || function(t) {
|
||||||
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
||||||
|
s = arguments[i];
|
||||||
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
||||||
|
t[p] = s[p];
|
||||||
|
}
|
||||||
|
return t;
|
||||||
|
};
|
||||||
|
return __assign.apply(this, arguments);
|
||||||
|
};
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.overwriteReadonlyProp = void 0;
|
||||||
|
/* eslint-disable no-empty */
|
||||||
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||||
|
var assert_1 = __webpack_require__(606);
|
||||||
|
var is_1 = __webpack_require__(834);
|
||||||
|
/**
|
||||||
|
* Assign a value to a property even if the object is freezed or if the property is not writable
|
||||||
|
* Throw if the assignation fail ( for example if the property is non configurable write: false )
|
||||||
|
* */
|
||||||
|
var overwriteReadonlyProp = function (obj, propertyName, value) {
|
||||||
|
try {
|
||||||
|
obj[propertyName] = value;
|
||||||
|
}
|
||||||
|
catch (_a) { }
|
||||||
|
if (obj[propertyName] === value) {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
var errorDefineProperty = undefined;
|
||||||
|
var propertyDescriptor = Object.getOwnPropertyDescriptor(obj, propertyName) || {
|
||||||
|
"enumerable": true,
|
||||||
|
"configurable": true,
|
||||||
|
};
|
||||||
|
if (!!propertyDescriptor.get) {
|
||||||
|
throw new Error("Probably a wrong ides to overwrite " + propertyName + " getter");
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
Object.defineProperty(obj, propertyName, __assign(__assign({}, propertyDescriptor), { value: value }));
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
(0, assert_1.assert)((0, is_1.is)(error));
|
||||||
|
errorDefineProperty = error;
|
||||||
|
}
|
||||||
|
if (obj[propertyName] !== value) {
|
||||||
|
throw errorDefineProperty || new Error("Can't assign");
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
};
|
||||||
|
exports.overwriteReadonlyProp = overwriteReadonlyProp;
|
||||||
|
//# sourceMappingURL=overwriteReadonlyProp.js.map
|
||||||
|
|
||||||
/***/ })
|
/***/ })
|
||||||
|
|
||||||
/******/ });
|
/******/ });
|
||||||
5
package-lock.json
generated
5
package-lock.json
generated
|
|
@ -779,6 +779,11 @@
|
||||||
"has-flag": "^3.0.0"
|
"has-flag": "^3.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"tsafe": {
|
||||||
|
"version": "0.8.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/tsafe/-/tsafe-0.8.1.tgz",
|
||||||
|
"integrity": "sha512-EfPjxQHzndQAV/uh0SMGP26Wg3dCuaw8dRv2VPEuGHen5qzg2oqsMvZw2wkQFkiMisZq2fm95m5lheimW2Fpvg=="
|
||||||
|
},
|
||||||
"typescript": {
|
"typescript": {
|
||||||
"version": "3.9.9",
|
"version": "3.9.9",
|
||||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.9.tgz",
|
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.9.tgz",
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@
|
||||||
"glob": "^7.1.6",
|
"glob": "^7.1.6",
|
||||||
"node-fetch": "^2.6.1",
|
"node-fetch": "^2.6.1",
|
||||||
"scripting-tools": "^0.19.12",
|
"scripting-tools": "^0.19.12",
|
||||||
|
"tsafe": "^0.8.1",
|
||||||
"url-join": "^4.0.1",
|
"url-join": "^4.0.1",
|
||||||
"validate-npm-package-name": "^3.0.0"
|
"validate-npm-package-name": "^3.0.0"
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ type CoreLike = {
|
||||||
debug: (message: string) => void;
|
debug: (message: string) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const { setOutput } = setOutputFactory<"from_version" | "to_version" | "is_upgraded_version">();
|
export const { setOutput } = setOutputFactory<"from_version" | "to_version" | "is_upgraded_version" | "is_release_beta">();
|
||||||
|
|
||||||
export async function action(
|
export async function action(
|
||||||
_actionName: "is_package_json_version_upgraded",
|
_actionName: "is_package_json_version_upgraded",
|
||||||
|
|
@ -46,7 +46,7 @@ export async function action(
|
||||||
|
|
||||||
const { getLatestSemVersionedTag } = getLatestSemVersionedTagFactory({ octokit });
|
const { getLatestSemVersionedTag } = getLatestSemVersionedTagFactory({ octokit });
|
||||||
|
|
||||||
const { version: from_version } = await getLatestSemVersionedTag({ owner, repo })
|
const { version: from_version } = await getLatestSemVersionedTag({ owner, repo, "doIgnoreBeta": false })
|
||||||
.then(wrap => wrap === undefined ? { "version": NpmModuleVersion.parse("0.0.0") } : wrap);
|
.then(wrap => wrap === undefined ? { "version": NpmModuleVersion.parse("0.0.0") } : wrap);
|
||||||
|
|
||||||
core.debug(`Last version was ${NpmModuleVersion.stringify(from_version)}`);
|
core.debug(`Last version was ${NpmModuleVersion.stringify(from_version)}`);
|
||||||
|
|
@ -58,10 +58,13 @@ 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";
|
||||||
|
|
||||||
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
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,8 @@ export const outputNames = [
|
||||||
"npm_or_yarn",
|
"npm_or_yarn",
|
||||||
"from_version",
|
"from_version",
|
||||||
"to_version",
|
"to_version",
|
||||||
"is_upgraded_version"
|
"is_upgraded_version",
|
||||||
|
"is_release_beta"
|
||||||
] as const;
|
] as const;
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -34,6 +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";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ export type NpmModuleVersion = {
|
||||||
major: number;
|
major: number;
|
||||||
minor: number;
|
minor: number;
|
||||||
patch: number;
|
patch: number;
|
||||||
|
betaPreRelease?: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
export namespace NpmModuleVersion {
|
export namespace NpmModuleVersion {
|
||||||
|
|
@ -12,20 +13,28 @@ export namespace NpmModuleVersion {
|
||||||
|
|
||||||
const match = versionStr.match(/^([0-9]+)\.([0-9]+)\.([0-9]+)(?:-beta.([0-9]+))?/);
|
const match = versionStr.match(/^([0-9]+)\.([0-9]+)\.([0-9]+)(?:-beta.([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`);
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"major": parseInt(match[1]),
|
"major": parseInt(match[1]),
|
||||||
"minor": parseInt(match[2]),
|
"minor": parseInt(match[2]),
|
||||||
"patch": parseInt(match[3])
|
"patch": parseInt(match[3]),
|
||||||
|
...(() => {
|
||||||
|
|
||||||
|
const str = match[4];
|
||||||
|
return str === undefined ?
|
||||||
|
{} :
|
||||||
|
{ "betaPreRelease": parseInt(str) };
|
||||||
|
|
||||||
|
})()
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export function stringify(v: NpmModuleVersion) {
|
export function stringify(v: NpmModuleVersion) {
|
||||||
return `${v.major}.${v.minor}.${v.patch}`;
|
return `${v.major}.${v.minor}.${v.patch}${v.betaPreRelease === undefined ? "" : `-beta.${v.betaPreRelease}`}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -37,18 +46,17 @@ export namespace NpmModuleVersion {
|
||||||
*/
|
*/
|
||||||
export function compare(v1: NpmModuleVersion, v2: NpmModuleVersion): -1 | 0 | 1 {
|
export function compare(v1: NpmModuleVersion, v2: NpmModuleVersion): -1 | 0 | 1 {
|
||||||
|
|
||||||
const sign = (n: number): -1 | 0 | 1 => n === 0 ? 0 : (n < 0 ? -1 : 1);
|
const sign = (diff: number): -1 | 0 | 1 => diff === 0 ? 0 : (diff < 0 ? -1 : 1);
|
||||||
|
const noUndefined= (n: number | undefined)=> n ?? -1;
|
||||||
|
|
||||||
if (v1.major === v2.major) {
|
for (const level of ["major", "minor", "patch", "betaPreRelease"] as const) {
|
||||||
if (v1.minor === v2.minor) {
|
if (noUndefined(v1[level]) !== noUndefined(v2[level])) {
|
||||||
return sign(v1.patch - v2.patch);
|
return sign(noUndefined(v1[level]) - noUndefined(v2[level]));
|
||||||
} else {
|
|
||||||
return sign(v1.minor - v2.minor);
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
return sign(v1.major - v2.major);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function bumpType(
|
export function bumpType(
|
||||||
|
|
@ -56,33 +64,23 @@ export namespace NpmModuleVersion {
|
||||||
versionBehindStr: string;
|
versionBehindStr: string;
|
||||||
versionAheadStr: string;
|
versionAheadStr: string;
|
||||||
}
|
}
|
||||||
): "SAME" | "MAJOR" | "MINOR" | "PATCH" {
|
): "major" | "minor" | "patch" | "betaPreRelease" | "same" {
|
||||||
|
|
||||||
|
|
||||||
const versionAhead = parse(params.versionAheadStr);
|
const versionAhead = parse(params.versionAheadStr);
|
||||||
const versionBehind = parse(params.versionBehindStr);
|
const versionBehind = parse(params.versionBehindStr);
|
||||||
|
|
||||||
if( compare(versionBehind, versionAhead) === 1 ){
|
if (compare(versionBehind, versionAhead) === 1) {
|
||||||
throw new Error(`Version regression ${versionBehind} -> ${versionAhead}`);
|
throw new Error(`Version regression ${versionBehind} -> ${versionAhead}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (versionBehind.major !== versionAhead.major) {
|
for (const level of ["major", "minor", "patch", "betaPreRelease"] as const) {
|
||||||
|
if (versionBehind[level] !== versionAhead[level]) {
|
||||||
return "MAJOR";
|
return level;
|
||||||
|
|
||||||
} else if (versionBehind.minor !== versionAhead.minor) {
|
|
||||||
|
|
||||||
return "MINOR";
|
|
||||||
|
|
||||||
} else if (versionBehind.patch !== versionAhead.patch) {
|
|
||||||
|
|
||||||
return "PATCH";
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
return "SAME";
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return "same";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,13 +11,14 @@ export function getLatestSemVersionedTagFactory(params: { octokit: Octokit; }) {
|
||||||
params: {
|
params: {
|
||||||
owner: string;
|
owner: string;
|
||||||
repo: string;
|
repo: string;
|
||||||
|
doIgnoreBeta: boolean;
|
||||||
}
|
}
|
||||||
): Promise<{
|
): Promise<{
|
||||||
tag: string;
|
tag: string;
|
||||||
version: NpmModuleVersion;
|
version: NpmModuleVersion;
|
||||||
} | undefined> {
|
} | undefined> {
|
||||||
|
|
||||||
const { owner, repo } = params;
|
const { owner, repo, doIgnoreBeta } = params;
|
||||||
|
|
||||||
const semVersionedTags: { tag: string; version: NpmModuleVersion; }[] = [];
|
const semVersionedTags: { tag: string; version: NpmModuleVersion; }[] = [];
|
||||||
|
|
||||||
|
|
@ -25,16 +26,21 @@ export function getLatestSemVersionedTagFactory(params: { octokit: Octokit; }) {
|
||||||
|
|
||||||
for await (const tag of listTags({ owner, repo })) {
|
for await (const tag of listTags({ owner, repo })) {
|
||||||
|
|
||||||
const match = tag.match(/^v?([0-9]+\.[0-9]+\.[0-9]+)$/);
|
let version: NpmModuleVersion;
|
||||||
|
|
||||||
if (!match) {
|
try{
|
||||||
|
|
||||||
|
version = NpmModuleVersion.parse(tag.replace(/^[vV]?/, ""));
|
||||||
|
|
||||||
|
}catch{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
semVersionedTags.push({
|
if( doIgnoreBeta && version.betaPreRelease !== undefined ){
|
||||||
tag,
|
continue;
|
||||||
"version": NpmModuleVersion.parse( match[1])
|
}
|
||||||
});
|
|
||||||
|
semVersionedTags.push({ tag, version });
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ import { NpmModuleVersion } from "./tools/NpmModuleVersion";
|
||||||
import { gitCommit } from "./tools/gitCommit";
|
import { gitCommit } from "./tools/gitCommit";
|
||||||
import { getLatestSemVersionedTagFactory } from "./tools/octokit-addons/getLatestSemVersionedTag";
|
import { getLatestSemVersionedTagFactory } from "./tools/octokit-addons/getLatestSemVersionedTag";
|
||||||
import { createOctokit } from "./tools/createOctokit";
|
import { createOctokit } from "./tools/createOctokit";
|
||||||
|
import { assert } from "tsafe/assert";
|
||||||
|
|
||||||
export const { getActionParams } = getActionParamsFactory({
|
export const { getActionParams } = getActionParamsFactory({
|
||||||
"inputNameSubset": [
|
"inputNameSubset": [
|
||||||
|
|
@ -53,7 +54,7 @@ export async function action(
|
||||||
|
|
||||||
const { getLatestSemVersionedTag } = getLatestSemVersionedTagFactory({ octokit });
|
const { getLatestSemVersionedTag } = getLatestSemVersionedTagFactory({ octokit });
|
||||||
|
|
||||||
const { tag: branchBehind } = (await getLatestSemVersionedTag({ owner, repo })) ?? {};
|
const { tag: branchBehind } = (await getLatestSemVersionedTag({ owner, repo, "doIgnoreBeta": true })) ?? {};
|
||||||
|
|
||||||
if( branchBehind === undefined ){
|
if( branchBehind === undefined ){
|
||||||
|
|
||||||
|
|
@ -97,13 +98,22 @@ export async function action(
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if( NpmModuleVersion.parse(branchAheadVersion).betaPreRelease !== undefined ){
|
||||||
|
|
||||||
|
core.warning(`Version on ${branch} is ${branchAheadVersion} it's a beta release, we do not update the CHANGELOG.md`);
|
||||||
|
|
||||||
|
return;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
const bumpType = NpmModuleVersion.bumpType({
|
const bumpType = NpmModuleVersion.bumpType({
|
||||||
"versionAheadStr": branchAheadVersion,
|
"versionAheadStr": branchAheadVersion,
|
||||||
"versionBehindStr": branchBehindVersion || "0.0.0"
|
"versionBehindStr": branchBehindVersion || "0.0.0"
|
||||||
});
|
});
|
||||||
|
|
||||||
if( bumpType === "SAME" ){
|
assert(bumpType !== "betaPreRelease");
|
||||||
|
|
||||||
|
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`);
|
||||||
|
|
||||||
|
|
@ -162,7 +172,7 @@ function updateChangelog(
|
||||||
params: {
|
params: {
|
||||||
changelogRaw: string;
|
changelogRaw: string;
|
||||||
version: string;
|
version: string;
|
||||||
bumpType: "MAJOR" | "MINOR" | "PATCH";
|
bumpType: "major" | "minor" | "patch";
|
||||||
body: string;
|
body: string;
|
||||||
}
|
}
|
||||||
): { changelogRaw: string; } {
|
): { changelogRaw: string; } {
|
||||||
|
|
@ -180,7 +190,7 @@ function updateChangelog(
|
||||||
})();
|
})();
|
||||||
|
|
||||||
const changelogRaw = [
|
const changelogRaw = [
|
||||||
`${bumpType === "MAJOR" ? "#" : (bumpType === "MINOR" ? "##" : "###")}`,
|
`${bumpType === "major" ? "#" : (bumpType === "minor" ? "##" : "###")}`,
|
||||||
` **${version}** (${dateString}) \n \n`,
|
` **${version}** (${dateString}) \n \n`,
|
||||||
`${body} \n \n`,
|
`${body} \n \n`,
|
||||||
params.changelogRaw
|
params.changelogRaw
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue