Skip to content

Commit

Permalink
Update CI config, and change how build script release/debug is passed…
Browse files Browse the repository at this point in the history
… (see extended commit description)

Build config is now passed like: `./build.sh -t Build -- Debug` or `./build.sh -t Build -- Release`
  • Loading branch information
jwosty committed Aug 4, 2024
1 parent 67f2b67 commit 0a6aefb
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 46 deletions.
30 changes: 15 additions & 15 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,22 @@ jobs:
build-windows:
name: CI (Windows)
runs-on: windows-latest
timeout-minutes: 25

steps:
- uses: actions/checkout@v2
- uses: actions/setup-dotnet@v1
- uses: actions/checkout@v3
- uses: actions/setup-dotnet@v3
with:
dotnet-version: '6.0.400'
dotnet-version: 8.0.x
- name: Restore
run: |
dotnet tool restore
dotnet paket restore
- name: Build
run: dotnet fake build
run: .\build.cmd -t Build
- name: Pack
run: |
dotnet fake build -t PackAll
.\build.cmd -t PackAll
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
Expand All @@ -33,29 +34,28 @@ jobs:
build-macos:
name: CI (macOS)
runs-on: macos-latest
timeout-minutes: 25

steps:
- uses: actions/checkout@v2
- uses: actions/setup-dotnet@v1
- uses: actions/checkout@v3
- uses: actions/setup-dotnet@v3
with:
dotnet-version: '6.0.400'
- name: Install workloads
run: |
dotnet tool restore
sudo dotnet workload install macos
dotnet-version: 8.0.3
- name: Restore
run: |
sudo dotnet workload install macos
dotnet tool restore
dotnet paket restore
dotnet restore Interstellar.MacOS.sln
- name: Build
run: dotnet fake build -- Release
run: ./build.sh -t Build
- name: Pack
run: dotnet fake build -t PackAll -- Release
run: ./build.sh -t PackAll
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: interstellar-macos
path: artifacts/
- name: Test
run: |
dotnet fake build -t Test -- Release
./build.sh -t Test
67 changes: 36 additions & 31 deletions build/build.fs
Original file line number Diff line number Diff line change
Expand Up @@ -112,24 +112,29 @@ let addVersionInfo (versionInfo: PackageVersionInfo) =
"VersionPrefix", versionPrefix
match versionSuffix with Some versionSuffix -> "VersionSuffix", versionSuffix | _ -> ()
"PackageReleaseNotes", versionInfo.versionChanges
]
]

let projects = [
yield Projects.coreLib
if Environment.isWindows then yield! [Projects.chromiumLib; Projects.winFormsLib; Projects.wpfLib]
if Environment.isMacOS then yield! [Projects.macosWkLib]
]

let buildOptions setParams =
let buildMode = Environment.environVarOrDefault "buildMode" "Release"
let msBuildCfg (args: TargetParameter) =
args.Context.Arguments
|> List.tryPick (fun x -> if x.ToLower () = "debug" then Some "Debug" else None)
|> Option.defaultValue "Release"

let buildOptions args setParams =
let buildMode = msBuildCfg args
let commit = Git.Information.getCurrentSHA1 repoDir

quiet <<
setParams <<
addProperties ["Configuration", buildMode; "RepositoryCommit", commit] <<
addVersionInfo (currentVersionInfo.Force()) << setParams

let dotnetBuild (setParams: DotNet.BuildOptions -> DotNet.BuildOptions) project = project |> DotNet.build (buildOptions setParams)
let dotnetBuild args (setParams: DotNet.BuildOptions -> DotNet.BuildOptions) project = project |> DotNet.build (buildOptions args setParams)

