From 152be5d8ad8bc9ccfb7d8799df408677bb5da2db Mon Sep 17 00:00:00 2001 From: lukeIam <2lukeiam@gmail.com> Date: Wed, 28 Dec 2016 23:01:34 +0100 Subject: [PATCH 1/3] - calculate full version tag in build script and set AssemblyTitle - display AssemblyTitle in Vocaluxe gui - code names are stored in .build/versionNames.json - pre and post build scripts for windows (one place for all commands) - adjusted and moved the linux build scripts --- .../linuxPostBuildEvent.sh | 1 + .build/linuxPreBuildEvent.sh | 29 +++++++++ .build/versionNames.json | 5 ++ .build/winPostBuild.ps1 | 23 ++++++++ .build/winPreBuild.ps1 | 40 +++++++++++++ Vocaluxe/Base/CSettings.cs | 59 +++---------------- Vocaluxe/Linux/Build/PreBuildEvent.sh | 6 -- Vocaluxe/Properties/AssemblyInfo.cs | 2 +- Vocaluxe/Vocaluxe.csproj | 11 ++-- 9 files changed, 112 insertions(+), 64 deletions(-) rename Vocaluxe/Linux/Build/PostBuildEvent.sh => .build/linuxPostBuildEvent.sh (83%) mode change 100755 => 100644 create mode 100644 .build/linuxPreBuildEvent.sh create mode 100644 .build/versionNames.json create mode 100644 .build/winPostBuild.ps1 create mode 100644 .build/winPreBuild.ps1 delete mode 100755 Vocaluxe/Linux/Build/PreBuildEvent.sh diff --git a/Vocaluxe/Linux/Build/PostBuildEvent.sh b/.build/linuxPostBuildEvent.sh old mode 100755 new mode 100644 similarity index 83% rename from Vocaluxe/Linux/Build/PostBuildEvent.sh rename to .build/linuxPostBuildEvent.sh index 92b73c10..fe52ac53 --- a/Vocaluxe/Linux/Build/PostBuildEvent.sh +++ b/.build/linuxPostBuildEvent.sh @@ -4,4 +4,5 @@ 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 -r -e 's/AssemblyTitle\(".*?"\)/AssemblyTitle("FULLVERSION")/' $PROJECT/Properties/AssemblyInfo.cs sed -i -e 's/var matchingServerVersion = "";/var matchingServerVersion = "'$(git describe --long)'";/' $PROJECT/../Output/Website/js/main.js diff --git a/.build/linuxPreBuildEvent.sh b/.build/linuxPreBuildEvent.sh new file mode 100644 index 00000000..329c0678 --- /dev/null +++ b/.build/linuxPreBuildEvent.sh @@ -0,0 +1,29 @@ +#!/bin/sh +PROJECT=$1 +cd $PROJECT +arch=$2 +version=$(git describe --long) +shortVersion=${version%%-*} +shortVersionClean=$(echo $shortVersion | sed -e 's/alpha/0/' -e 's/beta/1/' -e 's/rc/2/' -e 's/[[:alpha:]]//g') + +case ${shortVersion##*.} in +alpha*) + releaseType='Alpha' + ;; +beta*) + releaseType='Beta' + ;; +rc*) + releaseType='RC' + ;; +*) + releaseType='Release' + ;; +esac + +versionName=$(grep -oP "\"${shortVersionClean%.*}.\" *: *\"\K([^\"]+)(?=\")" ../.build/versionNames.json) +fullVersionName="Vocaluxe $([ "$versionName" == "" ] && echo "" || echo "'$versionName' ")$shortVersion ($arch) $([ "$releaseType" == "Release" ] && echo "" || echo "$releaseType ")($version)" + +sed -i -e s/GITVERSION/$(git describe --long)/ $PROJECT/Properties/AssemblyInfo.cs +sed -i -e s/SHORTVERSION/"$shortVersionClean"/ $PROJECT/Properties/AssemblyInfo.cs +sed -i -e s/FULLVERSION/"$fullVersionName"/ $PROJECT/Properties/AssemblyInfo.cs \ No newline at end of file diff --git a/.build/versionNames.json b/.build/versionNames.json new file mode 100644 index 00000000..2cc6109c --- /dev/null +++ b/.build/versionNames.json @@ -0,0 +1,5 @@ +{ + "0.0.": "Unversioned Build", + "0.3.": "Shining Heaven", + "0.4.": "Blue Sunrise" +} \ No newline at end of file diff --git a/.build/winPostBuild.ps1 b/.build/winPostBuild.ps1 new file mode 100644 index 00000000..416353fc --- /dev/null +++ b/.build/winPostBuild.ps1 @@ -0,0 +1,23 @@ +param( + [Parameter(Mandatory=$true)] + [String]$ProjectDir +) + +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" + +(Get-Content -Encoding UTF8 "$($ProjectDir)Properties\AssemblyInfo.cs") ` + | Foreach-Object {$_ -replace '(?<=AssemblyInformationalVersion\(\").*(?=\")', 'GITVERSION'} ` + | Foreach-Object {$_ -replace '(?<=(AssemblyVersion|AssemblyFileVersion)\(\").*(?=\")', 'SHORTVERSION'} ` + | Foreach-Object {$_ -replace '(?<=AssemblyTitle\(\").*(?=\")', 'FULLVERSION'} ` + | Set-Content -Encoding UTF8 "$($ProjectDir)Properties\AssemblyInfo.cs" \ No newline at end of file diff --git a/.build/winPreBuild.ps1 b/.build/winPreBuild.ps1 new file mode 100644 index 00000000..a26a9300 --- /dev/null +++ b/.build/winPreBuild.ps1 @@ -0,0 +1,40 @@ +param( + [Parameter(Mandatory=$true)] + [String]$ProjectDir, + [Parameter(Mandatory=$true)] + [String]$Arch +) + +if($Env:GIT_VERSION_TAG) +{ + $version = $Env:GIT_VERSION_TAG; +} +else +{ + $version = git describe --long; +} + +$shortVersion = $version.Split('-')[0]; + +[System.Reflection.Assembly]::LoadWithPartialName("System.Web.Extensions") +$versionName = (New-Object System.Web.Script.Serialization.JavaScriptSerializer).Deserialize((Get-Content "$($ProjectDir)..\.build\versionNames.json"), ` + [System.Collections.Hashtable])[([regex]"[0-9]+\.[0-9]+\.").Match($shortVersion).Value] + +$releaseType = switch -wildcard ($shortVersion.Split('.')[2]) +{ + "alpha*" {"Alpha"} + "beta*" {"Beta"} + "rc*" {"RC"} + default {"Release"} +}; + +$fullVersionName = "Vocaluxe $(if($versionName) {"'"+$versionName+"' "} else {''})$shortVersion ($Arch) $(if($releaseType -ne "Release") {'$releaseType '} else {''})($version)" + +(Get-Content -Encoding UTF8 "$($ProjectDir)Properties\AssemblyInfo.cs") ` + | Foreach-Object {$_ ` + -replace '(?<=AssemblyInformationalVersion\(").*(?=")', $version ` + -replace '(?<=(AssemblyVersion|AssemblyFileVersion)\(").*(?=")', ` + ($version.Split('-')[0].replace('alpha','0').replace('beta','1').replace('rc','2') -replace "[a-zA-Z]+","")` + -replace '(?<=AssemblyTitle\(").*(?=")', $fullVersionName ` + -replace '(?<=AssemblyCopyright\(".*)[0-9]+(?=")', (Get-Date).Year} ` + | Set-Content -Encoding UTF8 "$($ProjectDir)Properties\AssemblyInfo.cs" \ No newline at end of file diff --git a/Vocaluxe/Base/CSettings.cs b/Vocaluxe/Base/CSettings.cs index 05c52e2c..917e75bb 100644 --- a/Vocaluxe/Base/CSettings.cs +++ b/Vocaluxe/Base/CSettings.cs @@ -20,8 +20,10 @@ using System.Collections.Generic; using System.IO; using System.Linq; using System.Reflection; +using System.Text; using System.Windows.Forms; using VocaluxeLib; +using VocaluxeLib.Xml; namespace Vocaluxe.Base { @@ -35,6 +37,8 @@ namespace Vocaluxe.Base // ReSharper restore UnusedMember.Global } + + /// /// This class contains settings for the program /// These are not editable, everything that can be changed by the user is in CConfig @@ -52,26 +56,7 @@ namespace Vocaluxe.Base //TODO: This should not be here as it can change //State of the program public static EProgramState ProgramState = EProgramState.Start; - - //Adjusting of programName and version now in the assembly config. - private static readonly Dictionary _CodeNames = new Dictionary() - { - {"0.3.", "Shining Heaven"}, - {"0.4.", "Blue Sunrise"} - }; - - 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 { @@ -208,6 +193,7 @@ namespace Vocaluxe.Base { get { return _Assembly.Name; } } + private static string _Version { get @@ -215,39 +201,10 @@ namespace Vocaluxe.Base return Application.ProductVersion.Split('-').First(); } } - - private static string _GetVersionText() - { - string version = _Version + " (" + _Arch + ")"; - - string gitversion = Application.ProductVersion; - - if (VersionRevision != ERevision.Release || gitversion.Split('-')[1] != "0") - { - version += " " + _GetVersionStatus() + String.Format(" ({0})", gitversion); - } - - return version; - } - + public static string GetFullVersionText() { - string version = ProgramName; - - if (_ProgramCodeName != "") - version += " \"" + _ProgramCodeName + "\""; - - return version + " " + _GetVersionText(); - } - - private static string _GetVersionStatus() - { - string result = ""; - - if (VersionRevision != ERevision.Release) - result = Enum.GetName(typeof(ERevision), VersionRevision); - - return result; + return ((AssemblyTitleAttribute)Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyTitleAttribute), false).First()).Title; } public static float GetRenderAspect() diff --git a/Vocaluxe/Linux/Build/PreBuildEvent.sh b/Vocaluxe/Linux/Build/PreBuildEvent.sh deleted file mode 100755 index 9fe7bd5b..00000000 --- a/Vocaluxe/Linux/Build/PreBuildEvent.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh -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 4cde4f89..348b3386 100644 --- a/Vocaluxe/Properties/AssemblyInfo.cs +++ b/Vocaluxe/Properties/AssemblyInfo.cs @@ -22,7 +22,7 @@ using System.Runtime.InteropServices; // Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern, // die mit einer Assembly verknüpft sind. -[assembly: AssemblyTitle("Vocaluxe")] +[assembly: AssemblyTitle("FULLVERSION")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] diff --git a/Vocaluxe/Vocaluxe.csproj b/Vocaluxe/Vocaluxe.csproj index ef349b8e..010461d9 100644 --- a/Vocaluxe/Vocaluxe.csproj +++ b/Vocaluxe/Vocaluxe.csproj @@ -477,15 +477,14 @@ - 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'} | Foreach-Object {$_ -replace '(?<=(AssemblyVersion|AssemblyFileVersion)\(\").*(?=\")', 'SHORTVERSION'} | Set-Content -Encoding UTF8 '$(ProjectDir)Properties\AssemblyInfo.cs' " + xcopy /E /D /Y "$(ProjectDir)\Website" "$(SolutionDir)\PhoneGap" + powershell -ExecutionPolicy Bypass -File $(SolutionDir)\.build\winPostBuild.ps1 $(ProjectDir) cp -ruT "$(ProjectDir)Website" "$(SolutionDir)/PhoneGap" - $(ProjectDir)Linux/Build/PostBuildEvent.sh $(ProjectDir) + $(SolutionDir)/.build/linuxPostBuildEvent.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 '(?<=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) + powershell -ExecutionPolicy Bypass -File $(SolutionDir)\.build\winPreBuild.ps1 $(ProjectDir) $(Platform) + $(SolutionDir)/.build/linuxPreBuildEvent.sh $(ProjectDir) $(Platform)