forked from jichang/Suave.Template
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.fsx
101 lines (81 loc) · 2.66 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
#r @"packages/FAKE/tools/FakeLib.dll"
#load "paket-files/fsharp/FAKE/modules/Octokit/Octokit.fsx"
open System
open Fake
open Fake.ReleaseNotesHelper
open Octokit
let templatePath = "./Content/.template.config/template.json"
let templateName = "Suave"
let nupkgDir = FullName "./nupkg"
let release = LoadReleaseNotes "RELEASE_NOTES.md"
let formattedRN =
release.Notes
|> List.map (sprintf "* %s")
|> String.concat "\n"
Target "Clean" (fun () ->
CleanDirs [
nupkgDir
]
)
Target "Pack" (fun () ->
RegexReplaceInFileWithEncoding
" \"name\": .+,"
(" \"name\": \"" + templateName + " v" + release.NugetVersion + "\",")
System.Text.Encoding.UTF8
templatePath
DotNetCli.Pack ( fun args ->
{ args with
OutputPath = nupkgDir
AdditionalArgs =
[
sprintf "/p:PackageVersion=%s" release.NugetVersion
sprintf "/p:PackageReleaseNotes=\"%s\"" formattedRN
]
}
)
)
Target "ReleaseGitHub" (fun _ ->
let remoteGit = "origin"
let commitMsg = sprintf "Bumping version to %O" release.NugetVersion
let tagName = string release.NugetVersion
let gitOwner = "SuaveIO"
let gitName = "Suave.Template"
Git.Branches.checkout "" false "master"
Git.CommandHelper.directRunGitCommand "" "fetch origin" |> ignore
Git.CommandHelper.directRunGitCommand "" "fetch origin --tags" |> ignore
Git.Staging.StageAll ""
Git.Commit.Commit "" commitMsg
Git.Branches.pushBranch "" remoteGit "master"
Git.Branches.tag "" tagName
Git.Branches.pushTag "" remoteGit tagName
let client =
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: "
createClient user pw
let file = !! (nupkgDir </> "*.nupkg") |> Seq.head
// release on github
client
|> createDraft gitOwner gitName release.NugetVersion (release.SemVer.PreRelease <> None) release.Notes
|> uploadFile file
|> releaseDraft
|> Async.RunSynchronously
)
Target "Push" (fun () ->
let key =
match getBuildParam "nuget-key" with
| s when not (String.IsNullOrWhiteSpace s) -> s
| _ -> getUserPassword "NuGet Key: "
Paket.Push (fun p -> { p with WorkingDir = nupkgDir; ApiKey = key }))
Target "Release" DoNothing
"Clean"
==> "Pack"
==> "ReleaseGitHub"
==> "Push"
==> "Release"
RunTargetOrDefault "Pack"