-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.fsx
99 lines (79 loc) · 2.76 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
System.IO.Directory.SetCurrentDirectory __SOURCE_DIRECTORY__
#r "paket:
nuget Fake.Api.GitHub
nuget Fake.Core.ReleaseNotes
nuget Fake.Core.Target
nuget Fake.DotNet.AssemblyInfoFile
nuget Fake.DotNet.MSBuild
nuget Fake.IO.FileSystem
nuget Fake.IO.Zip
nuget Fake.Tools.Git
nuget Octokit
//"
#load ".fake/build.fsx/intellisense.fsx"
open Fake.Api
open Fake.Core
open Fake.Core.TargetOperators
open Fake.DotNet
open Fake.IO
open Fake.IO.Globbing
open Fake.IO.Globbing.Operators
open Fake.Tools
let solutionFile = "Amagatsha.sln"
let gitOwner = "TeaDrivenDev"
let gitHome = "https://github.com/" + gitOwner
let gitName = "Amagatsha"
let gitRaw = Environment.environVarOrDefault "gitRaw" ("https://raw.github.com/" + gitOwner)
let outputDirectory = "bin"
let release = ReleaseNotes.load "RELEASE_NOTES.md"
Target.create "AssemblyInfo" (fun _ ->
let fileName = !! "**/AssemblyInfo.fs" |> Seq.head
[
AssemblyInfo.Title "Amagatsha"
AssemblyInfo.Product "Amagatsha"
AssemblyInfo.Copyright "Copyright © TeaDrivenDev 2019"
AssemblyInfo.ComVisible false
AssemblyInfo.Version release.AssemblyVersion
]
|> AssemblyInfoFile.createFSharp fileName
)
Target.create "Clean" (fun _ -> Shell.cleanDirs [ outputDirectory ])
Target.create "Build" (fun _ ->
!! solutionFile
|> MSBuild.runRelease id "" "Rebuild"
|> ignore)
Target.create "Pack" (fun _ ->
let filesToPack =
{
BaseDirectory = outputDirectory
Includes = [ "*.exe"; "*.dll"; "*.config" ]
Excludes = []
}
:> IGlobbingPattern
Zip.createZipOfIncludes (outputDirectory + "/Amagatsha.zip") "" 5 ["", filesToPack ]
)
Target.create "ReleaseGitHub" (fun _ ->
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]
Git.Staging.stageAll ""
Git.Commit.exec "" (sprintf "Release version %s" release.NugetVersion)
Git.Branches.pushBranch "" remote (Git.Information.getBranchName "")
Git.Branches.tag "" release.NugetVersion
Git.Branches.pushTag "" remote release.NugetVersion
// release on GitHub
GitHub.createClientWithToken (Environment.environVarOrFail "githubtoken")
|> GitHub.draftNewRelease gitOwner gitName release.NugetVersion (release.SemVer.PreRelease <> None) release.Notes
|> GitHub.uploadFile "./bin/Amagatsha.zip"
|> GitHub.publishDraft
|> Async.RunSynchronously
)
"AssemblyInfo"
==> "Clean"
==> "Build"
==> "Pack"
==> "ReleaseGitHub"
Target.runOrDefault "Build"
printfn "\nFinished %s\n" (System.DateTime.Now.ToString "HH:mm:ss")