Permalink
Browse files

Introducing GitVersion for getting the tag version

  • Loading branch information...
einari committed Jan 18, 2017
1 parent b7ed95a commit 134a1996f25f7e158a6d1f36564284d8e0c3f314
Showing with 31 additions and 2 deletions.
  1. +1 −0 build.cmd
  2. +29 −2 build.fsx
  3. +1 −0 build.sh
View
@@ -31,6 +31,7 @@ pushd %~dp0
%NUGET_DIR%\NuGet.exe install FAKE -ConfigFile %NUGET_DIR%\Nuget.Config -OutputDirectory %PACKAGE_DIR% -ExcludeVersion -Version 4.16.1
%NUGET_DIR%\NuGet.exe install FSharp.Data -ConfigFile %NUGET_DIR%\Nuget.Config -OutputDirectory %PACKAGE_DIR%\FAKE -ExcludeVersion -Version 2.3.2
%NUGET_DIR%\NuGet.exe install GitVersion.CommandLine -ConfigFile %NUGET_DIR%\Nuget.Config -OutputDirectory %PACKAGE_DIR% -ExcludeVersion -Version 3.6.5
rem cls
View
@@ -86,15 +86,42 @@ let performGitCommand arguments =
failwith ("Couldn't get the current tag for versioning: \r\n" + proc.StandardError.ReadToEnd())
result
let gitVersion repositoryDir =
let isWindows = System.Environment.OSVersion.Platform = PlatformID.Win32NT
let arguments = sprintf "%s /output json /showvariable SemVer" repositoryDir
let gitVersionExecutable = "Source/Solutions/packages/GitVersion.CommandLine/tools/GitVersion.exe"
let processName = if isWindows then gitVersionExecutable else "mono"
let fullArguments = if isWindows then arguments else sprintf "%s %s" gitVersionExecutable arguments
let startInfo = new System.Diagnostics.ProcessStartInfo(processName)
startInfo.Arguments <- fullArguments
startInfo.RedirectStandardInput <- true
startInfo.RedirectStandardOutput <- true
startInfo.RedirectStandardError <- true
startInfo.UseShellExecute <- false
startInfo.CreateNoWindow <- true
use proc = new System.Diagnostics.Process(StartInfo = startInfo)
proc.Start() |> ignore
let reader = new System.IO.StreamReader(proc.StandardOutput.BaseStream, System.Text.Encoding.UTF8)
let result = reader.ReadToEnd()
proc.WaitForExit()
if proc.ExitCode <> 0 then
failwith ("Couldn't get the current tag for versioning: \r\n" + proc.StandardError.ReadToEnd())
result
let getLatestTag repositoryDir =
//let commitSha = performGitCommand "rev-list --tags --max-count=1"
performGitCommand (sprintf "describe --tag --abbrev=0")
let getVersionFromGitTag(buildNumber:int) =
trace "Get version from Git tag"
let gitVersionTag = getLatestTag "./"
let gitVersionTag = gitVersion "./"
tracef "Git tag version : %s" gitVersionTag
new BuildVersion(gitVersionTag, buildNumber, true)
View
@@ -22,6 +22,7 @@ fi
mono $NUGET_PATH/NuGet.exe update -self
mono $NUGET_PATH/NuGet.exe install FAKE -OutputDirectory $PACKAGES_PATH -ExcludeVersion -Version 4.16.1
mono $NUGET_PATH/NuGet.exe install FSharp.Data -OutputDirectory $PACKAGES_PATH/FAKE -ExcludeVersion -Version 2.3.2
mono $NUGET_PATH/NuGet.exe install GitVersion.CommandLine -OutputDirectory $PACKAGES_PATH -ExcludeVersion -Version 3.6.5
export encoding=utf-8

0 comments on commit 134a199

Please sign in to comment.