Cleanup default-build-script

This commit is contained in:
Webber 2020-04-22 21:36:45 +02:00 committed by Webber Takken
parent 6f1d03d8a8
commit e8a2eaad72
3 changed files with 17 additions and 11 deletions

View File

@ -33,11 +33,12 @@ namespace UnityBuilderAction.Versioning
/// <summary> /// <summary>
/// Get the version of the current tag. /// Get the version of the current tag.
/// ///
/// The tag must point at HEAD for this method to work.
///
/// Output Format: /// Output Format:
/// #.* (where # is the major version and * can be any number of any type of character) /// #.* (where # is the major version and * can be any number of any type of character)
/// </summary> /// </summary>
/// <returns></returns> public static string GetTagVersion()
public static string GenerateSemanticClassicVersion()
{ {
string version = Run(@"tag --points-at HEAD | grep v[0-9]*"); string version = Run(@"tag --points-at HEAD | grep v[0-9]*");
@ -72,7 +73,7 @@ namespace UnityBuilderAction.Versioning
/// </summary> /// </summary>
static string GetSemanticCommitVersion() static string GetSemanticCommitVersion()
{ {
// v0.1-2-g12345678 // v0.1-2-g12345678 (where 2 is the amount of commits, g stands for git)
string version = GetVersionString(); string version = GetVersionString();
// 0.1-2 // 0.1-2
version = version.Substring(1, version.LastIndexOf('-') - 1); version = version.Substring(1, version.LastIndexOf('-') - 1);
@ -86,10 +87,15 @@ namespace UnityBuilderAction.Versioning
/// Get version string. /// Get version string.
/// ///
/// Format: `v0.1-2-g12345678` (where 2 is the amount of commits since the last tag) /// Format: `v0.1-2-g12345678` (where 2 is the amount of commits since the last tag)
///
/// See: https://softwareengineering.stackexchange.com/questions/141973/how-do-you-achieve-a-numeric-versioning-scheme-with-git
/// </summary> /// </summary>
static string GetVersionString() static string GetVersionString()
{ {
return Run(@"describe --tags --long --match ""v[0-9]*"""); return Run(@"describe --tags --long --match ""v[0-9]*""");
// Todo - implement split function based on this more complete query
return Run(@"git describe --long --tags --dirty --always");
} }
/// <summary> /// <summary>

View File

@ -10,8 +10,8 @@ namespace UnityBuilderAction.Versioning
{ {
None, None,
Custom, Custom,
SemanticCommit, Semantic,
SemanticClassic, Tag,
} }
public static void SetVersion(string strategy, [CanBeNull] string version) public static void SetVersion(string strategy, [CanBeNull] string version)
@ -26,11 +26,11 @@ namespace UnityBuilderAction.Versioning
case Strategy.Custom: case Strategy.Custom:
ApplyCustomVersion(version); ApplyCustomVersion(version);
return; return;
case Strategy.SemanticCommit: case Strategy.Semantic:
ApplySemanticCommitVersion(); ApplySemanticCommitVersion();
return; return;
case Strategy.SemanticClassic: case Strategy.Tag:
ApplySemanticClassicVersion(); ApplyVersionFromCurrentTag();
return; return;
default: default:
throw new NotImplementedException("Version strategy has not been implemented."); throw new NotImplementedException("Version strategy has not been implemented.");
@ -49,9 +49,9 @@ namespace UnityBuilderAction.Versioning
Apply(version); Apply(version);
} }
static void ApplySemanticClassicVersion() static void ApplyVersionFromCurrentTag()
{ {
string version = Git.GenerateSemanticClassicVersion(); string version = Git.GetTagVersion();
Apply(version); Apply(version);
} }

File diff suppressed because one or more lines are too long