-
Notifications
You must be signed in to change notification settings - Fork 0
/
Build.fsx
83 lines (66 loc) · 2.63 KB
/
Build.fsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#r "paket:
storage: none
source https://api.nuget.org/v3/index.json
nuget FSharp.Core 4.3.4 // https://github.com/fsharp/FAKE/issues/2001
nuget Fake.Core.Target
nuget Fake.DotNet.Cli
nuget Fake.IO.FileSystem
nuget Fake.BuildServer.AppVeyor
//"
#load "./.fake/build.fsx/intellisense.fsx"
#if !FAKE
#r "netstandard"
#endif
open System
open System.Diagnostics
open Fake.Core
open Fake.DotNet
open Fake.IO
open System.Threading
open System.IO
open Fake.Core
// Init buildserver
Fake.Core.BuildServer.install [ Fake.BuildServer.AppVeyor.Installer ]
let (@@) a b = Path.combine a b
let root = __SOURCE_DIRECTORY__
let inline withWorkDir wd = DotNet.Options.withWorkingDirectory wd
let justBuild() =
DotNet.build (fun o -> { o with Configuration = DotNet.BuildConfiguration.Release }) (root @@ "src\\Fable.TSInterop.Ex\\Fable.TSInterop.Ex.fsproj")
let publishToNuget(v:string) =
// dotnet pack does a build
DotNet.pack (fun o ->
{ o with Configuration = DotNet.BuildConfiguration.Release
OutputPath = Some (root @@ "nupkg")
MSBuildParams = { MSBuild.CliArguments.Create() with Properties = ["Version",v; "PackageVersion",v] }
}) (root @@ "src\\Fable.TSInterop.Ex\\Fable.TSInterop.Ex.fsproj")
let nupkgs = System.IO.Directory.GetFiles(root @@ "nupkg", "*.nupkg", SearchOption.AllDirectories)
match nupkgs with
| [| |] -> failwith "found no nupkgs"
| [| f |] ->
DotNet.nugetPush (fun o -> { o with
PushParams = { o.PushParams with
Source = Some "https://api.nuget.org/v3/index.json"
ApiKey = Some (Fake.Core.Environment.environVarOrFail "NUGET_API_KEY") } }) f
| _ -> failwithf "found more than one nupkg"
Target.create "BuildRelease" (fun _ ->
justBuild()
)
Target.create "AppVeyor" (fun _ ->
if not (Fake.BuildServer.AppVeyor.detect()) then
failwith "expected to be run on appveyor"
if Fake.BuildServer.AppVeyor.Environment.RepoTag then
let tagName = Fake.BuildServer.AppVeyor.Environment.RepoTagName
if tagName.StartsWith("release-") then
let version = tagName.Substring("release-".Length)
publishToNuget(version)
else if tagName.StartsWith("prerelease-") then
let version = tagName.Substring("prerelease-".Length)
publishToNuget(version)
else
// other, unknown tag
justBuild()
else
// no tag, just build
justBuild()
)
Target.runOrDefault "BuildRelease"