Implement versioning strategies in js 🧉

This commit is contained in:
Webber
2020-04-26 20:22:09 +02:00
committed by Webber Takken
parent 2e81e61af3
commit d75d7890d0
23 changed files with 361 additions and 93 deletions

View File

@@ -27,7 +27,7 @@ namespace UnityBuilderAction
};
// Set version for this build
VersionApplicator.SetVersion(options["versioning"], options["version"]);
VersionApplicator.SetVersion(options["version"]);
// Perform build
BuildReport buildReport = BuildPipeline.BuildPlayer(buildOptions);

View File

@@ -10,7 +10,7 @@ namespace UnityBuilderAction.Versioning
/// <summary>
/// Generate a version based on the latest tag and the amount of commits.
/// Format: 0.1.2 (where 2 is the amount of commits).
///
///
/// If no tag is present in the repository then v0.0 is assumed.
/// This would result in 0.0.# where # is the amount of commits.
/// </summary>
@@ -32,7 +32,7 @@ namespace UnityBuilderAction.Versioning
/// <summary>
/// Get the version of the current tag.
///
///
/// The tag must point at HEAD for this method to work.
///
/// Output Format:
@@ -85,7 +85,7 @@ namespace UnityBuilderAction.Versioning
/// <summary>
/// Get version string.
///
///
/// 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
@@ -95,7 +95,7 @@ namespace UnityBuilderAction.Versioning
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");
// return Run(@"describe --long --tags --dirty --always");
}
/// <summary>

View File

@@ -6,53 +6,12 @@ namespace UnityBuilderAction.Versioning
{
public class VersionApplicator
{
enum Strategy
public static void SetVersion(string version)
{
None,
Custom,
Semantic,
Tag,
}
public static void SetVersion(string strategy, [CanBeNull] string version)
{
if (!Enum.TryParse<Strategy>(strategy, out Strategy validatedStrategy)) {
throw new Exception($"Invalid versioning argument provided. {strategy} is not a valid strategy.");
if (version == "none") {
return;
}
switch (validatedStrategy) {
case Strategy.None:
return;
case Strategy.Custom:
ApplyCustomVersion(version);
return;
case Strategy.Semantic:
ApplySemanticCommitVersion();
return;
case Strategy.Tag:
ApplyVersionFromCurrentTag();
return;
default:
throw new NotImplementedException("Version strategy has not been implemented.");
}
}
static void ApplyCustomVersion(string version)
{
Apply(version);
}
static void ApplySemanticCommitVersion()
{
string version = Git.GenerateSemanticCommitVersion();
Apply(version);
}
static void ApplyVersionFromCurrentTag()
{
string version = Git.GetTagVersion();
Apply(version);
}

File diff suppressed because one or more lines are too long