// *** Define Targets ***
let PackageDescription _ =
Expand All @@ -143,10 +148,10 @@ let doRestore (dotnetBuildOptions: DotNet.BuildOptions) = { dotnetBuildOptions w
let getNupkgPath version (projPath: string) =
let vstr = match version with Some v -> sprintf ".%s" v | None -> ""
let projDir = Path.GetDirectoryName projPath
Path.Combine ([|projDir; "bin"; "Release";
sprintf "%s%s.nupkg" (Path.GetFileNameWithoutExtension projPath) vstr|])
Path.Combine [|projDir; "bin"; "Release";
sprintf "%s%s.nupkg" (Path.GetFileNameWithoutExtension projPath) vstr|]

let Clean _ =
let Clean args =
Trace.log " --- Cleaning --- "
for proj in projects do
let vstr = currentVersionInfo.Force().versionName
Expand All @@ -157,7 +162,7 @@ let Clean _ =
else if Environment.isMacOS then [ yield Solutions.macos; for p in Templates.macosProjects -> p ]
else []
for proj in projects do
dotnetBuild (addTarget "Clean") proj
dotnetBuild args (addTarget "Clean") proj
Shell.deleteDir ".fsdocs"
Shell.deleteDir "output"
Shell.deleteDir "temp"
Expand All @@ -181,29 +186,29 @@ let Restore _ =
// DotNet.restore id proj
DotNet.restore id proj

let Build _ =
let Build args =
Trace.log " --- Building --- "
// if Environment.isWindows then
// msbuild (addTarget "Restore") Solutions.windows
// else
// msbuild (addTarget "Restore") Solutions.macos
if Environment.isWindows then
dotnetBuild (addTarget "Restore") Solutions.windows
dotnetBuild args (addTarget "Restore") Solutions.windows
else
dotnetBuild (addTarget "Restore") Solutions.macos
dotnetBuild args (addTarget "Restore") Solutions.macos
if Environment.isWindows then
dotnetBuild (doRestore << addTarget "Build") Projects.winFormsLib
dotnetBuild (doRestore << addTarget "Build") Projects.wpfLib
dotnetBuild args (doRestore << addTarget "Build") Projects.winFormsLib
dotnetBuild args (doRestore << addTarget "Build") Projects.wpfLib
else if Environment.isMacOS then
dotnetBuild (doRestore << addTarget "Build") Projects.macosWkLib
dotnetBuild args (doRestore << addTarget "Build") Projects.macosWkLib

let Run _ =
let Run args =
Trace.log " --- Running example app --- "
if Environment.isWindows then
DotNet.exec id "run" ("-p " + Projects.wpfExampleApp) |> ignore
else
Shell.cd (Path.GetDirectoryName Projects.macosExampleApp)
dotnetBuild (addTarget "Run") Projects.macosExampleApp
dotnetBuild args (addTarget "Run") Projects.macosExampleApp

let Test _ =
Trace.log " --- Running tests --- "
Expand All @@ -225,10 +230,10 @@ let ReleaseDocs _ =
|> printfn "%s"
Git.Branches.pushBranch "temp/gh-pages" "origin" "gh-pages"

let Pack _ =
let Pack args =
Trace.log " --- Packing NuGet packages --- "
let props = ["SolutionDir", repoDir; "RepositoryCommit", Git.Information.getCurrentSHA1 repoDir]
let dotnetBuild f = dotnetBuild (doRestore << addTargets ["Pack"] << addProperties props << f)
let dotnetBuild f = dotnetBuild args (doRestore << addTargets ["Pack"] << addProperties props << f)
Trace.logf "PROJECT LIST: %A" projects
for proj in projects do
dotnetBuild id proj
Expand All @@ -241,7 +246,7 @@ let Pack _ =
!! (Path.Combine (artifactsPath, "**", "*.nupkg"))
|> Seq.iter (NupkgHack.hackNupkgAtPath)

let BuildTemplateProjects _ =
let BuildTemplateProjects args =
Trace.log " --- Building template projects --- "
if Environment.isWindows then
let p = [ yield! Templates.winProjects ]
Expand All @@ -252,9 +257,9 @@ let BuildTemplateProjects _ =
else if Environment.isMacOS then
let p = [ yield! Templates.macosProjects ]
for proj in p do
dotnetBuild (addTarget "Restore") proj
dotnetBuild args (addTarget "Restore") proj
for proj in p do
dotnetBuild (addTarget "Build") proj
dotnetBuild args (addTarget "Build") proj


let PackTemplates _ =
Expand Down Expand Up @@ -296,48 +301,48 @@ let initTargets () =
Target.create "PackAll" PackAll
Target.create "TestAll" TestAll
Target.create "All" All

// *** Define Dependencies ***
"Restore"
==> "Build"
==> "Pack"
==> "PackAll"
==> "All"

"Restore"
==> "Run"

"PackTemplates"
==> "PackAll"
==> "All"

"Build"
==> "BuildDocs"
==> "ReleaseDocs"
==> "All"

"BuildTemplateProjects"
==> "TestAll"

// "Build"
// ==> "Test"
"Test"
==> "TestAll"

"Build"
==> "BuildTemplateProjects"

[<EntryPoint>]
let main args =
Environment.CurrentDirectory <- __SOURCE_DIRECTORY__

args
|> Array.toList
|> Context.FakeExecutionContext.Create false "build.fs"
|> Context.RuntimeContext.Fake
|> Context.setExecutionContext

initTargets ()
Target.runOrDefaultWithArguments "Build"

0

0 comments on commit 0a6aefb

Please sign in to comment.