mirror of
https://github.com/PaulHatch/semantic-version.git
synced 2026-04-10 10:04:18 +00:00
Add version type as output
This commit is contained in:
parent
b505a7cf06
commit
e1e99bd214
13 changed files with 51 additions and 33 deletions
|
|
@ -13,11 +13,11 @@ class ActionConfig {
|
|||
/** A string which, if present in a git commit, indicates that a change represents a major (breaking) change. Wrap with '/' to match using a regular expression. */
|
||||
this.majorPattern = "(MAJOR)";
|
||||
/** A string which indicates the flags used by the `majorPattern` regular expression. */
|
||||
this.majorFlags = "(MAJOR)";
|
||||
this.majorFlags = "";
|
||||
/** A string which, if present in a git commit, indicates that a change represents a minor (feature) change. Wrap with '/' to match using a regular expression. */
|
||||
this.minorPattern = "(MINOR)";
|
||||
/** A string which indicates the flags used by the `minorPattern` regular expression. */
|
||||
this.minorFlags = "(MINOR)";
|
||||
this.minorFlags = "";
|
||||
/** Pattern to use when formatting output version */
|
||||
this.versionFormat = '${major}.${minor}.${patch}';
|
||||
/** Path to check for changes. If any changes are detected in the path the 'changed' output will true. Enter multiple paths separated by spaces. */
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ class VersionResult {
|
|||
* @param minor - The minor version number
|
||||
* @param patch - The patch version number
|
||||
* @param increment - The number of commits for this version (usually used to create version suffix)
|
||||
* @param versionType - The type of version, e.g. major, minor, patch
|
||||
* @param formattedVersion - The formatted semantic version
|
||||
* @param versionTag - The string to be used as a Git tag
|
||||
* @param changed - True if the version was changed, otherwise false
|
||||
|
|
@ -17,11 +18,12 @@ class VersionResult {
|
|||
* @param previousCommit - The previous commit hash
|
||||
* @param previousVersion - the previous version
|
||||
*/
|
||||
constructor(major, minor, patch, increment, formattedVersion, versionTag, changed, authors, currentCommit, previousCommit, previousVersion) {
|
||||
constructor(major, minor, patch, increment, versionType, formattedVersion, versionTag, changed, authors, currentCommit, previousCommit, previousVersion) {
|
||||
this.major = major;
|
||||
this.minor = minor;
|
||||
this.patch = patch;
|
||||
this.increment = increment;
|
||||
this.versionType = versionType;
|
||||
this.formattedVersion = formattedVersion;
|
||||
this.versionTag = versionTag;
|
||||
this.changed = changed;
|
||||
|
|
|
|||
|
|
@ -24,8 +24,8 @@ function runAction(configurationProvider) {
|
|||
const tagFormmater = configurationProvider.GetTagFormatter();
|
||||
const userFormatter = configurationProvider.GetUserFormatter();
|
||||
if (yield currentCommitResolver.IsEmptyRepoAsync()) {
|
||||
let versionInfo = new VersionInformation_1.VersionInformation(0, 0, 0, 0, VersionType_1.VersionType.None, [], false);
|
||||
return new VersionResult_1.VersionResult(versionInfo.major, versionInfo.minor, versionInfo.patch, versionInfo.increment, versionFormatter.Format(versionInfo), tagFormmater.Format(versionInfo), versionInfo.changed, userFormatter.Format('author', []), '', '', '0.0.0');
|
||||
const versionInfo = new VersionInformation_1.VersionInformation(0, 0, 0, 0, VersionType_1.VersionType.None, [], false);
|
||||
return new VersionResult_1.VersionResult(versionInfo.major, versionInfo.minor, versionInfo.patch, versionInfo.increment, versionInfo.type, versionFormatter.Format(versionInfo), tagFormmater.Format(versionInfo), versionInfo.changed, userFormatter.Format('author', []), '', '', '0.0.0');
|
||||
}
|
||||
const currentCommit = yield currentCommitResolver.ResolveAsync();
|
||||
const lastRelease = yield lastReleaseResolver.ResolveAsync(currentCommit, tagFormmater);
|
||||
|
|
@ -46,7 +46,7 @@ function runAction(configurationProvider) {
|
|||
const authors = Object.values(allAuthors)
|
||||
.map((u) => new UserInfo_1.UserInfo(u.n, u.e, u.c))
|
||||
.sort((a, b) => b.commits - a.commits);
|
||||
return new VersionResult_1.VersionResult(versionInfo.major, versionInfo.minor, versionInfo.patch, versionInfo.increment, versionFormatter.Format(versionInfo), tagFormmater.Format(versionInfo), versionInfo.changed, userFormatter.Format('author', authors), currentCommit, lastRelease.hash, `${lastRelease.major}.${lastRelease.minor}.${lastRelease.patch}`);
|
||||
return new VersionResult_1.VersionResult(versionInfo.major, versionInfo.minor, versionInfo.patch, versionInfo.increment, versionInfo.type, versionFormatter.Format(versionInfo), tagFormmater.Format(versionInfo), versionInfo.changed, userFormatter.Format('author', authors), currentCommit, lastRelease.hash, `${lastRelease.major}.${lastRelease.minor}.${lastRelease.patch}`);
|
||||
});
|
||||
}
|
||||
exports.runAction = runAction;
|
||||
|
|
|
|||
|
|
@ -36,8 +36,9 @@ exports.run = void 0;
|
|||
const action_1 = require("./action");
|
||||
const ConfigurationProvider_1 = require("./ConfigurationProvider");
|
||||
const core = __importStar(require("@actions/core"));
|
||||
const VersionType_1 = require("./providers/VersionType");
|
||||
function setOutput(versionResult) {
|
||||
const { major, minor, patch, increment, formattedVersion, versionTag, changed, authors, currentCommit, previousCommit, previousVersion } = versionResult;
|
||||
const { major, minor, patch, increment, versionType, formattedVersion, versionTag, changed, authors, currentCommit, previousCommit, previousVersion } = versionResult;
|
||||
const repository = process.env.GITHUB_REPOSITORY;
|
||||
if (!changed) {
|
||||
core.info('No changes detected for this commit');
|
||||
|
|
@ -51,6 +52,7 @@ function setOutput(versionResult) {
|
|||
core.setOutput("minor", minor.toString());
|
||||
core.setOutput("patch", patch.toString());
|
||||
core.setOutput("increment", increment.toString());
|
||||
core.setOutput("version_type", VersionType_1.VersionType[versionType].toLowerCase());
|
||||
core.setOutput("changed", changed.toString());
|
||||
core.setOutput("version_tag", versionTag);
|
||||
core.setOutput("authors", authors);
|
||||
|
|
|
|||
|
|
@ -5,11 +5,11 @@ exports.VersionType = void 0;
|
|||
var VersionType;
|
||||
(function (VersionType) {
|
||||
/** Indicates a major version change */
|
||||
VersionType[VersionType["Major"] = 0] = "Major";
|
||||
VersionType["Major"] = "Major";
|
||||
/** Indicates a minor version change */
|
||||
VersionType[VersionType["Minor"] = 1] = "Minor";
|
||||
VersionType["Minor"] = "Minor";
|
||||
/** Indicates a patch version change */
|
||||
VersionType[VersionType["Patch"] = 2] = "Patch";
|
||||
VersionType["Patch"] = "Patch";
|
||||
/** Indicates no change--generally this means that the current commit is already tagged with a version */
|
||||
VersionType[VersionType["None"] = 3] = "None";
|
||||
VersionType["None"] = "None";
|
||||
})(VersionType = exports.VersionType || (exports.VersionType = {}));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue