Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
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" ]
pull_request:
branches: [ "dev" ]

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: 9.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 -- -- pack 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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ _UpgradeReport*
packages
.nuget
.paket
.ionide

# Ignore Visual Studio files
*.pdb
Expand All @@ -32,6 +33,8 @@ TestResult.*
.xake*
.fake
.vs/
.vscode/
.ionide/
samples/**/*.exe
samples/**/*.dll
samples/**/*.fsx.lock
Expand Down
12 changes: 4 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
language: csharp
mono: latest
dotnet: 2.1.300
dotnet: 7.0.202
env: VER=$(if [[ "${TRAVIS_TAG:0:1}" == "v" ]]; then echo ${TRAVIS_TAG:1}.${TRAVIS_BUILD_NUMBER}; else echo 1.0.0.${TRAVIS_BUILD_NUMBER}; fi;)
install:
- dotnet restore build.proj
script:
- export FrameworkPathOverride=$(dirname $(which mono))/../lib/mono/4.5-api/
- dotnet fake run build.fsx -- build test -ll Diag
- dotnet fsi build.fsx -- -- build test -ll Diag
deploy:
- provider: script
script: dotnet fake run build.fsx -- pack push -ll Diag
script: dotnet fsi build.fsx -- -- pack push -ll Diag
skip_cleanup: true
on:
tags: true
condition: "${TRAVIS_TAG:0:1} = v"
condition: "${TRAVIS_TAG:0:1} = v"
5 changes: 0 additions & 5 deletions .vscode/settings.json

This file was deleted.

2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2014 OlegZee
Copyright (c) 2014-2024 OlegZee

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
3 changes: 1 addition & 2 deletions build.cmd
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
@echo off
dotnet restore build.proj
dotnet fake run build.fsx -- build
dotnet fsi build.fsx -- -- build
119 changes: 44 additions & 75 deletions build.fsx
Original file line number Diff line number Diff line change
@@ -1,55 +1,31 @@
#r "paket:
nuget Xake ~> 1.1 prerelease //"

#if !FAKE
#load ".fake/build.fsx/intellisense.fsx"
#endif
#r "nuget: Xake, 2.2.0"

open Xake
open Xake.Tasks

let frameworks = ["netstandard2.0"; "net46"]
let frameworks = ["netstandard2.0" (*; "net46" *)]
let libtargets =
[ for t in frameworks do
for e in ["dll"; "xml"]
-> sprintf "out/%s/Xake.%s" t e
[ for fwk in frameworks do
for ext in ["dll"; "xml"]
-> $"out/%s{fwk}/Xake.%s{ext}"
]

let getVersion () = recipe {
let! verVar = getVar("VER")
let! verEnv = getEnv("VER")
let ver = verVar |> Option.defaultValue (verEnv |> Option.defaultValue "0.0.1")

let! verSuffix =
getVar("SUFFIX")
|> Recipe.map (
function
| None -> "-beta"
| Some "" -> "" // this is release!
| Some s -> "-" + s
)
return ver + verSuffix
}
let getVersion () = getEnv "VERSION" |> map (Option.defaultValue "0.0.1")

let makePackageName = sprintf "Xake.%s.nupkg"
let makePackageName version = $"Xake.%s{version}.nupkg"

let dotnet arglist = recipe {
do! shell {
let dotnet arglist =
shell {
cmd "dotnet"
args arglist
failonerror
} |> Recipe.Ignore
}
} |> Ignore

do xakeScript {
filelog "build.log" Verbosity.Diag
// consolelog Verbosity.Normal
filelog "build.log" Diag

rules [
"main" => recipe {
do! need ["build"]
do! need ["test"]
}
"main" <<< ["build"; "test"]

"build" <== libtargets
"clean" => rm {dir "out"}
Expand All @@ -58,38 +34,33 @@ do xakeScript {
do! alwaysRerun()

let! where =
getVar("FILTER")
|> Recipe.map (function |Some clause -> ["--filter"; sprintf "Name~\"%s\"" clause] | None -> [])

// in case of travis only run tests for standard runtime, eventually will add more
let! limitFwk = getEnv("TRAVIS") |> Recipe.map (function | Some _ -> ["-f:netcoreapp2.0"] | _ -> [])
getVar "FILTER"
|> map (function |Some clause -> ["--filter"; $"Name~\"{clause}\""] | None -> [])

do! dotnet <| ["test"; "src/tests"; "-c"; "Release"] @ where @ limitFwk
do! dotnet <| ["test"; "src/tests"; "-c"; "Release"] @ where
}

libtargets *..> recipe {

let! allFiles
= getFiles <| fileset {
basedir "src/core"
includes "Xake.fsproj"
includes "**/*.fs"
}
let! allFiles = getFiles <| fileset {
basedir "src/core"
includes "Xake.fsproj"
includes "**/*.fs"
}

do! needFiles allFiles
let! version = getVersion()

for framework in frameworks do
do! dotnet
[
"build"
"src/core"
"/p:Version=" + version
"--configuration"; "Release"
"--framework"; framework
"--output"; "../../out/" + framework
"/p:DocumentationFile=Xake.xml"
]
do! dotnet [
"build"
"src/core"
"/p:Version=" + version
"--configuration"; "Release"
"--framework"; framework
"--output"; "./out/" + framework
"/p:DocumentationFile=Xake.xml"
]
}
]

Expand All @@ -101,29 +72,27 @@ do xakeScript {
}

"out/Xake.(ver:*).nupkg" ..> recipe {
let! ver = getRuleMatch("ver")
do! dotnet
[
"pack"; "src/core"
"-c"; "Release"
"/p:Version=" + ver
"--output"; "../../out/"
"/p:DocumentationFile=Xake.xml"
]
let! ver = getRuleMatch "ver"
do! dotnet [
"pack"; "src/core"
"-c"; "Release"
$"/p:Version={ver}"
"--output"; "out/"
"/p:DocumentationFile=Xake.xml"
]
}

// push need pack to be explicitly called in advance
"push" => recipe {
let! version = getVersion()

let! nuget_key = getEnv("NUGET_KEY")
do! dotnet
[
"nuget"; "push"
"out" </> makePackageName version
"--source"; "https://www.nuget.org/api/v2/package"
"--api-key"; nuget_key |> Option.defaultValue ""
]
let! nuget_key = getEnv "NUGET_KEY"
do! dotnet [
"nuget"; "push"
"out" </> makePackageName version
"--source"; "https://www.nuget.org/api/v2/package"
"--api-key"; nuget_key |> Option.defaultValue ""
]
}
]
}
7 changes: 0 additions & 7 deletions build.fsx.lock

This file was deleted.

10 changes: 0 additions & 10 deletions build.proj

This file was deleted.

3 changes: 1 addition & 2 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
#!/bin/bash
dotnet restore build.proj
dotnet fake run build.fsx -- build
dotnet fsi build.fsx -- --
9 changes: 9 additions & 0 deletions docs/cheatsheet.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
## Operators ##

### `<<<` - depends on targets (run sequentially)

> `"main" <<< ["restore"; "build-debug"; "unit-test"]`

### `<==` - depends on targets that are allowed to run in parallel
> `"main" <<< ["build-debug"; "build-release"]`

3 changes: 2 additions & 1 deletion docs/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Xake script is just an F# script with some flavors.
The most simple, but structured script looks as follows:

```fsharp
#r @".tools/Xake.Core.dll" // (1)
#r "nuget: Xake, 1.1.4.427-beta" // (1)

open Xake // (2)

Expand Down Expand Up @@ -154,6 +154,7 @@ There're several forms of rules including:

* `rule (<name> => <action>)` - creates a phony rule (the rule that does not create a file)
* `rule (<name> <== [targets])` - creates a phony rule which demands specified targets
* `rule (<name> <<< [targets])` - the same as above, but the targets are requested one by one (non-parallel excution)
* `rule (<file pattern> ..> <action>)` - rule for single file or group of files matching the specified wildcards pattern. The file and an optional matching groups can be accessed via getTargetFile and getRuleMatch methods
* `rule (<condition> ..?> <action>)` - allows to use function instead of file name or wildcards

Expand Down
7 changes: 3 additions & 4 deletions docs/todo.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@

* change the first page to a tutorial with script and usage examples

* switch development to mono under windows
* idea: xake script as a task. Override/inherit variables. How to change variable on the fly is the original question. (we have got it out of the box, need more info)
* accept filemasks in 'need' parameters (WHY I added it here?, the use case is very unclear)
* detect changes in build script (internal changes), e.g. new target added that was not in .xake database
* dependencies tracking mode: automatically rebuild when dependency is changed, execute triggers allowing to start/stop the processes which lock/hold artifacts
* in-memory artifact (string or stream). Say in Gulp file is processed in-memory
* can the rules be abstract over artifacts

### Refactorings

Expand All @@ -25,10 +22,12 @@
* `rule "Viewer" -> fun folder -> action {need [folder <\\> "bin" <\\> folder <.> "exe"]...}`
* Filelist is not handy as it requires to cast all the time
* FileInfo is not good for the same reason: poorly composable and does not cover Directory well
* wildcards phony actions

## Done (top is recent)

* wildcards phony actions
* support tasks in line with recipes and asyncs

* rules should accept #seq not just the list
* <<< for running tasks one by one. Current one runs in parallel only.
* complete copyFiles method
Expand Down
6 changes: 6 additions & 0 deletions global.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"sdk": {
"rollForward": "major",
"version": "9.0.0"
}
}
Loading