From 9d4a420ea2987370032f8cda0d4e3de7b422c000 Mon Sep 17 00:00:00 2001 From: lukeIam <2lukeiam@gmail.com> Date: Mon, 12 Dec 2016 21:01:41 +0100 Subject: [PATCH 1/5] -Mod: New versioning scheme including type if type!=release -Mod: Show the same version tag everywhere -Mod: Automatically determinate release type depending on the new version-tag -Mod: Automatically determinate CodeName -Add: Code-name for the 0.4. releases --- Vocaluxe/Base/CSettings.cs | 54 +++++++++++++++++++------- Vocaluxe/Linux/Build/PostBuildEvent.sh | 2 + Vocaluxe/Linux/Build/PreBuildEvent.sh | 2 + Vocaluxe/Properties/AssemblyInfo.cs | 6 +-- Vocaluxe/Vocaluxe.csproj | 4 +- 5 files changed, 50 insertions(+), 18 deletions(-) diff --git a/Vocaluxe/Base/CSettings.cs b/Vocaluxe/Base/CSettings.cs index 3ad3a4ef..94f38509 100644 --- a/Vocaluxe/Base/CSettings.cs +++ b/Vocaluxe/Base/CSettings.cs @@ -18,6 +18,7 @@ using System; using System.Collections.Generic; using System.IO; +using System.Linq; using System.Reflection; using System.Windows.Forms; using VocaluxeLib; @@ -53,10 +54,44 @@ namespace Vocaluxe.Base public static EProgramState ProgramState = EProgramState.Start; //Adjusting of programName and version now in the assembly config. - //I'd use the major and minor for Main releases, build number for every public release and revision for every bugfix version without any features - private const string _ProgramCodeName = "Shining Heaven"; + private static readonly Dictionary _CodeNames = new Dictionary() + { + {"0.3.", "Shining Heaven"}, + {"0.4.", "Blue Sunrise"} + }; - public const ERevision VersionRevision = ERevision.Beta; + private static string _ProgramCodeName + { + get + { + var versionParts = Application.ProductVersion.Split('.'); + string name; + _CodeNames.TryGetValue($"{versionParts[0]}.{versionParts[1]}.", out name); + if (name != null) + return name; + return "Unnamed Version"; + } + } + + public static ERevision VersionRevision + { + get + { + if (_Version.ToLower().Contains("alpha")) + { + return ERevision.Alpha; + } + if (_Version.ToLower().Contains("beta")) + { + return ERevision.Beta; + } + if (_Version.ToLower().Contains("rc")) + { + return ERevision.RC; + } + return ERevision.Release; + } + } public const int DatabaseHighscoreVersion = 3; public const int DatabaseCoverVersion = 1; @@ -177,8 +212,7 @@ namespace Vocaluxe.Base { get { - Version v = _Assembly.Version; - return "v" + v.Major + "." + v.Minor + "." + v.Build; + return Application.ProductVersion.Split('-').First(); } } @@ -186,10 +220,8 @@ namespace Vocaluxe.Base { string version = _Version + " (" + _Arch + ")"; - // ReSharper disable ConditionIsAlwaysTrueOrFalse if (VersionRevision != ERevision.Release) { - // ReSharper restore ConditionIsAlwaysTrueOrFalse string gitversion = Application.ProductVersion; version += " " + _GetVersionStatus() + String.Format(" ({0})", gitversion); } @@ -200,10 +232,8 @@ namespace Vocaluxe.Base public static string GetFullVersionText() { string version = ProgramName; - - // ReSharper disable ConditionIsAlwaysTrueOrFalse + if (_ProgramCodeName != "") - // ReSharper restore ConditionIsAlwaysTrueOrFalse version += " \"" + _ProgramCodeName + "\""; return version + " " + _GetVersionText(); @@ -211,11 +241,9 @@ namespace Vocaluxe.Base private static string _GetVersionStatus() { - string result; + string result = ""; - // ReSharper disable ConditionIsAlwaysTrueOrFalse if (VersionRevision != ERevision.Release) - // ReSharper restore ConditionIsAlwaysTrueOrFalse result = Enum.GetName(typeof(ERevision), VersionRevision); return result; diff --git a/Vocaluxe/Linux/Build/PostBuildEvent.sh b/Vocaluxe/Linux/Build/PostBuildEvent.sh index c9c2d125..92b73c10 100755 --- a/Vocaluxe/Linux/Build/PostBuildEvent.sh +++ b/Vocaluxe/Linux/Build/PostBuildEvent.sh @@ -2,4 +2,6 @@ PROJECT=$1 cd $PROJECT sed -i -r -e 's/AssemblyInformationalVersion\(".*?"\)/AssemblyInformationalVersion("GITVERSION")/' $PROJECT/Properties/AssemblyInfo.cs +sed -i -r -e 's/AssemblyVersion\(".*?"\)/AssemblyVersion("SHORTVERSION")/' $PROJECT/Properties/AssemblyInfo.cs +sed -i -r -e 's/AssemblyFileVersion\(".*?"\)/AssemblyFileVersion("SHORTVERSION")/' $PROJECT/Properties/AssemblyInfo.cs sed -i -e 's/var matchingServerVersion = "";/var matchingServerVersion = "'$(git describe --long)'";/' $PROJECT/../Output/Website/js/main.js diff --git a/Vocaluxe/Linux/Build/PreBuildEvent.sh b/Vocaluxe/Linux/Build/PreBuildEvent.sh index 4d7c6ef7..9fe7bd5b 100755 --- a/Vocaluxe/Linux/Build/PreBuildEvent.sh +++ b/Vocaluxe/Linux/Build/PreBuildEvent.sh @@ -2,3 +2,5 @@ PROJECT=$1 cd $PROJECT sed -i -e s/GITVERSION/$(git describe --long)/ $PROJECT/Properties/AssemblyInfo.cs +shortv=$(git describe --abbrev=0 | sed -e 's/alpha/0/' -e 's/beta/1/' -e 's/rc/2/') +sed -i -e s/SHORTVERSION/${shortv}/ $PROJECT/Properties/AssemblyInfo.cs diff --git a/Vocaluxe/Properties/AssemblyInfo.cs b/Vocaluxe/Properties/AssemblyInfo.cs index 3e00fede..4cde4f89 100644 --- a/Vocaluxe/Properties/AssemblyInfo.cs +++ b/Vocaluxe/Properties/AssemblyInfo.cs @@ -27,7 +27,7 @@ using System.Runtime.InteropServices; [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("Vocaluxe")] -[assembly: AssemblyCopyright("Copyright © 2013")] +[assembly: AssemblyCopyright("Copyright © 2016")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] @@ -49,6 +49,6 @@ using System.Runtime.InteropServices; // Revision // -[assembly: AssemblyVersion("0.3.0.83")] -[assembly: AssemblyFileVersion("0.3.0.83")] +[assembly: AssemblyVersion("SHORTVERSION")] +[assembly: AssemblyFileVersion("SHORTVERSION")] [assembly: AssemblyInformationalVersion("GITVERSION")] diff --git a/Vocaluxe/Vocaluxe.csproj b/Vocaluxe/Vocaluxe.csproj index fc607fd5..ef349b8e 100644 --- a/Vocaluxe/Vocaluxe.csproj +++ b/Vocaluxe/Vocaluxe.csproj @@ -479,12 +479,12 @@ xcopy /E /D /Y "$(ProjectDir)\Website" "$(SolutionDir)\PhoneGap" powershell -command "if($Env:GIT_VERSION_TAG) {$version = $Env:GIT_VERSION_TAG;} else {$version = git describe --long;}(Get-Content -Encoding UTF8 '$(ProjectDir)..\Output\Website\js\main.js') | Foreach-Object {$_ -replace '(?<=var *matchingServerVersion * = *\")\w*(?=\" *;)', "$version"} | Set-Content -Encoding UTF8 '$(ProjectDir)..\Output\Website\js\main.js'" -powershell -command "(Get-Content -Encoding UTF8 '$(ProjectDir)Properties\AssemblyInfo.cs') | Foreach-Object {$_ -replace '(?<=AssemblyInformationalVersion\()(.*)(?=\))', '\"GITVERSION\"'} | Set-Content -Encoding UTF8 '$(ProjectDir)Properties\AssemblyInfo.cs'" +powershell -command "(Get-Content -Encoding UTF8 '$(ProjectDir)Properties\AssemblyInfo.cs') | Foreach-Object {$_ -replace '(?<=AssemblyInformationalVersion\(\").*(?=\")', 'GITVERSION'} | Foreach-Object {$_ -replace '(?<=(AssemblyVersion|AssemblyFileVersion)\(\").*(?=\")', 'SHORTVERSION'} | Set-Content -Encoding UTF8 '$(ProjectDir)Properties\AssemblyInfo.cs' " cp -ruT "$(ProjectDir)Website" "$(SolutionDir)/PhoneGap" $(ProjectDir)Linux/Build/PostBuildEvent.sh $(ProjectDir) - powershell -command "if($Env:GIT_VERSION_TAG) {$version = $Env:GIT_VERSION_TAG;} else {$version = git describe --long;} (Get-Content -Encoding UTF8 '$(ProjectDir)Properties\AssemblyInfo.cs') | Foreach-Object {$_ -replace 'GITVERSION', $version} | Set-Content -Encoding UTF8 '$(ProjectDir)Properties\AssemblyInfo.cs'" + powershell -command " if($Env:GIT_VERSION_TAG) {$version = $Env:GIT_VERSION_TAG;} else {$version = git describe --long;} (Get-Content -Encoding UTF8 '$(ProjectDir)Properties\AssemblyInfo.cs') | Foreach-Object {$_ -replace '(?<=AssemblyInformationalVersion\(\").*(?=\")', $version} | Foreach-Object {$_ -replace '(?<=(AssemblyVersion|AssemblyFileVersion)\(\").*(?=\")', $version.Split('-')[0].replace('alpha','0').replace('beta','1').replace('rc','2')} | Foreach-Object {$_ -replace '(?<=AssemblyCopyright\(\".*)[0-9]+(?=\")', (Get-Date).Year} | Set-Content -Encoding UTF8 '$(ProjectDir)Properties\AssemblyInfo.cs' " $(ProjectDir)Linux/Build/PreBuildEvent.sh $(ProjectDir)