|
6 | 6 | #r "packages/FAKE/tools/FakeLib.dll" |
7 | 7 | #load "packages/SourceLink.Fake/tools/SourceLink.fsx" |
8 | 8 | open System |
9 | | -open Fake |
| 9 | +open Fake.AppVeyor |
| 10 | +open Fake |
10 | 11 | open Fake.Git |
11 | 12 | open Fake.ReleaseNotesHelper |
12 | 13 | open Fake.AssemblyInfoFile |
@@ -38,21 +39,35 @@ let netFrameworks = ["v4.0"; "v4.5"] |
38 | 39 |
|
39 | 40 | // Read release notes & version info from RELEASE_NOTES.md |
40 | 41 | let release = LoadReleaseNotes "RELEASE_NOTES.md" |
41 | | -let isAppVeyorBuild = environVar "APPVEYOR" <> null |
42 | | -let nugetVersion = |
43 | | - if isAppVeyorBuild then sprintf "%s-a%s" release.NugetVersion (DateTime.UtcNow.ToString "yyMMddHHmm") |
44 | | - else release.NugetVersion |
| 42 | +let isAppVeyorBuild = buildServer = BuildServer.AppVeyor |
| 43 | +let isVersionTag tag = Version.TryParse tag |> fst |
| 44 | +let hasRepoVersionTag = isAppVeyorBuild && AppVeyorEnvironment.RepoTag && isVersionTag AppVeyorEnvironment.RepoTagName |
| 45 | +let assemblyVersion = if hasRepoVersionTag then AppVeyorEnvironment.RepoTagName else release.NugetVersion |
| 46 | +let buildDate = DateTime.UtcNow |
| 47 | +let buildVersion = |
| 48 | + if hasRepoVersionTag then assemblyVersion |
| 49 | + else if isAppVeyorBuild then sprintf "%s-b%s" assemblyVersion AppVeyorEnvironment.BuildNumber |
| 50 | + else sprintf "%s-a%s" assemblyVersion (buildDate.ToString "yyMMddHHmm") |
45 | 51 |
|
46 | 52 | Target "BuildVersion" (fun _ -> |
47 | | - Shell.Exec("appveyor", sprintf "UpdateBuild -Version \"%s\"" nugetVersion) |> ignore |
| 53 | + Shell.Exec("appveyor", sprintf "UpdateBuild -Version \"%s\"" buildVersion) |> ignore |
48 | 54 | ) |
49 | 55 |
|
50 | 56 | // Generate assembly info files with the right version & up-to-date information |
51 | 57 | Target "AssemblyInfo" (fun _ -> |
52 | | - let fileName = "src/assemblyinfo/assemblyinfo.shared.fs" |
53 | | - CreateFSharpAssemblyInfo fileName |
54 | | - [ Attribute.Version release.AssemblyVersion |
55 | | - Attribute.FileVersion release.AssemblyVersion] |
| 58 | + let fileName = "src/assemblyinfo/assemblyinfo.shared.fs" |
| 59 | + // add json info to the informational version |
| 60 | + let iv = Text.StringBuilder() // json |
| 61 | + iv.Appendf "{\\\"buildVersion\\\":\\\"%s\\\"" buildVersion |
| 62 | + iv.Appendf ",\\\"buildDate\\\":\\\"%s\\\"" (buildDate.ToString "yyyy'-'MM'-'dd'T'HH':'mm':'sszzz") |
| 63 | + if isAppVeyorBuild then |
| 64 | + iv.Appendf ",\\\"gitCommit\\\":\\\"%s\\\"" AppVeyor.AppVeyorEnvironment.RepoCommit |
| 65 | + iv.Appendf ",\\\"gitBranch\\\":\\\"%s\\\"" AppVeyor.AppVeyorEnvironment.RepoBranch |
| 66 | + iv.Appendf "}" |
| 67 | + CreateFSharpAssemblyInfo fileName |
| 68 | + [ Attribute.Version assemblyVersion |
| 69 | + Attribute.FileVersion assemblyVersion |
| 70 | + Attribute.InformationalVersion iv.String ] |
56 | 71 | ) |
57 | 72 |
|
58 | 73 | // -------------------------------------------------------------------------------------- |
@@ -136,7 +151,7 @@ Target "NuGet" (fun _ -> |
136 | 151 | Project = project |
137 | 152 | Summary = summary |
138 | 153 | Description = description |
139 | | - Version = nugetVersion |
| 154 | + Version = buildVersion |
140 | 155 | ReleaseNotes = release.Notes |> toLines |
141 | 156 | Tags = tags |
142 | 157 | OutputPath = "bin" |
@@ -167,7 +182,7 @@ Target "ReleaseDocs" (fun _ -> |
167 | 182 | fullclean tempDocsDir |
168 | 183 | CopyRecursive "docs/output" "temp/gh-pages" true |> printfn "%A" |
169 | 184 | StageAll tempDocsDir |
170 | | - Commit tempDocsDir (sprintf "Update generated documentation for version %s" release.NugetVersion) |
| 185 | + Commit tempDocsDir (sprintf "Update generated documentation for version %s" buildVersion) |
171 | 186 | Branches.push "temp/gh-pages" |
172 | 187 | ) |
173 | 188 |
|
|
0 commit comments