Add version type as output

This commit is contained in:
Paul Hatcherian 2022-10-02 17:17:28 -04:00
parent b505a7cf06
commit e1e99bd214
13 changed files with 51 additions and 33 deletions

View file

@ -1,4 +1,5 @@
import { UserInfo } from "./providers/UserInfo";
import { VersionType } from "./providers/VersionType";
/** Represents the total output for the action */
export class VersionResult {
@ -8,6 +9,7 @@ export 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
@ -21,6 +23,7 @@ export class VersionResult {
public minor: number,
public patch: number,
public increment: number,
public versionType: VersionType,
public formattedVersion: string,
public versionTag: string,
public changed: boolean,

View file

@ -15,12 +15,13 @@ export async function runAction(configurationProvider: ConfigurationProvider): P
const userFormatter = configurationProvider.GetUserFormatter();
if (await currentCommitResolver.IsEmptyRepoAsync()) {
let versionInfo = new VersionInformation(0, 0, 0, 0, VersionType.None, [], false);
const versionInfo = new VersionInformation(0, 0, 0, 0, VersionType.None, [], false);
return new VersionResult(
versionInfo.major,
versionInfo.minor,
versionInfo.patch,
versionInfo.increment,
versionInfo.type,
versionFormatter.Format(versionInfo),
tagFormmater.Format(versionInfo),
versionInfo.changed,
@ -60,6 +61,7 @@ export async function runAction(configurationProvider: ConfigurationProvider): P
versionInfo.minor,
versionInfo.patch,
versionInfo.increment,
versionInfo.type,
versionFormatter.Format(versionInfo),
tagFormmater.Format(versionInfo),
versionInfo.changed,

View file

@ -3,9 +3,10 @@ import { ActionConfig } from './ActionConfig';
import { ConfigurationProvider } from './ConfigurationProvider';
import { VersionResult } from './VersionResult';
import * as core from '@actions/core';
import { VersionType } from './providers/VersionType';
function setOutput(versionResult: 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;
@ -23,6 +24,7 @@ function setOutput(versionResult: VersionResult) {
core.setOutput("minor", minor.toString());
core.setOutput("patch", patch.toString());
core.setOutput("increment", increment.toString());
core.setOutput("version_type", VersionType[versionType].toLowerCase());
core.setOutput("changed", changed.toString());
core.setOutput("version_tag", versionTag);
core.setOutput("authors", authors);

View file

@ -2,11 +2,11 @@
/** Indicates the type of change a particular version change represents */
export enum VersionType {
/** Indicates a major version change */
Major,
Major = 'Major',
/** Indicates a minor version change */
Minor,
Minor = 'Minor',
/** Indicates a patch version change */
Patch,
Patch = 'Patch',
/** Indicates no change--generally this means that the current commit is already tagged with a version */
None
None = 'None'
}