-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.fsx
123 lines (97 loc) · 3.51 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
// include Fake libs
#r "./packages/build/FAKE/tools/FakeLib.dll"
#r "System.IO.Compression.FileSystem"
open System
open System.IO
open Fake
open Fake.NpmHelper
open Fake.ReleaseNotesHelper
open Fake.Git
// Filesets
let projects = !! "src/**.fsproj"
let dotnetcliVersion = "2.1.402"
let mutable dotnetExePath = "dotnet"
let runDotnet workingDir =
DotNetCli.RunCommand (fun p -> { p with ToolPath = dotnetExePath
WorkingDir = workingDir } )
Target "InstallDotNetCore" (fun _ ->
dotnetExePath <- DotNetCli.InstallDotNetSDK dotnetcliVersion
)
Target "Clean" (fun _ ->
CleanDir "src/obj"
CleanDir "src/bin"
runDotnet "src" "restore"
)
Target "Build" (fun _ ->
runDotnet "src" "build"
)
let release = LoadReleaseNotes "RELEASE_NOTES.md"
Target "Meta" (fun _ ->
[ "<Project xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">"
"<PropertyGroup>"
"<Description>Fable bindings for React Grid System</Description>"
"<PackageProjectUrl>https://github.com/Prolucid/fable-react-grid-system</PackageProjectUrl>"
"<PackageLicenseUrl>https://raw.githubusercontent.com/prolucid/fable-grid-system/master/LICENSE</PackageLicenseUrl>"
"<RepositoryUrl>https://github.com/Prolucid/fable-react-grid-system.git</RepositoryUrl>"
"<PackageTags>responsive;design;react;fsharp;fable</PackageTags>"
"<Authors>Justin Sacks</Authors>"
sprintf "<Version>%s</Version>" (string release.SemVer)
"</PropertyGroup>"
"</Project>"]
|> WriteToFile false "Directory.Build.props"
)
// --------------------------------------------------------------------------------------
// Build a NuGet package
Target "Package" (fun _ ->
runDotnet "src" "pack -c Release"
)
Target "PublishNuget" (fun _ ->
let args = sprintf "nuget push Fable.ReactGridSystem.%s.nupkg -s nuget.org -k %s" (string release.SemVer) (environVar "nugetkey")
runDotnet "src/bin/Release" args
)
let gitOwner = "prolucid"
let gitName = "fable-react-grid-system"
let gitHome= sprintf "https://github.com/%s" gitOwner
#load "paket-files/build/fsharp/FAKE/modules/Octokit/Octokit.fsx"
open Octokit
Target "Release" (fun _ ->
let user =
match getBuildParam "github-user" with
| s when not (String.IsNullOrWhiteSpace s) -> s
| _ -> getUserInput "Username: "
let pw =
match getBuildParam "github-pw" with
| s when not (String.IsNullOrWhiteSpace s) -> s
| _ -> getUserPassword "Password: "
let remote =
Git.CommandHelper.getGitResult "" "remote -v"
|> Seq.filter (fun (s: string) -> s.EndsWith("(push)"))
|> Seq.tryFind (fun (s: string) -> s.Contains(gitOwner + "/" + gitName))
|> function None -> gitHome + "/" + gitName | Some (s: string) -> s.Split().[0]
StageAll ""
Git.Commit.Commit "" (sprintf "Bump version to %s" release.NugetVersion)
Branches.pushBranch "" remote (Information.getBranchName "")
Branches.tag "" release.NugetVersion
Branches.pushTag "" remote release.NugetVersion
// release on github
createClient user pw
|> createDraft gitOwner gitName release.NugetVersion (release.SemVer.PreRelease <> None) release.Notes
|> releaseDraft
|> Async.RunSynchronously
)
Target "Publish" DoNothing
// Build order
"Clean"
==> "Meta"
==> "InstallDotNetCore"
// ==> "Install"
==> "Build"
// ==> "Test"
==> "Package"
"Publish"
<== [ "Build"
"Package"
"PublishNuget"
"Release" ]
// start build
RunTargetOrDefault "Build"