-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.fsx
94 lines (73 loc) · 2.72 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
System.IO.Directory.SetCurrentDirectory __SOURCE_DIRECTORY__
#r @"packages/build/FAKE/tools/FakeLib.dll"
open System
open System.IO
open Fake
open Fake.Git
let solutionFile = "StatusPotentiae.sln"
let gitOwner = "TeaDrivenDev"
let gitHome = "https://github.com/" + gitOwner
let gitName = "StatusPotentiae"
let gitRaw = environVarOrDefault "gitRaw" ("https://raw.github.com/" + gitOwner)
let outputDirectory = "bin"
let release = File.ReadAllLines "RELEASE_NOTES.md" |> ReleaseNotesHelper.parseReleaseNotes
Target "AssemblyInfo" (fun _ ->
let fileName = !! "**/AssemblyInfo.fs" |> Seq.head
ReplaceAssemblyInfoVersions (fun p ->
{ p with
OutputFileName = fileName
AssemblyVersion = release.AssemblyVersion
AssemblyFileVersion = release.AssemblyVersion + ".*"
AssemblyInformationalVersion =
let version = System.Version release.AssemblyVersion
sprintf "%i.%i" version.Major version.Minor
})
)
Target "Clean" (fun _ -> CleanDirs [ outputDirectory ])
Target "Build" (fun _ ->
!! solutionFile
|> MSBuildRelease "" "Rebuild"
|> ignore)
Target "Pack" (fun _ ->
let filesToPack =
{
BaseDirectory = outputDirectory
Includes = [ "*.exe"; "*.dll"; "*.config" ]
Excludes = []
}
ZipOfIncludes (outputDirectory + "/StatusPotentiae.zip") ["", filesToPack ]
)
#load "paket-files/build/fsharp/FAKE/modules/Octokit/Octokit.fsx"
open Octokit
Target "ReleaseGitHub" (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 "Release version %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
|> uploadFile "./bin/StatusPotentiae.zip"
|> releaseDraft
|> Async.RunSynchronously
)
"AssemblyInfo"
==> "Clean"
==> "Build"
==> "Pack"
==> "ReleaseGitHub"
RunTargetOrDefault "Build"