Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# This workflow will build a .NET project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net

name: Build and test

on:
push:
branches: [ "dev", "master" ]
pull_request:
branches: [ "dev", "master" ]

jobs:
build:
if: github.event_name != 'push' || !startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.x
- name: Build & test
run: dotnet fsi build.fsx -- -- build test
44 changes: 44 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# This workflow will build a .NET project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net

name: Publish package

on:
push:
tags:
- 'v*'

jobs:
publish:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 9.0.x

- name: Extract version from tag
id: version
run: |
TAG_NAME="${{ github.ref_name }}"
VERSION="${TAG_NAME#v}" # Remove 'v' prefix
echo "version=${VERSION}.${{ github.run_number }}" >> $GITHUB_OUTPUT

- name: Build and test
run: dotnet fsi build.fsx -- -- build test

- name: Publish
run: dotnet fsi build.fsx -- -- push
env:
VERSION: ${{ steps.version.outputs.version }}
NUGET_KEY: ${{ secrets.NUGET_API_KEY }}

- name: Upload build log
uses: actions/upload-artifact@v4
if: always()
with:
name: build-log-${{ github.run_number }}.txt
path: build.log
retention-days: 5
14 changes: 0 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,3 @@ Library tends to be compliant to Ebml specs, as they described in https://github
### Prerequisites

* dotnet 8 SDK

### Publishing new version (note to myself)

```bash
# build and test a package
dotnet fsi build.fsx -- -- clean build test

# set env vars:
export VER=0.9.0
export NUGET_KEY=111112222233333

# pack and push the package
dotnet fsi build.fsx -- -- push
```
35 changes: 14 additions & 21 deletions build.fsx
Original file line number Diff line number Diff line change
@@ -1,31 +1,18 @@
// xake build file

#r "nuget: Xake, 2"
#r "nuget: Xake, 2.3.0"

open Xake
open Xake.Tasks

let sh folder cmd =
let command::arglist | OtherwiseFail(command,arglist) = (cmd: string).Split(' ') |> List.ofArray
shell {
cmd command
args arglist
workdir folder
failonerror
} |> Ignore

let (=?) value deflt = match value with |Some v -> v |None -> deflt
let (=?) value deflt = value |> Option.defaultValue deflt

let getVersion () = recipe {
let! ver = getEnv "VER"
let! ver = getEnv "VERSION"
return ver =? "0.0.1"
}

let dependsOn (fileset) = recipe {
let! files = fileset |> getFiles
do! needFiles files
}

do xake {ExecOptions.Default with FileLog = "build.log"; ConLogLevel = Loud } {

rules [
Expand All @@ -39,17 +26,17 @@ do xake {ExecOptions.Default with FileLog = "build.log"; ConLogLevel = Loud } {
"build" ..> recipe {
do! dependsOn !! "Src/Core/**/*.cs"
let! ver = getVersion()
do! sh "Src/Core" $"dotnet build -c Release -p:Version={ver}"
do! sh $"dotnet build -c Release -p:Version={ver}" { workdir "Src/Core" }
}

"test" ..> recipe {
do! dependsOn !! "Src/Core.Tests/**/*.cs"
do! sh "Src/Core.Tests" "dotnet test"
do! sh "dotnet test" { workdir "Src/Core.Tests" }
}

"pack" ..> recipe {
let! ver = getVersion()
do! sh "Src/Core" $"dotnet pack -c Release -p:Version={ver}"
do! sh $"dotnet pack -c Release -p:Version={ver}" { workdir "Src/Core" }
}

"push" => action {
Expand All @@ -60,8 +47,14 @@ do xake {ExecOptions.Default with FileLog = "build.log"; ConLogLevel = Loud } {

let package_name = $"NEbml.{ver}.nupkg"
let nuget_key = nuget_key_var =? ""
do! sh "Src/Core/bin/Release" $"dotnet nuget push {package_name} --api-key {nuget_key} --source https://api.nuget.org/v3/index.json"
do! sh "dotnet nuget push" {
workdir "Src/Core/bin/Release"
args [
package_name
"--api-key"; nuget_key
"--source"; "https://api.nuget.org/v3/index.json"
]
}
}
]

}