Skip to content
This repository has been archived by the owner on Oct 6, 2020. It is now read-only.

Commit

Permalink
Tweaking build scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
StanleyGoldman committed Sep 9, 2019
1 parent 07d9538 commit d9f0c6f
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 3 deletions.
33 changes: 31 additions & 2 deletions Build.fsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#r "paket: groupref FakeBuild //"
#load "./.fake/build.fsx/intellisense.fsx"

open System.Text.RegularExpressions
open Fake.IO
open Fake.BuildServer
open Fake.IO.Globbing.Operators
Expand All @@ -15,14 +16,28 @@ BuildServer.install [
let isAppveyor = AppVeyor.detect()
let gitVersion = GitVersion.generateProperties id

let replacementVersion, fullSemver =
if (Git.Information.getBranchName(Shell.pwd()) = "master") then
CreateProcess.fromRawCommandLine "node" (sprintf "%s\\npm\\node_modules\\commit-analyzer-cli\\bin\\index.js" (Environment.environVarOrFail "APPDATA"))
|> CreateProcess.redirectOutput
|> CreateProcess.map (fun t ->
Trace.log t.Result.Error
t.Result.Output.Trim()
|> function
| x when String.isNullOrWhiteSpace(x) -> None, gitVersion.FullSemVer
| x -> Some(x), x
)
|> Proc.run
else None, gitVersion.FullSemVer

Target.create "Clean" (fun _ ->
["reports" ; "build" ; "src/common"]
|> Seq.iter Directory.delete


let configuration: (DotNet.Options -> DotNet.Options) = (fun t -> {t with
Verbosity = Some DotNet.Verbosity.Minimal})

DotNet.exec configuration "clean" "SonOfPicasso.sln"
|> ignore
)
Expand All @@ -32,6 +47,20 @@ Target.create "Build" (fun _ ->
|> Proc.run
|> ignore

match replacementVersion with
| None -> ()
| Some version ->
let sha = Git.Information.getCurrentSHA1(Shell.pwd())

Fake.IO.File.readAsString "./src/common/SharedAssemblyInfo.cs"
|> (fun t -> Regex.Replace(t, "AssemblyFileVersion\\(\"(.*?)\"\\)", sprintf "AssemblyFileVersion(\"%s.0\")" version))
|> (fun t -> Regex.Replace(t, "AssemblyVersion\\(\"(.*?)\"\\)", sprintf "AssemblyVersion(\"%s.0\")" version))
|> (fun t -> Regex.Replace(t, "AssemblyInformationalVersion\\(\"(.*?)\"\\)", sprintf "AssemblyInformationalVersion(\"%s+Branch.master.Sha.%s\")" version sha))
|> Fake.IO.File.writeString false "./src/common/SharedAssemblyInfo.cs"

if isAppveyor then
AppVeyor.updateBuild (fun t -> {t with Version = (sprintf "%s" version)})

let configuration: (DotNet.BuildOptions -> DotNet.BuildOptions)
= (fun t -> {t with
Configuration = DotNet.BuildConfiguration.Release})
Expand Down Expand Up @@ -92,7 +121,7 @@ Target.create "TestData" (fun _ ->
)

Target.create "Package" (fun _ ->
let packagePath = (sprintf "build/son-of-picasso-%s.zip" gitVersion.FullSemVer)
let packagePath = (sprintf "build/son-of-picasso-%s.zip" fullSemver)

Directory.ensure "build"

Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ install:
- choco install dotnetcore-sdk --version 3.0.100-preview9-014004 --pre
- choco install codecov --no-progress --confirm
- choco install gitversion.portable --no-progress --confirm
- npm install -g semantic-release @semantic-release/changelog @semantic-release/git
- npm install -g semantic-release @semantic-release/changelog @semantic-release/git commit-analyzer-cli
cache:
- '%LOCALAPPDATA%\Temp\Chocolatey -> appveyor.yml'
- '.fake -> Build.fsx'
Expand Down
1 change: 1 addition & 0 deletions paket.dependencies
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ group FakeBuild
nuget Fake.BuildServer.AppVeyor
nuget Fake.DotNet.Cli
nuget Fake.IO.Zip
nuget Fake.Tools.Git
nuget Fake.Tools.GitVersion
groupref FakeBuildResources

Expand Down
8 changes: 8 additions & 0 deletions paket.lock
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,14 @@ NUGET
Fake.Core.Trace (>= 5.16.1)
FSharp.Core (>= 4.7)
System.Net.Http (>= 4.3.4)
Fake.Tools.Git (5.16.1)
Fake.Core.Environment (>= 5.16.1)
Fake.Core.Process (>= 5.16.1)
Fake.Core.SemVer (>= 5.16.1)
Fake.Core.String (>= 5.16.1)
Fake.Core.Trace (>= 5.16.1)
Fake.IO.FileSystem (>= 5.16.1)
FSharp.Core (>= 4.7)
Fake.Tools.GitVersion (5.16.1)
Fake.Core.Environment (>= 5.16.1)
Fake.Core.Process (>= 5.16.1)
Expand Down

0 comments on commit d9f0c6f

Please sign in to comment.