Rework version number to include short commit hash

This commit is contained in:
Starbeamrainbowlabs 2016-05-19 20:47:26 +01:00
parent 1174882a75
commit 73b2efa75f
5 changed files with 11 additions and 5 deletions

View file

@ -15,13 +15,19 @@ namespace SpritePacker
class Program class Program
{ {
public static string Version = Utilities.GetEmbeddedResourceContent("SpritePacker.Version.txt").Trim();
private static ProgramMode programMode = ProgramMode.Normal; private static ProgramMode programMode = ProgramMode.Normal;
private static string helpTextFilename = "SpritePacker.Resources.HelpText.txt"; private static string helpTextFilename = "SpritePacker.Resources.HelpText.txt";
private static string versionTextFilename = "SpritePacker.Resources.VersionText.txt"; private static string versionTextFilename = "SpritePacker.Resources.VersionText.txt";
private static string commitHashFilename = "SpritePacker.latest-commit-hash.txt";
private static List<string> values = new List<string>(); private static List<string> values = new List<string>();
public static void Main(string[] args) public static void Main(string[] args)
{ {
string commitHash = Utilities.GetEmbeddedResourceContent(commitHashFilename).Trim();
Version += "-" + commitHash.Substring(commitHash.Length - 7);
for(int i = 0; i < args.Length; i++) for(int i = 0; i < args.Length; i++)
{ {
switch(args[i]) switch(args[i])
@ -47,9 +53,8 @@ namespace SpritePacker
case ProgramMode.DisplayVersionText: case ProgramMode.DisplayVersionText:
string textFileName = programMode == ProgramMode.DisplayHelpText ? helpTextFilename : versionTextFilename; string textFileName = programMode == ProgramMode.DisplayHelpText ? helpTextFilename : versionTextFilename;
string helpText = Utilities.GetEmbeddedResourceContent(textFileName); string helpText = Utilities.GetEmbeddedResourceContent(textFileName);
string commitHash = Utilities.GetEmbeddedResourceContent("SpritePacker.latest-commit-hash.txt").Trim();
Dictionary<string, string> templateValues = new Dictionary<string, string>() { Dictionary<string, string> templateValues = new Dictionary<string, string>() {
{ "version", Utilities.GetProgramVersion().ToString() }, { "version", Version },
{ "build-date", Utilities.GetProgramBuildDate().ToString("dd/MM/yyyy h:mmtt") }, { "build-date", Utilities.GetProgramBuildDate().ToString("dd/MM/yyyy h:mmtt") },
{ "commit-hash", commitHash.Substring(commitHash.Length - 7) }, { "commit-hash", commitHash.Substring(commitHash.Length - 7) },
{ "commit-url", string.Format("https://git.starbeamrainbowlabs.com/sbrl/SpritePacker/commit/{0}", commitHash) } { "commit-url", string.Format("https://git.starbeamrainbowlabs.com/sbrl/SpritePacker/commit/{0}", commitHash) }

View file

@ -1,4 +1,4 @@
SpritePacker v{version}, by Starbeamrainbowlabs SpritePacker {version}, by Starbeamrainbowlabs
Built at {build-date} from git commit {commit-hash} Built at {build-date} from git commit {commit-hash}
Usage: Usage:

View file

@ -1,5 +1,4 @@
SpritePacker v{version}, by Starbeamrainbowlabs SpritePacker {version}, by Starbeamrainbowlabs
Built at {build-date} Built at {build-date}
Built from git commit hash {commit-hash}
Commit url: {commit-url} Commit url: {commit-url}

View file

@ -48,6 +48,7 @@
<EmbeddedResource Include="latest-commit-hash.txt" /> <EmbeddedResource Include="latest-commit-hash.txt" />
<EmbeddedResource Include="Resources\VersionText.txt" /> <EmbeddedResource Include="Resources\VersionText.txt" />
<EmbeddedResource Include="Resources\HelpText.txt" /> <EmbeddedResource Include="Resources\HelpText.txt" />
<EmbeddedResource Include="Version.txt" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Folder Include="Resources\" /> <Folder Include="Resources\" />

1
SpritePacker/Version.txt Normal file
View file

@ -0,0 +1 @@
v0.1