Skip to content

Commit

Permalink
_ is invalid
Browse files Browse the repository at this point in the history
  • Loading branch information
matthid committed May 12, 2018
1 parent 7226b22 commit ec6d3bb
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions build.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -352,28 +352,33 @@ let version =
let segToString = function
| PreReleaseSegment.AlphaNumeric n -> n
| PreReleaseSegment.Numeric n -> string n

let createAlphaNum (s:string) =
PreReleaseSegment.AlphaNumeric (s.Replace("_", "-"))
let source =
match BuildServer.buildServer with
| _ when MyGitLab.isGitLabCi ->
// Workaround for now
// We get CI_COMMIT_REF_NAME=master and CI_COMMIT_SHA

[ PreReleaseSegment.AlphaNumeric "release"
PreReleaseSegment.AlphaNumeric MyGitLab.Environment.CommitRefName
PreReleaseSegment.AlphaNumeric MyGitLab.Environment.PipelineId ]
let branchPath =
MyGitLab.Environment.CommitRefName.Split('/')
|> Seq.map createAlphaNum
[ yield PreReleaseSegment.AlphaNumeric "gitlab"
yield! branchPath
yield PreReleaseSegment.AlphaNumeric MyGitLab.Environment.PipelineId ]
| BuildServer.TeamFoundation ->
let sourceBranch = MyTeamFoundation.Environment.BuildSourceBranch
let isPr = sourceBranch.StartsWith "refs/pull/"
let firstSegment =
if isPr then
let splits = sourceBranch.Split '/'
let prNum = bigint (int splits.[2])
[ PreReleaseSegment.AlphaNumeric "pr"; PreReleaseSegment.Numeric prNum ]
else [ PreReleaseSegment.AlphaNumeric "release" ]
[ PreReleaseSegment.AlphaNumeric "pr"; PreReleaseSegment.AlphaNumeric "vsts"; PreReleaseSegment.Numeric prNum ]
else
let branchPath = sourceBranch.Split('/') |> Seq.skip 2 |> Seq.map createAlphaNum
[ yield PreReleaseSegment.AlphaNumeric "vsts"
yield! branchPath ]
let buildId = bigint (int MyTeamFoundation.Environment.BuildId)
[ yield! firstSegment
yield PreReleaseSegment.AlphaNumeric MyTeamFoundation.Environment.BuildSourceBranchName
yield PreReleaseSegment.Numeric buildId
]
| _ -> []
Expand All @@ -388,6 +393,7 @@ let version =
Some ({p with Values = p.Values @ source; Origin = p.Origin + toAdd })
{ semVer with PreRelease = prerelease; Original = None }
let nugetVersion = version.AsString
Trace.setBuildNumber nugetVersion

//let current = CoreTracing.getListeners()
//if current |> Seq.contains CoreTracing.defaultConsoleTraceListener |> not then
Expand Down

0 comments on commit ec6d3bb

Please sign in to comment.