Skip to content

Commit a1c185a

Browse files
committed
Add NUKE build
1 parent 5bf5d1d commit a1c185a

15 files changed

+686
-0
lines changed

.github/workflows/Continuous.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# ------------------------------------------------------------------------------
2+
# <auto-generated>
3+
#
4+
# This code was generated.
5+
#
6+
# - To turn off auto-generation set:
7+
#
8+
# [GitHubActions (AutoGenerate = false)]
9+
#
10+
# - To trigger manual generation invoke:
11+
#
12+
# nuke --generate-configuration GitHubActions_Continuous --host GitHubActions
13+
#
14+
# </auto-generated>
15+
# ------------------------------------------------------------------------------
16+
17+
name: Continuous
18+
19+
on: [push]
20+
21+
jobs:
22+
ubuntu-latest:
23+
name: ubuntu-latest
24+
runs-on: ubuntu-latest
25+
steps:
26+
- uses: actions/checkout@v3
27+
with:
28+
fetch-depth: 0
29+
- name: 'Cache: .nuke/temp, ~/.nuget/packages'
30+
uses: actions/cache@v3
31+
with:
32+
path: |
33+
.nuke/temp
34+
~/.nuget/packages
35+
key: ${{ runner.os }}-${{ hashFiles('**/global.json', '**/*.csproj', '**/Directory.Packages.props') }}
36+
- name: 'Run: Push'
37+
run: ./build.cmd Push
38+
env:
39+
FeedGitHubToken: ${{ secrets.FEED_GITHUB_TOKEN }}
40+
NuGetApiKey: ${{ secrets.NUGET_API_KEY }}
41+
- name: 'Publish: Artifacts'
42+
uses: actions/upload-artifact@v3
43+
with:
44+
name: Artifacts
45+
path: Artifacts

.nuke/build.schema.json

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-04/schema#",
3+
"$ref": "#/definitions/build",
4+
"title": "Build Schema",
5+
"definitions": {
6+
"build": {
7+
"type": "object",
8+
"properties": {
9+
"Configuration": {
10+
"type": "string",
11+
"description": "Configuration to build - Default is 'Debug' (local) or 'Release' (server)",
12+
"enum": [
13+
"Debug",
14+
"Release"
15+
]
16+
},
17+
"Continue": {
18+
"type": "boolean",
19+
"description": "Indicates to continue a previously failed build attempt"
20+
},
21+
"FeedGitHubToken": {
22+
"type": "string",
23+
"default": "Secrets must be entered via 'nuke :secrets [profile]'"
24+
},
25+
"GitHubUser": {
26+
"type": "string"
27+
},
28+
"Help": {
29+
"type": "boolean",
30+
"description": "Shows the help text for this build assembly"
31+
},
32+
"Host": {
33+
"type": "string",
34+
"description": "Host for execution. Default is 'automatic'",
35+
"enum": [
36+
"AppVeyor",
37+
"AzurePipelines",
38+
"Bamboo",
39+
"Bitbucket",
40+
"Bitrise",
41+
"GitHubActions",
42+
"GitLab",
43+
"Jenkins",
44+
"Rider",
45+
"SpaceAutomation",
46+
"TeamCity",
47+
"Terminal",
48+
"TravisCI",
49+
"VisualStudio",
50+
"VSCode"
51+
]
52+
},
53+
"NoLogo": {
54+
"type": "boolean",
55+
"description": "Disables displaying the NUKE logo"
56+
},
57+
"NuGetApiKey": {
58+
"type": "string",
59+
"description": "The key to push to Nuget",
60+
"default": "Secrets must be entered via 'nuke :secrets [profile]'"
61+
},
62+
"Partition": {
63+
"type": "string",
64+
"description": "Partition to use on CI"
65+
},
66+
"Plan": {
67+
"type": "boolean",
68+
"description": "Shows the execution plan (HTML)"
69+
},
70+
"Profile": {
71+
"type": "array",
72+
"description": "Defines the profiles to load",
73+
"items": {
74+
"type": "string"
75+
}
76+
},
77+
"Root": {
78+
"type": "string",
79+
"description": "Root directory during build execution"
80+
},
81+
"Skip": {
82+
"type": "array",
83+
"description": "List of targets to be skipped. Empty list skips all dependencies",
84+
"items": {
85+
"type": "string",
86+
"enum": [
87+
"CalculateVersion",
88+
"Clean",
89+
"CodeCoverage",
90+
"Compile",
91+
"Pack",
92+
"Push",
93+
"PushGithub",
94+
"PushNuget",
95+
"Restore",
96+
"UnitTests"
97+
]
98+
}
99+
},
100+
"Solution": {
101+
"type": "string",
102+
"description": "Path to a solution file that is automatically loaded"
103+
},
104+
"Target": {
105+
"type": "array",
106+
"description": "List of targets to be invoked. Default is '{default_target}'",
107+
"items": {
108+
"type": "string",
109+
"enum": [
110+
"CalculateVersion",
111+
"Clean",
112+
"CodeCoverage",
113+
"Compile",
114+
"Pack",
115+
"Push",
116+
"PushGithub",
117+
"PushNuget",
118+
"Restore",
119+
"UnitTests"
120+
]
121+
}
122+
},
123+
"Verbosity": {
124+
"type": "string",
125+
"description": "Logging verbosity during build execution. Default is 'Normal'",
126+
"enum": [
127+
"Minimal",
128+
"Normal",
129+
"Quiet",
130+
"Verbose"
131+
]
132+
}
133+
}
134+
}
135+
}
136+
}

