Skip to content

Commit

Permalink
chore: update build
Browse files Browse the repository at this point in the history
  • Loading branch information
AngelMunoz committed Nov 4, 2024
1 parent c2f76f2 commit 015f6f5
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 14 deletions.
10 changes: 2 additions & 8 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,8 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v4
# Restore the local tools
- name: Restore tools
run: dotnet tool restore
# Build the code for the API documentation
- name: Build code
run: dotnet build -c Release Threads.Lib/Threads.Lib.fsproj
# Generate the documentation files
- name: Generate the documentation'
run: dotnet fsdocs build --properties Configuration=Release
- name: Build Docs
run: dotnet fsi build.fsx -- -p ci:docs
# Upload the static files
- name: Upload documentation
uses: actions/upload-pages-artifact@v3
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/library.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,11 @@ on:
jobs:
build:
runs-on: ubuntu-latest
name: Build dotnet 8.0
name: Build Library
steps:
- uses: actions/checkout@v4
- name: Setup dotnet
uses: actions/setup-dotnet@v4
with:
dotnet-version: "8.0.x"
- run: dotnet restore
- run: dotnet build Threads.Lib -f net8.0 --configuration Release --no-restore
- run: dotnet test Threads.Lib.Tests -f net8.0 --no-restore
- run: dotnet fsi build.fsx -- -p ci:library
3 changes: 1 addition & 2 deletions .github/workflows/sample.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,4 @@ jobs:
uses: actions/setup-dotnet@v4
with:
dotnet-version: "8.0.x"
- run: dotnet restore Sample/Sample.fsproj
- run: dotnet build Sample/Sample.fsproj -f net8.0 --configuration Release --no-restore
- run: dotnet fsi build.fsx -- -p ci:sample
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,7 @@ async {
- `dotnet run script.fsx` should print the profile response.

For more information, check out the docs at https://angelmunoz.github.io/Threads.Lib/

# Build locally

`dotnet fsi build.fsx -- -p build
97 changes: 97 additions & 0 deletions build.fsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
#r "nuget: Fun.Build, 1.1.14"
#r "nuget: Fun.Result, 2.1.0"

open System.IO
open Fun.Build

let restore name = stage $"Restoring {name}" { run $"dotnet restore {name}" }

let build name = stage $"Building {name}" {
run $"dotnet build {name} -f net8.0 --no-restore -c Release"
}

let test name = stage $"Testing {name}" {
run $"dotnet test {name} -f net8.0 --no-restore"
}

let pack name = stage $"Packing {name}" {
run $"dotnet pack {name} --no-build --no-restore -o dist"
}

let pushNugets = stage $"Push to NuGet" {

run(fun ctx -> async {

let nugetApiKey = ctx.GetEnvVar "NUGET_DEPLOY_KEY"
let nugets = Directory.GetFiles(__SOURCE_DIRECTORY__ + "/dist", "*.nupkg")

for nuget in nugets do
printfn "Pushing %s" nuget

let! res =
ctx.RunSensitiveCommand
$"dotnet nuget push {nuget} --skip-duplicate -s https://api.nuget.org/v3/index.json -k {nugetApiKey}"

match res with
| Ok _ -> return ()
| Error err -> failwith err
})
}


pipeline "release" {
let project = "Threads.Lib"
restore project
build project
pack project
pushNugets
runIfOnlySpecified true
}

pipeline "release:local" {
let project = "Threads.Lib"
restore project
build project
pack project
runIfOnlySpecified true
}

pipeline "ci:library" {
let project = "Threads.Lib"
restore project
build project
test project
runIfOnlySpecified true
}

pipeline "ci:docs" {
stage "Restoring Tools" { run "dotnet tool restore" }
restore "Threads.Lib"
build "Threads.Lib"

stage "Fsdocs build" {
run "dotnet fsdocs build --properties Condfiguration=Release"
}

runIfOnlySpecified true
}


pipeline "ci:sample" {
let project = "Sample/Sample.fsproj"
restore project
build project

runIfOnlySpecified true
}

pipeline "build" {
stage "Restoring Tools" { run "dotnet tool restore" }
stage "Restore Solution" { run "dotnet restore" }
stage "Build Solution" { run "dotnet build -f net8.0 --no-restore -tl" }
stage "Test Solution" { run "dotnet test -f net8.0 --no-restore" }

runIfOnlySpecified true
}

tryPrintPipelineCommandHelp()

0 comments on commit 015f6f5

Please sign in to comment.