@@ -5,13 +5,13 @@ open Fake.DotNet
55open Fake.IO
66open Fake.IO .Globbing .Operators
77open Fake.Core .TargetOperators
8- open Fake.DotNet . Testing
8+ open Fake.BuildServer
99
10- Target.initEnvironment()
10+ Target.initEnvironment ()
1111
1212let sln = " ./FSharp.CosmosDb.sln"
1313
14- let getChangelog () =
14+ let getChangelog () =
1515 let changelog = " CHANGELOG.md" |> Changelog.load
1616 changelog.LatestEntry
1717
@@ -23,64 +23,75 @@ let isRelease (targets: Target list) =
2323let configuration ( targets : Target list ) =
2424 let defaultVal =
2525 if isRelease targets then " Release" else " Debug"
26+
2627 match Environment.environVarOrDefault " CONFIGURATION" defaultVal with
2728 | " Debug" -> DotNet.BuildConfiguration.Debug
2829 | " Release" -> DotNet.BuildConfiguration.Release
2930 | config -> DotNet.BuildConfiguration.Custom config
3031
32+ let getVersionNumber ( changeLog : Changelog.ChangelogEntry ) ( targets : Target list ) =
33+ match GitHubActions.Environment.CI false , isRelease targets with
34+ | ( true , true ) -> changeLog.NuGetVersion
35+ | ( true , false ) -> sprintf " %s -ci-%s " changeLog.NuGetVersion GitHubActions.Environment.RunId
36+ | (_, _) -> changeLog.NuGetVersion
37+
3138Target.create " Clean" ( fun _ ->
3239 DotNet.exec id " clean" " " |> ignore
33- !! " ./.nuget" |> Shell.cleanDirs)
40+ !! " ./.nuget" |> Shell.cleanDirs)
3441
3542Target.create " Restore" ( fun _ -> DotNet.restore id sln)
3643
3744Target.create " Build" ( fun ctx ->
38- let changelog = getChangelog()
45+ let changelog = getChangelog ()
3946
4047 let args =
41- [ sprintf " /p:PackageVersion=%s " ( changelog.NuGetVersion )
48+ [ sprintf " /p:PackageVersion=%s " ( getVersionNumber changelog ( ctx.Context.AllExecutingTargets ) )
4249 " --no-restore" ]
50+
4351 DotNet.build ( fun c ->
4452 { c with
4553 Configuration = configuration ( ctx.Context.AllExecutingTargets)
4654 Common = c.Common |> DotNet.Options.withAdditionalArgs args }) sln)
4755
4856Target.create " Publish" ( fun ctx ->
49- let changelog = getChangelog()
57+ let changelog = getChangelog ()
5058
5159 let args =
52- [ sprintf " /p:PackageVersion=%s " ( changelog.NuGetVersion )
60+ [ sprintf " /p:PackageVersion=%s " ( getVersionNumber changelog ( ctx.Context.AllExecutingTargets ) )
5361 " --no-restore"
5462 " --no-build" ]
63+
5564 DotNet.publish ( fun c ->
5665 { c with
5766 Configuration = configuration ( ctx.Context.AllExecutingTargets)
5867 Common = c.Common |> DotNet.Options.withAdditionalArgs args }) sln)
5968
6069Target.create " Package" ( fun ctx ->
61- let changelog = getChangelog()
70+ let changelog = getChangelog ()
6271
6372 let args =
64- [ sprintf " /p:PackageVersion=%s " ( changelog.NuGetVersion )
73+ [ sprintf " /p:PackageVersion=%s " ( getVersionNumber changelog ( ctx.Context.AllExecutingTargets ) )
6574 sprintf " /p:PackageReleaseNotes=\" %s \" " ( sprintf " %O " changelog) ]
75+
6676 DotNet.pack ( fun c ->
6777 { c with
6878 Configuration = configuration ( ctx.Context.AllExecutingTargets)
6979 OutputPath = Some " ./.nupkg"
7080 Common = c.Common |> DotNet.Options.withAdditionalArgs args }) sln)
7181
7282Target.create " PackageVersion" ( fun _ ->
73- let version = getChangelog()
83+ let version = getChangelog ()
7484 printfn " The version is %s " version.NuGetVersion)
7585
7686Target.create " Changelog" ( fun _ ->
77- let changelog = getChangelog()
87+ let changelog = getChangelog ()
7888 Directory.ensure " ./.nupkg"
7989
80- [| sprintf " %O " changelog |] |> File.append " ./.nupkg/changelog.md" )
90+ [| sprintf " %O " changelog |]
91+ |> File.append " ./.nupkg/changelog.md" )
8192
8293Target.create " SetVersionForCI" ( fun _ ->
83- let changelog = getChangelog()
94+ let changelog = getChangelog ()
8495 printfn " ::set-env name=package_version::%s " changelog.NuGetVersion)
8596
8697Target.create " Test" ( fun _ -> DotNet.test id sln)
@@ -90,14 +101,20 @@ Target.create "RunAnalyzer" (fun ctx ->
90101 sprintf
91102 " --project samples/FSharp.CosmosDb.Samples/FSharp.CosmosDb.Samples.fsproj --analyzers-path src/FSharp.CosmosDb.Analyzer/bin/%A /netcoreapp2.0/publish"
92103 ( configuration ( ctx.Context.AllExecutingTargets))
104+
93105 DotNet.exec id " fsharp-analyzers" args |> ignore)
94106
95107Target.create " Default" ignore
96108Target.create " Release" ignore
97109
98110" Clean" ==> " Restore" ==> " Build" ==> " Default"
99111
100- " Default" ==> " Publish" ==> " Test" ==> " Package" ==> " Changelog" ==> " Release"
112+ " Default"
113+ ==> " Publish"
114+ ==> " Test"
115+ ==> " Package"
116+ ==> " Changelog"
117+ ==> " Release"
101118
102119" Default" ==> " Publish" ==> " RunAnalyzer"
103120
0 commit comments