.nuke/parameters.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"$schema": "./build.schema.json",
3+
"Solution": "DendroDocs.Tool.sln"
4+
}

DendroDocs.Tool.sln

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,16 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{8D0820F2
1111
EndProject
1212
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DendroDocs.Tool.Tests", "tests\DendroDocs.Tool.Tests\DendroDocs.Tool.Tests.csproj", "{B8F2E42D-3EBB-429E-A234-B9C8D9D77F2B}"
1313
EndProject
14+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "_build", "build\_build.csproj", "{356A51CF-BAEB-4C92-ACDB-D0C3E54D9FFC}"
15+
EndProject
1416
Global
1517
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1618
Debug|Any CPU = Debug|Any CPU
1719
Release|Any CPU = Release|Any CPU
1820
EndGlobalSection
1921
GlobalSection(ProjectConfigurationPlatforms) = postSolution
22+
{356A51CF-BAEB-4C92-ACDB-D0C3E54D9FFC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
23+
{356A51CF-BAEB-4C92-ACDB-D0C3E54D9FFC}.Release|Any CPU.ActiveCfg = Release|Any CPU
2024
{66695CA6-7F1D-4327-917C-1BE7BA5CF89D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
2125
{66695CA6-7F1D-4327-917C-1BE7BA5CF89D}.Debug|Any CPU.Build.0 = Debug|Any CPU
2226
{66695CA6-7F1D-4327-917C-1BE7BA5CF89D}.Release|Any CPU.ActiveCfg = Release|Any CPU

build.cmd

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
:; set -eo pipefail
2+
:; SCRIPT_DIR=$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)
3+
:; ${SCRIPT_DIR}/build.sh "$@"
4+
:; exit $?
5+
6+
@ECHO OFF
7+
powershell -ExecutionPolicy ByPass -NoProfile -File "%~dp0build.ps1" %*

build.ps1

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
[CmdletBinding()]
2+
Param(
3+
[Parameter(Position=0,Mandatory=$false,ValueFromRemainingArguments=$true)]
4+
[string[]]$BuildArguments
5+
)
6+
7+
Write-Output "PowerShell $($PSVersionTable.PSEdition) version $($PSVersionTable.PSVersion)"
8+
9+
Set-StrictMode -Version 2.0; $ErrorActionPreference = "Stop"; $ConfirmPreference = "None"; trap { Write-Error $_ -ErrorAction Continue; exit 1 }
10+
$PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent
11+
12+
###########################################################################
13+
# CONFIGURATION
14+
###########################################################################
15+
16+
$BuildProjectFile = "$PSScriptRoot\build\_build.csproj"
17+
$TempDirectory = "$PSScriptRoot\\.nuke\temp"
18+
19+
$DotNetGlobalFile = "$PSScriptRoot\\global.json"
20+
$DotNetInstallUrl = "https://dot.net/v1/dotnet-install.ps1"
21+
$DotNetChannel = "STS"
22+
23+
$env:DOTNET_CLI_TELEMETRY_OPTOUT = 1
24+
$env:DOTNET_NOLOGO = 1
25+
26+
###########################################################################
27+
# EXECUTION
28+
###########################################################################
29+
30+
function ExecSafe([scriptblock] $cmd) {
31+
& $cmd
32+
if ($LASTEXITCODE) { exit $LASTEXITCODE }
33+
}
34+
35+
# If dotnet CLI is installed globally and it matches requested version, use for execution
36+
if ($null -ne (Get-Command "dotnet" -ErrorAction SilentlyContinue) -and `
37+
$(dotnet --version) -and $LASTEXITCODE -eq 0) {
38+
$env:DOTNET_EXE = (Get-Command "dotnet").Path
39+
}
40+
else {
41+
# Download install script
42+
$DotNetInstallFile = "$TempDirectory\dotnet-install.ps1"
43+
New-Item -ItemType Directory -Path $TempDirectory -Force | Out-Null
44+
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
45+
(New-Object System.Net.WebClient).DownloadFile($DotNetInstallUrl, $DotNetInstallFile)
46+
47+
# If global.json exists, load expected version
48+
if (Test-Path $DotNetGlobalFile) {
49+
$DotNetGlobal = $(Get-Content $DotNetGlobalFile | Out-String | ConvertFrom-Json)
50+
if ($DotNetGlobal.PSObject.Properties["sdk"] -and $DotNetGlobal.sdk.PSObject.Properties["version"]) {
51+
$DotNetVersion = $DotNetGlobal.sdk.version
52+
}
53+
}
54+
55+
# Install by channel or version
56+
$DotNetDirectory = "$TempDirectory\dotnet-win"
57+
if (!(Test-Path variable:DotNetVersion)) {
58+
ExecSafe { & powershell $DotNetInstallFile -InstallDir $DotNetDirectory -Channel $DotNetChannel -NoPath }
59+
} else {
60+
ExecSafe { & powershell $DotNetInstallFile -InstallDir $DotNetDirectory -Version $DotNetVersion -NoPath }
61+
}
62+
$env:DOTNET_EXE = "$DotNetDirectory\dotnet.exe"
63+
$env:PATH = "$DotNetDirectory;$env:PATH"
64+
}
65+
66+
Write-Output "Microsoft (R) .NET SDK version $(& $env:DOTNET_EXE --version)"
67+
68+
if (Test-Path env:NUKE_ENTERPRISE_TOKEN) {
69+
& $env:DOTNET_EXE nuget remove source "nuke-enterprise" > $null
70+
& $env:DOTNET_EXE nuget add source "https://f.feedz.io/nuke/enterprise/nuget" --name "nuke-enterprise" --username "PAT" --password $env:NUKE_ENTERPRISE_TOKEN > $null
71+
}
72+
73+
ExecSafe { & $env:DOTNET_EXE build $BuildProjectFile /nodeReuse:false /p:UseSharedCompilation=false -nologo -clp:NoSummary --verbosity quiet }
74+
ExecSafe { & $env:DOTNET_EXE run --project $BuildProjectFile --no-build -- $BuildArguments }

build.sh

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#!/usr/bin/env bash
2+
3+
bash --version 2>&1 | head -n 1
4+
5+
set -eo pipefail
6+
SCRIPT_DIR=$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)
7+
8+
###########################################################################
9+
# CONFIGURATION
10+
###########################################################################
11+
12+
BUILD_PROJECT_FILE="$SCRIPT_DIR/build/_build.csproj"
13+
TEMP_DIRECTORY="$SCRIPT_DIR//.nuke/temp"
14+
15+
DOTNET_GLOBAL_FILE="$SCRIPT_DIR//global.json"
16+
DOTNET_INSTALL_URL="https://dot.net/v1/dotnet-install.sh"
17+
DOTNET_CHANNEL="STS"
18+
19+
export DOTNET_CLI_TELEMETRY_OPTOUT=1
20+
export DOTNET_NOLOGO=1
21+
22+
###########################################################################
23+
# EXECUTION
24+
###########################################################################
25+
26+
function FirstJsonValue {
27+
perl -nle 'print $1 if m{"'"$1"'": "([^"]+)",?}' <<< "${@:2}"
28+
}
29+
30+
# If dotnet CLI is installed globally and it matches requested version, use for execution
31+
if [ -x "$(command -v dotnet)" ] && dotnet --version &>/dev/null; then
32+
export DOTNET_EXE="$(command -v dotnet)"
33+
else
34+
# Download install script
35+
DOTNET_INSTALL_FILE="$TEMP_DIRECTORY/dotnet-install.sh"
36+
mkdir -p "$TEMP_DIRECTORY"
37+
curl -Lsfo "$DOTNET_INSTALL_FILE" "$DOTNET_INSTALL_URL"
38+
chmod +x "$DOTNET_INSTALL_FILE"
39+
40+
# If global.json exists, load expected version
41+
if [[ -f "$DOTNET_GLOBAL_FILE" ]]; then
42+
DOTNET_VERSION=$(FirstJsonValue "version" "$(cat "$DOTNET_GLOBAL_FILE")")
43+
if [[ "$DOTNET_VERSION" == "" ]]; then
44+
unset DOTNET_VERSION
45+
fi
46+
fi
47+
48+
# Install by channel or version
49+
DOTNET_DIRECTORY="$TEMP_DIRECTORY/dotnet-unix"
50+
if [[ -z ${DOTNET_VERSION+x} ]]; then
51+
"$DOTNET_INSTALL_FILE" --install-dir "$DOTNET_DIRECTORY" --channel "$DOTNET_CHANNEL" --no-path
52+
else
53+
"$DOTNET_INSTALL_FILE" --install-dir "$DOTNET_DIRECTORY" --version "$DOTNET_VERSION" --no-path
54+
fi
55+
export DOTNET_EXE="$DOTNET_DIRECTORY/dotnet"
56+
export PATH="$DOTNET_DIRECTORY:$PATH"
57+
fi
58+
59+
echo "Microsoft (R) .NET SDK version $("$DOTNET_EXE" --version)"
60+
61+
if [[ ! -z ${NUKE_ENTERPRISE_TOKEN+x} && "$NUKE_ENTERPRISE_TOKEN" != "" ]]; then
62+
"$DOTNET_EXE" nuget remove source "nuke-enterprise" &>/dev/null || true
63+
"$DOTNET_EXE" nuget add source "https://f.feedz.io/nuke/enterprise/nuget" --name "nuke-enterprise" --username "PAT" --password "$NUKE_ENTERPRISE_TOKEN" --store-password-in-clear-text &>/dev/null || true
64+
fi
65+
66+
"$DOTNET_EXE" build "$BUILD_PROJECT_FILE" /nodeReuse:false /p:UseSharedCompilation=false -nologo -clp:NoSummary --verbosity quiet
67+
"$DOTNET_EXE" run --project "$BUILD_PROJECT_FILE" --no-build -- "$@"

build/.editorconfig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[*.cs]
2+
dotnet_style_qualification_for_field = false:warning
3+
dotnet_style_qualification_for_property = false:warning
4+
dotnet_style_qualification_for_method = false:warning
5+
dotnet_style_qualification_for_event = false:warning
6+
dotnet_style_require_accessibility_modifiers = never:warning
7+
8+
csharp_style_expression_bodied_methods = true:silent
9+
csharp_style_expression_bodied_properties = true:warning
10+
csharp_style_expression_bodied_indexers = true:warning
11+
csharp_style_expression_bodied_accessors = true:warning

0 commit comments

Comments
 (0)