mirror of
https://github.com/PaulHatch/semantic-version.git
synced 2026-04-12 18:44:16 +00:00
Adding is_tagged to outputs
Sets a flag when the current commit that the action is being run on has a tag matching the version format
This commit is contained in:
parent
9e89a29a4a
commit
e27fda7711
17 changed files with 85 additions and 29 deletions
|
|
@ -23,6 +23,7 @@ export class DefaultLastReleaseResolver implements LastReleaseResolver {
|
|||
)).trim();
|
||||
|
||||
currentTag = tagFormatter.IsValid(currentTag) ? currentTag : '';
|
||||
const isTagged = currentTag !== '';
|
||||
|
||||
const [currentMajor, currentMinor, currentPatch] = !!currentTag ? tagFormatter.Parse(currentTag) : [null, null, null];
|
||||
|
||||
|
|
@ -63,13 +64,13 @@ export class DefaultLastReleaseResolver implements LastReleaseResolver {
|
|||
core.warning('No tags are present for this repository. If this is unexpected, check to ensure that tags have been pulled from the remote.');
|
||||
}
|
||||
// no release tags yet, use the initial commit as the root
|
||||
return new ReleaseInformation(0, 0, 0, '', currentMajor, currentMinor, currentPatch);
|
||||
return new ReleaseInformation(0, 0, 0, '', currentMajor, currentMinor, currentPatch, isTagged);
|
||||
}
|
||||
|
||||
// parse the version tag
|
||||
const [major, minor, patch] = tagFormatter.Parse(tag);
|
||||
const root = await cmd('git', `merge-base`, tag, current);
|
||||
return new ReleaseInformation(major, minor, patch, root.trim(), currentMajor, currentMinor, currentPatch);
|
||||
return new ReleaseInformation(major, minor, patch, root.trim(), currentMajor, currentMinor, currentPatch, isTagged);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -9,7 +9,7 @@ test('Regular expressions can be used as minor tag direct', async () => {
|
|||
|
||||
const classifier = new DefaultVersionClassifier({ ...new ActionConfig(), ...{ tagPrefix: '', minorPattern: '/S[a-z]+Value/' }});
|
||||
|
||||
const releaseInfo =new ReleaseInformation(0,0,1,"",null,null,null);
|
||||
const releaseInfo =new ReleaseInformation(0,0,1,"",null,null,null,false);
|
||||
const commitSet = new CommitInfoSet(false, [
|
||||
new CommitInfo("", "Second Commit SomeValue", "", "","", new Date(), "", "", new Date(), []),
|
||||
new CommitInfo("", "Initial Commit", "", "","", new Date(), "", "", new Date(), []),
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ export class ReleaseInformation {
|
|||
* @param currentMajor - the major version number from the current commit
|
||||
* @param currentMinor - the minor version number from the current commit
|
||||
* @param currentPatch - the patch version number from the current commit
|
||||
* @param isTagged - whether the current commit is tagged with a version
|
||||
*/
|
||||
constructor(
|
||||
public major: number,
|
||||
|
|
@ -17,5 +18,6 @@ export class ReleaseInformation {
|
|||
public hash: string,
|
||||
public currentMajor: number | null,
|
||||
public currentMinor: number | null,
|
||||
public currentPatch: number | null,) { }
|
||||
public currentPatch: number | null,
|
||||
public isTagged: boolean,) { }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ export class VersionInformation {
|
|||
* @param type - The type of change the current range represents
|
||||
* @param commits - The list of commits for this version
|
||||
* @param changed - True if the version has changed, false otherwise
|
||||
* @param isTagged - True if the current commit is a version-tagged commit
|
||||
*/
|
||||
constructor(
|
||||
public major: number,
|
||||
|
|
@ -23,5 +24,6 @@ export class VersionInformation {
|
|||
public increment: number,
|
||||
public type: VersionType,
|
||||
public commits: CommitInfo[],
|
||||
public changed: boolean) { }
|
||||
public changed: boolean,
|
||||
public isTagged: boolean) { }
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue