4 Commits

Author SHA1 Message Date
SKProCH d3b9b3f1ca Add submodules cloning for nuke build
main / ubuntu-latest (push) Has been cancelled
2022-11-20 23:00:41 +03:00
SKProCH 748405d52d Improve nuke support 2022-11-20 22:57:57 +03:00
SKProCH f131d3d969 Add initial nuke support 2022-11-05 14:43:01 +03:00
SKProCH 29cb7f51f3 Add ripple removing after focus is lost 2022-10-26 01:09:55 +03:00
28 changed files with 812 additions and 151 deletions
-22
View File
@@ -1,22 +0,0 @@
name: .NET Core
on:
push:
branches-ignore:
- 'master'
pull_request:
branches:
- '**:**'
jobs:
build:
runs-on: ubuntu-latest
name: Build solution
steps:
- uses: actions/checkout@v1
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.*
- name: Build with dotnet
run: dotnet build --configuration Release
+44
View File
@@ -0,0 +1,44 @@
# ------------------------------------------------------------------------------
# <auto-generated>
#
# This code was generated.
#
# - To turn off auto-generation set:
#
# [GitHubActions (AutoGenerate = false)]
#
# - To trigger manual generation invoke:
#
# nuke --generate-configuration GitHubActions_main --host GitHubActions
#
# </auto-generated>
# ------------------------------------------------------------------------------
name: main
on: [push, pull_request]
jobs:
ubuntu-latest:
name: ubuntu-latest
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Cache .nuke/temp, ~/.nuget/packages
uses: actions/cache@v2
with:
path: |
.nuke/temp
~/.nuget/packages
key: ${{ runner.os }}-${{ hashFiles('**/global.json', '**/*.csproj') }}
- name: Run './build.cmd Compile PublishNugetPackage'
run: ./build.cmd Compile PublishNugetPackage
env:
NuGetKey: ${{ secrets.NUGET_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/upload-artifact@v1
with:
name: nuget
path: Material.Avalonia/bin/artifacts/nuget
-62
View File
@@ -1,62 +0,0 @@
name: Publish nightly builds
on:
push:
branches: [ dev ]
jobs:
build:
name: Build and pack
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, 'no nightly')"
steps:
- uses: actions/checkout@v2
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.*
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore --configuration Release
- name: Pack
run: dotnet pack --configuration Release /p:PatchNumber=$GITHUB_RUN_NUMBER-nightly
- name: Collect packages
run: |
mkdir artifacts
cp Config.Numerge.json artifacts/
mkdir -p artifacts/input/
find . -name \*.nupkg -exec cp {} artifacts/input/ \;
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: artifacts
path: artifacts/
numerge:
name: Merge packages and publish nightly
runs-on: ubuntu-latest
needs: [build]
steps:
- name: Checkout Numerge
uses: actions/checkout@v2.3.4
with:
repository: CreateLab/Numerge
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.*
- name: Build Numerge
run: dotnet build
- name: Download packages
uses: actions/download-artifact@v2.0.8
with:
name: artifacts
path: artifacts
- name: Merge packages
run: |
mkdir artifacts/output/
dotnet run --project Numerge.Console artifacts/Config.Numerge.json artifacts/input/ artifacts/output/
- name: Publish to Nuget
run: dotnet nuget push "artifacts/output/Material.Avalonia.*.nupkg" --api-key ${{secrets.NUGET_KEY}} --source https://api.nuget.org/v3/index.json --skip-duplicate
- name: Publish to GitHub Packages
run: dotnet nuget push "artifacts/output/Material.Avalonia.*.nupkg" --api-key ${{secrets.GITHUB_TOKEN}} --source https://nuget.pkg.github.com/AvaloniaCommunity/index.json --skip-duplicate
-61
View File
@@ -1,61 +0,0 @@
name: Publish release
on:
push:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
name: Build and pack
steps:
- uses: actions/checkout@v2
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.*
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore --configuration Release
- name: Pack
run: dotnet pack --configuration Release
- name: Collect packages
run: |
mkdir artifacts
cp Config.Numerge.json artifacts/
mkdir -p artifacts/input/
find . -name \*.nupkg -exec cp {} artifacts/input/ \;
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: artifacts
path: artifacts/
numerge:
runs-on: ubuntu-latest
name: Merge packages and publish release
needs: [build]
steps:
- name: Checkout Numerge
uses: actions/checkout@v2.3.4
with:
repository: CreateLab/Numerge
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.*
- name: Build Numerge
run: dotnet build
- name: Download packages
uses: actions/download-artifact@v2.0.8
with:
name: artifacts
path: artifacts
- name: Merge packages
run: |
mkdir artifacts/output/
dotnet run --project Numerge.Console artifacts/Config.Numerge.json artifacts/input/ artifacts/output/
- name: Publish to Nuget
run: dotnet nuget push "artifacts/output/Material.Avalonia.*.nupkg" --api-key ${{secrets.NUGET_KEY}} --source https://api.nuget.org/v3/index.json --skip-duplicate
- name: Publish to GitHub Packages
run: dotnet nuget push "artifacts/output/Material.Avalonia.*.nupkg" --api-key ${{secrets.GITHUB_TOKEN}} --source https://nuget.pkg.github.com/AvaloniaCommunity/index.json --skip-duplicate
+3
View File
@@ -0,0 +1,3 @@
[submodule "build/Numerge"]
path = build/Numerge
url = https://github.com/kekekeks/Numerge.git
+124
View File
@@ -0,0 +1,124 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "Build Schema",
"$ref": "#/definitions/build",
"definitions": {
"build": {
"type": "object",
"properties": {
"Configuration": {
"type": "string",
"description": "Configuration to build - Default is 'Debug' (local) or 'Release' (server)",
"enum": [
"Debug",
"Release"
]
},
"Continue": {
"type": "boolean",
"description": "Indicates to continue a previously failed build attempt"
},
"Help": {
"type": "boolean",
"description": "Shows the help text for this build assembly"
},
"Host": {
"type": "string",
"description": "Host for execution. Default is 'automatic'",
"enum": [
"AppVeyor",
"AzurePipelines",
"Bamboo",
"Bitbucket",
"Bitrise",
"GitHubActions",
"GitLab",
"Jenkins",
"Rider",
"SpaceAutomation",
"TeamCity",
"Terminal",
"TravisCI",
"VisualStudio",
"VSCode"
]
},
"NoLogo": {
"type": "boolean",
"description": "Disables displaying the NUKE logo"
},
"NuGetKey": {
"type": "string",
"default": "Secrets must be entered via 'nuke :secrets [profile]'"
},
"Partition": {
"type": "string",
"description": "Partition to use on CI"
},
"Plan": {
"type": "boolean",
"description": "Shows the execution plan (HTML)"
},
"Profile": {
"type": "array",
"description": "Defines the profiles to load",
"items": {
"type": "string"
}
},
"Root": {
"type": "string",
"description": "Root directory during build execution"
},
"Skip": {
"type": "array",
"description": "List of targets to be skipped. Empty list skips all dependencies",
"items": {
"type": "string",
"enum": [
"Clean",
"Compile",
"CreateIntermediateNugetPackages",
"CreateNugetPackage",
"PublishNugetPackage",
"ZipFiles"
]
}
},
"Solution": {
"type": "string",
"description": "Path to a solution file that is automatically loaded"
},
"Target": {
"type": "array",
"description": "List of targets to be invoked. Default is '{default_target}'",
"items": {
"type": "string",
"enum": [
"Clean",
"Compile",
"CreateIntermediateNugetPackages",
"CreateNugetPackage",
"PublishNugetPackage",
"ZipFiles"
]
}
},
"Verbosity": {
"type": "string",
"description": "Logging verbosity during build execution. Default is 'Normal'",
"enum": [
"Minimal",
"Normal",
"Quiet",
"Verbose"
]
},
"Version": {
"type": "string",
"description": "version"
}
}
}
}
}
+4
View File
@@ -0,0 +1,4 @@
{
"$schema": "./build.schema.json",
"Solution": "Material.Avalonia.sln"
}
+4
View File
@@ -17,12 +17,16 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Material.DataGrid", "Materi
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Material.Dialog", "Material.Dialog\Material.Dialog.csproj", "{4F5F7FFD-B6E2-4C36-B250-D6B8169A0B1A}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "_build", "build\_build.csproj", "{A8E3E5E2-C52D-4CB6-B1CC-7D3D60A907CD}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{A8E3E5E2-C52D-4CB6-B1CC-7D3D60A907CD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A8E3E5E2-C52D-4CB6-B1CC-7D3D60A907CD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{ECB440AE-658B-4602-87CD-BE7FE8285362}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{ECB440AE-658B-4602-87CD-BE7FE8285362}.Debug|Any CPU.Build.0 = Debug|Any CPU
{ECB440AE-658B-4602-87CD-BE7FE8285362}.Release|Any CPU.ActiveCfg = Release|Any CPU
+1 -6
View File
@@ -13,7 +13,7 @@
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageIcon>FavIcon.png</PackageIcon>
<VersionPrefix>3.0.0-avalonia10-preview2</VersionPrefix>
<Version>3.0.0-avalonia10-preview2</Version>
<PackageReleaseNotes>
Most likely latest version with Avalonia 0.10.x support
Version 3.0.0-rc0 was replaced with 3.0.0-avalonia10-preview1 (in order to keep version names clear)
@@ -40,11 +40,6 @@ Version 3.0.0-rc0 was replaced with 3.0.0-avalonia10-preview1 (in order to keep
<None Include="../README.md" Pack="true" PackagePath="/" />
<None Include="../wiki/FavIcon.png" Pack="true" PackagePath="/" />
</ItemGroup>
<!-- For nightly versions-->
<PropertyGroup>
<Version Condition="'$(PatchNumber)' != ''">$(VersionPrefix).$(PatchNumber)</Version>
</PropertyGroup>
<ItemGroup>
<AvaloniaResource Include="**\*.xaml">
+1
View File
@@ -4,6 +4,7 @@
<TargetFramework>net5.0</TargetFramework>
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Avalonia" Version="0.10.18" />
+6
View File
@@ -3,6 +3,7 @@ using Avalonia;
using Avalonia.Controls;
using Avalonia.Controls.Primitives;
using Avalonia.Input;
using Avalonia.Interactivity;
using Avalonia.Media;
using Avalonia.Threading;
@@ -18,6 +19,7 @@ namespace Material.Ripple
public RippleEffect()
{
AddHandler(LostFocusEvent, LostFocusHandler);
AddHandler(PointerReleasedEvent, PointerReleasedHandler);
AddHandler(PointerPressedEvent, PointerPressedHandler);
AddHandler(PointerCaptureLostEvent, PointerCaptureLostHandler);
@@ -41,6 +43,10 @@ namespace Material.Ripple
r.RunFirstStep();
}
private void LostFocusHandler(object sender, RoutedEventArgs e) {
RemoveLastRipple();
}
private void PointerReleasedHandler(object sender, PointerReleasedEventArgs e)
{
RemoveLastRipple();
Executable
+7
View File
@@ -0,0 +1,7 @@
:; set -eo pipefail
:; SCRIPT_DIR=$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)
:; ${SCRIPT_DIR}/build.sh "$@"
:; exit $?
@ECHO OFF
powershell -ExecutionPolicy ByPass -NoProfile -File "%~dp0build.ps1" %*
+69
View File
@@ -0,0 +1,69 @@
[CmdletBinding()]
Param(
[Parameter(Position=0,Mandatory=$false,ValueFromRemainingArguments=$true)]
[string[]]$BuildArguments
)
Write-Output "PowerShell $($PSVersionTable.PSEdition) version $($PSVersionTable.PSVersion)"
Set-StrictMode -Version 2.0; $ErrorActionPreference = "Stop"; $ConfirmPreference = "None"; trap { Write-Error $_ -ErrorAction Continue; exit 1 }
$PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent
###########################################################################
# CONFIGURATION
###########################################################################
$BuildProjectFile = "$PSScriptRoot\build\_build.csproj"
$TempDirectory = "$PSScriptRoot\\.nuke\temp"
$DotNetGlobalFile = "$PSScriptRoot\\global.json"
$DotNetInstallUrl = "https://dot.net/v1/dotnet-install.ps1"
$DotNetChannel = "Current"
$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE = 1
$env:DOTNET_CLI_TELEMETRY_OPTOUT = 1
$env:DOTNET_MULTILEVEL_LOOKUP = 0
###########################################################################
# EXECUTION
###########################################################################
function ExecSafe([scriptblock] $cmd) {
& $cmd
if ($LASTEXITCODE) { exit $LASTEXITCODE }
}
# If dotnet CLI is installed globally and it matches requested version, use for execution
if ($null -ne (Get-Command "dotnet" -ErrorAction SilentlyContinue) -and `
$(dotnet --version) -and $LASTEXITCODE -eq 0) {
$env:DOTNET_EXE = (Get-Command "dotnet").Path
}
else {
# Download install script
$DotNetInstallFile = "$TempDirectory\dotnet-install.ps1"
New-Item -ItemType Directory -Path $TempDirectory -Force | Out-Null
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
(New-Object System.Net.WebClient).DownloadFile($DotNetInstallUrl, $DotNetInstallFile)
# If global.json exists, load expected version
if (Test-Path $DotNetGlobalFile) {
$DotNetGlobal = $(Get-Content $DotNetGlobalFile | Out-String | ConvertFrom-Json)
if ($DotNetGlobal.PSObject.Properties["sdk"] -and $DotNetGlobal.sdk.PSObject.Properties["version"]) {
$DotNetVersion = $DotNetGlobal.sdk.version
}
}
# Install by channel or version
$DotNetDirectory = "$TempDirectory\dotnet-win"
if (!(Test-Path variable:DotNetVersion)) {
ExecSafe { & powershell $DotNetInstallFile -InstallDir $DotNetDirectory -Channel $DotNetChannel -NoPath }
} else {
ExecSafe { & powershell $DotNetInstallFile -InstallDir $DotNetDirectory -Version $DotNetVersion -NoPath }
}
$env:DOTNET_EXE = "$DotNetDirectory\dotnet.exe"
}
Write-Output "Microsoft (R) .NET SDK version $(& $env:DOTNET_EXE --version)"
ExecSafe { & $env:DOTNET_EXE build $BuildProjectFile /nodeReuse:false /p:UseSharedCompilation=false -nologo -clp:NoSummary --verbosity quiet }
ExecSafe { & $env:DOTNET_EXE run --project $BuildProjectFile --no-build -- $BuildArguments }
Executable
+62
View File
@@ -0,0 +1,62 @@
#!/usr/bin/env bash
bash --version 2>&1 | head -n 1
set -eo pipefail
SCRIPT_DIR=$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)
###########################################################################
# CONFIGURATION
###########################################################################
BUILD_PROJECT_FILE="$SCRIPT_DIR/build/_build.csproj"
TEMP_DIRECTORY="$SCRIPT_DIR//.nuke/temp"
DOTNET_GLOBAL_FILE="$SCRIPT_DIR//global.json"
DOTNET_INSTALL_URL="https://dot.net/v1/dotnet-install.sh"
DOTNET_CHANNEL="Current"
export DOTNET_CLI_TELEMETRY_OPTOUT=1
export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
export DOTNET_MULTILEVEL_LOOKUP=0
###########################################################################
# EXECUTION
###########################################################################
function FirstJsonValue {
perl -nle 'print $1 if m{"'"$1"'": "([^"]+)",?}' <<< "${@:2}"
}
# If dotnet CLI is installed globally and it matches requested version, use for execution
if [ -x "$(command -v dotnet)" ] && dotnet --version &>/dev/null; then
export DOTNET_EXE="$(command -v dotnet)"
else
# Download install script
DOTNET_INSTALL_FILE="$TEMP_DIRECTORY/dotnet-install.sh"
mkdir -p "$TEMP_DIRECTORY"
curl -Lsfo "$DOTNET_INSTALL_FILE" "$DOTNET_INSTALL_URL"
chmod +x "$DOTNET_INSTALL_FILE"
# If global.json exists, load expected version
if [[ -f "$DOTNET_GLOBAL_FILE" ]]; then
DOTNET_VERSION=$(FirstJsonValue "version" "$(cat "$DOTNET_GLOBAL_FILE")")
if [[ "$DOTNET_VERSION" == "" ]]; then
unset DOTNET_VERSION
fi
fi
# Install by channel or version
DOTNET_DIRECTORY="$TEMP_DIRECTORY/dotnet-unix"
if [[ -z ${DOTNET_VERSION+x} ]]; then
"$DOTNET_INSTALL_FILE" --install-dir "$DOTNET_DIRECTORY" --channel "$DOTNET_CHANNEL" --no-path
else
"$DOTNET_INSTALL_FILE" --install-dir "$DOTNET_DIRECTORY" --version "$DOTNET_VERSION" --no-path
fi
export DOTNET_EXE="$DOTNET_DIRECTORY/dotnet"
fi
echo "Microsoft (R) .NET SDK version $("$DOTNET_EXE" --version)"
"$DOTNET_EXE" build "$BUILD_PROJECT_FILE" /nodeReuse:false /p:UseSharedCompilation=false -nologo -clp:NoSummary --verbosity quiet
"$DOTNET_EXE" run --project "$BUILD_PROJECT_FILE" --no-build -- "$@"
+11
View File
@@ -0,0 +1,11 @@
[*.cs]
dotnet_style_qualification_for_field = false:warning
dotnet_style_qualification_for_property = false:warning
dotnet_style_qualification_for_method = false:warning
dotnet_style_qualification_for_event = false:warning
dotnet_style_require_accessibility_modifiers = never:warning
csharp_style_expression_bodied_methods = true:silent
csharp_style_expression_bodied_properties = true:warning
csharp_style_expression_bodied_indexers = true:warning
csharp_style_expression_bodied_accessors = true:warning
+64
View File
@@ -0,0 +1,64 @@
using System;
using Nuke.Common;
using Nuke.Common.Tools.DotNet;
using Numerge;
using static Nuke.Common.IO.FileSystemTasks;
using static Nuke.Common.Tools.DotNet.DotNetTasks;
partial class Build : NukeBuild {
/// Support plugins are available for:
/// - JetBrains ReSharper https://nuke.build/resharper
/// - JetBrains Rider https://nuke.build/rider
/// - Microsoft VisualStudio https://nuke.build/visualstudio
/// - Microsoft VSCode https://nuke.build/vscode
public static int Main() => Execute<Build>(x => x.Compile);
protected Target Clean => _ => _
.Executes(() =>
{
Parameters.BuildDirs.ForEach(DeleteDirectory);
Parameters.BuildDirs.ForEach(EnsureCleanDirectory);
EnsureCleanDirectory(Parameters.ArtifactsDir);
EnsureCleanDirectory(Parameters.NugetIntermediateRoot);
EnsureCleanDirectory(Parameters.NugetRoot);
EnsureCleanDirectory(Parameters.ZipRoot);
});
protected Target Compile => _ => _
.DependsOn(Clean)
.Executes(() =>
{
DotNetBuild(settings => ApplySetting(settings, buildSettings =>
buildSettings.SetProjectFile(Parameters.MSBuildSolution)));
});
protected Target CreateIntermediateNugetPackages => _ => _
.DependsOn(Compile)
.Executes(() =>
{
DotNetPack(settings => ApplySetting(settings, packSettings =>
packSettings.SetProject(Parameters.MSBuildSolution)
.SetOutputDirectory(Parameters.NugetIntermediateRoot))
);
});
protected Target CreateNugetPackage => _ => _
.DependsOn(CreateIntermediateNugetPackages)
.Produces(RootDirectory / "Material.Avalonia" / "bin" / "artifacts" / "nuget")
.Executes(() =>
{
var config = MergeConfiguration.LoadFile(RootDirectory / "build" / "numerge.config");
EnsureCleanDirectory(Parameters.NugetRoot);
if (!NugetPackageMerger.Merge(Parameters.NugetIntermediateRoot, Parameters.NugetRoot,
config, new NumergeNukeLogger()))
throw new Exception("Package merge failed");
});
protected Target ZipFiles => _ => _
.After(CreateNugetPackage, Compile)
.Executes(() =>
{
var data = Parameters;
Zip(data.ZipNuGetArtifacts, data.NugetRoot);
});
}
+160
View File
@@ -0,0 +1,160 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.InteropServices;
using Nuke.Common;
using Nuke.Common.CI.AzurePipelines;
using Nuke.Common.CI.GitHubActions;
using Nuke.Common.IO;
using Nuke.Common.ProjectModel;
using Nuke.Common.Tooling;
using Nuke.Common.Tools.DotNet;
using Nuke.Common.Utilities.Collections;
using Serilog;
partial class Build {
[Parameter("Configuration to build - Default is 'Debug' (local) or 'Release' (server)")]
readonly Configuration Configuration = IsLocalBuild ? Configuration.Debug : Configuration.Release;
[Parameter("version")]
public string Version { get; set; }
protected BuildParameters Parameters { get; set; }
[Solution(GenerateProjects = true)]
readonly Solution Solution;
protected override void OnBuildInitialized() {
Parameters = new BuildParameters(this);
Log.Information("Building version {0} of Material.Avalonia ({1}) using version {2} of Nuke.",
Parameters.Version,
Parameters.Configuration,
typeof(NukeBuild).Assembly.GetName().Version.ToString());
if (Parameters.IsLocalBuild) {
Log.Information("Repository Name: " + Parameters.RepositoryName);
Log.Information("Repository Branch: " + Parameters.RepositoryBranch);
}
Log.Information("Configuration: " + Parameters.Configuration);
Log.Information("IsLocalBuild: " + Parameters.IsLocalBuild);
Log.Information("IsRunningOnUnix: " + Parameters.IsRunningOnUnix);
Log.Information("IsRunningOnWindows: " + Parameters.IsRunningOnWindows);
Log.Information("IsRunningOnAzure: " + Parameters.IsRunningOnGithubActions);
Log.Information("IsPullRequest: " + Parameters.IsPullRequest);
Log.Information("IsMainRepo: " + Parameters.IsMainRepo);
Log.Information("IsMasterBranch: " + Parameters.IsNightlyRelease);
Log.Information("IsReleaseBranch: " + Parameters.IsReleaseBranch);
Log.Information("IsReleasable: " + Parameters.IsReleasable);
Log.Information("IsNuGetRelease: " + Parameters.IsNuGetRelease);
void ExecWait(string preamble, string command, string args) {
Console.WriteLine(preamble);
Process.Start(new ProcessStartInfo(command, args) { UseShellExecute = false }).WaitForExit();
}
ExecWait("dotnet version:", "dotnet", "--info");
ExecWait("dotnet workloads:", "dotnet", "workload list");
Log.Information("Processor count: " + Environment.ProcessorCount);
Log.Information("Available RAM: " + GC.GetGCMemoryInfo().TotalAvailableMemoryBytes / 0x100000 + "MB");
}
DotNetConfigHelper ApplySettingCore(DotNetConfigHelper c) {
c.AddProperty("PackageVersion", Parameters.Version)
.SetConfiguration(Parameters.Configuration)
.SetVerbosity(DotNetVerbosity.Minimal);
return c;
}
DotNetBuildSettings ApplySetting(DotNetBuildSettings c, Configure<DotNetBuildSettings> configurator = null) =>
ApplySettingCore(c).Build.Apply(configurator);
DotNetPackSettings ApplySetting(DotNetPackSettings c, Configure<DotNetPackSettings> configurator = null) =>
ApplySettingCore(c).Pack.Apply(configurator);
public class BuildParameters {
public string Configuration { get; }
public string MainRepo { get; }
public string NightlyAvailableBranch { get; }
public string RepositoryName { get; }
public string RepositoryBranch { get; }
public string ReleaseConfiguration { get; }
public string ReleaseBranchPrefix { get; }
public string MSBuildSolution { get; }
public string CommitMessage { get; }
public bool IsLocalBuild { get; }
public bool IsRunningOnUnix { get; }
public bool IsRunningOnWindows { get; }
public bool IsRunningOnGithubActions { get; }
public bool IsPullRequest { get; }
public bool IsMainRepo { get; }
public bool IsNightlyRelease { get; }
public bool IsReleaseBranch { get; }
public bool IsReleasable { get; }
public bool IsNuGetRelease { get; }
public bool PublishTestResults { get; }
public string Version { get; }
public AbsolutePath ArtifactsDir { get; }
public AbsolutePath NugetIntermediateRoot { get; }
public AbsolutePath NugetRoot { get; }
public AbsolutePath ZipRoot { get; }
public string DirSuffix { get; }
public List<AbsolutePath> BuildDirs { get; }
public string FileZipSuffix { get; }
public AbsolutePath ZipNuGetArtifacts { get; }
public BuildParameters(Build b) {
// ARGUMENTS
Configuration = b.Configuration ?? "Release";
// CONFIGURATION
MainRepo = "https://github.com/AvaloniaCommunity/Material.Avalonia";
NightlyAvailableBranch = "refs/heads/dev";
ReleaseBranchPrefix = "refs/heads/release/";
ReleaseConfiguration = "Release";
MSBuildSolution = RootDirectory / "Material.Avalonia.sln";
// PARAMETERS
IsLocalBuild = NukeBuild.IsLocalBuild;
IsRunningOnUnix = Environment.OSVersion.Platform == PlatformID.Unix ||
Environment.OSVersion.Platform == PlatformID.MacOSX;
IsRunningOnWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows);
IsRunningOnGithubActions = Host is GitHubActions;
if (IsRunningOnGithubActions) {
RepositoryName = GitHubActions.Instance.ServerUrl + GitHubActions.Instance.Repository;
RepositoryBranch = GitHubActions.Instance.Ref;
IsPullRequest = GitHubActions.Instance.Ref.StartsWith("refs/pull", StringComparison.OrdinalIgnoreCase);
CommitMessage = GitHubActions.Instance.GitHubEvent["head_commit"]!.Value<string>("message");
}
IsMainRepo = StringComparer.OrdinalIgnoreCase.Equals(MainRepo, RepositoryName);
IsNightlyRelease = IsMainRepo
&& RepositoryBranch?.StartsWith(NightlyAvailableBranch, StringComparison.OrdinalIgnoreCase) == true
&& !CommitMessage.Contains("no nightly");
IsReleaseBranch = RepositoryBranch?.StartsWith(ReleaseBranchPrefix, StringComparison.OrdinalIgnoreCase) == true;
IsReleasable = StringComparer.OrdinalIgnoreCase.Equals(ReleaseConfiguration, Configuration);
IsNuGetRelease = IsMainRepo && IsReleasable && IsReleaseBranch;
// VERSION
Version = b.Version ?? b.Solution.Material_Avalonia.GetProperty(nameof(Version));
if (IsRunningOnGithubActions) {
if (IsNightlyRelease) {
// Use AssemblyVersion with Build as version
Version += "." + GitHubActions.Instance.RunNumber + "-nightly";
}
PublishTestResults = true;
}
// DIRECTORIES
ArtifactsDir = RootDirectory / "Material.Avalonia" / "bin" / "artifacts";
NugetRoot = ArtifactsDir / "nuget";
NugetIntermediateRoot = RootDirectory / "Material.Avalonia" / "bin" / "build-intermediate" / "nuget";
ZipRoot = ArtifactsDir / "zip";
BuildDirs = RootDirectory.GlobDirectories(RootDirectory, "**bin").Concat(RootDirectory.GlobDirectories("**obj")).ToList();
DirSuffix = Configuration;
FileZipSuffix = Version + ".zip";
ZipNuGetArtifacts = ZipRoot / ("Material.Avalonia-NuGet-" + FileZipSuffix);
}
}
}
+16
View File
@@ -0,0 +1,16 @@
using System;
using System.ComponentModel;
using System.Linq;
using Nuke.Common.Tooling;
[TypeConverter(typeof(TypeConverter<Configuration>))]
public class Configuration : Enumeration
{
public static Configuration Debug = new Configuration { Value = nameof(Debug) };
public static Configuration Release = new Configuration { Value = nameof(Release) };
public static implicit operator string(Configuration configuration)
{
return configuration.Value;
}
}
+8
View File
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- This file prevents unintended imports of unrelated MSBuild files -->
<!-- Uncomment to include parent Directory.Build.props file -->
<!--<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" />-->
</Project>
+8
View File
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- This file prevents unintended imports of unrelated MSBuild files -->
<!-- Uncomment to include parent Directory.Build.targets file -->
<!--<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.targets', '$(MSBuildThisFileDirectory)../'))" />-->
</Project>
+57
View File
@@ -0,0 +1,57 @@
using System.Globalization;
using JetBrains.Annotations;
using Nuke.Common.Tools.DotNet;
// ReSharper disable ReturnValueOfPureMethodIsNotUsed
public class DotNetConfigHelper
{
public DotNetBuildSettings Build;
public DotNetPackSettings Pack;
public DotNetTestSettings Test;
public DotNetConfigHelper(DotNetBuildSettings s)
{
Build = s;
}
public DotNetConfigHelper(DotNetPackSettings s)
{
Pack = s;
}
public DotNetConfigHelper(DotNetTestSettings s)
{
Test = s;
}
public DotNetConfigHelper AddProperty(string key, bool value) =>
AddProperty(key, value.ToString(CultureInfo.InvariantCulture).ToLowerInvariant());
public DotNetConfigHelper AddProperty(string key, string value)
{
Build = Build?.AddProperty(key, value);
Pack = Pack?.AddProperty(key, value);
Test = Test?.AddProperty(key, value);
return this;
}
public DotNetConfigHelper SetConfiguration(string configuration)
{
Build = Build?.SetConfiguration(configuration);
Pack = Pack?.SetConfiguration(configuration);
Test = Test?.SetConfiguration(configuration);
return this;
}
public DotNetConfigHelper SetVerbosity(DotNetVerbosity verbosity)
{
Build = Build?.SetVerbosity(verbosity);
Pack = Pack?.SetVerbosity(verbosity);
Test = Test?.SetVerbosity(verbosity);
return this;
}
public static implicit operator DotNetConfigHelper(DotNetBuildSettings s) => new DotNetConfigHelper(s);
public static implicit operator DotNetConfigHelper(DotNetPackSettings s) => new DotNetConfigHelper(s);
public static implicit operator DotNetConfigHelper(DotNetTestSettings s) => new DotNetConfigHelper(s);
}
+49
View File
@@ -0,0 +1,49 @@
using Nuke.Common;
using Nuke.Common.CI.GitHubActions;
using Nuke.Common.Tools.DotNet;
using static Nuke.Common.EnvironmentInfo;
using static Nuke.Common.IO.FileSystemTasks;
using static Nuke.Common.IO.PathConstruction;
using static Nuke.Common.Tools.MSBuild.MSBuildTasks;
using static Nuke.Common.Tools.DotNet.DotNetTasks;
using static Nuke.Common.Tools.Xunit.XunitTasks;
using static Nuke.Common.Tools.VSWhere.VSWhereTasks;
/// <summary>
/// Representing targets for github pipeline for main repository
/// </summary>
[GitHubActions("main", GitHubActionsImage.UbuntuLatest, AutoGenerate = true, Submodules = GitHubActionsSubmodules.Recursive,
InvokedTargets = new[] { nameof(Compile), nameof(PublishNugetPackage) },
ImportSecrets = new[] { nameof(NuGetKey) }, EnableGitHubToken = true,
On = new[] {
GitHubActionsTrigger.Push,
GitHubActionsTrigger.PullRequest
})]
partial class Build {
[Parameter] [Secret] readonly string NuGetKey;
/// <summary>
/// Publishing artifacts for main Material.Avalonia repo
/// </summary>
Target PublishNugetPackage => _ => _
.Unlisted()
.DependsOn(CreateNugetPackage)
.OnlyWhenStatic(() => IsServerBuild)
.OnlyWhenDynamic(
() => Parameters.IsMainRepo,
() => Parameters.IsReleasable)
.Executes(() =>
{
GitHubActions.Instance.Token.NotNullOrEmpty("Github token should be not null or empty to publish packages");
DotNetNuGetPush(settings => settings
.SetSource("https://nuget.pkg.github.com/AvaloniaCommunity/index.json")
.SetApiKey(GitHubActions.Instance.Token)
.EnableSkipDuplicate());
NuGetKey.NotNullOrEmpty("NuGet api key should be not null or empty to publish packages");
DotNetNuGetPush(settings => settings
.SetSource("https://api.nuget.org/v3/index.json")
.SetApiKey(NuGetKey)
.EnableSkipDuplicate());
});
}
Submodule
+1
Submodule build/Numerge added at fb92f917cd
+11
View File
@@ -0,0 +1,11 @@
using Numerge;
class NumergeNukeLogger : INumergeLogger {
public void Log(NumergeLogLevel level, string message) {
if (level == NumergeLogLevel.Error)
Serilog.Log.Error(message);
else if (level == NumergeLogLevel.Warning)
Serilog.Log.Warning(message);
else
Serilog.Log.Information(message);
}
}
+53
View File
@@ -0,0 +1,53 @@
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Linq;
using Nuke.Common.IO;
partial class Build {
private void Zip(AbsolutePath target, params string[] paths) => Zip(target, paths.AsEnumerable());
private void Zip(AbsolutePath target, IEnumerable<string> paths) {
var targetPath = target.ToString();
bool finished = false, atLeastOneFileAdded = false;
try {
using (var targetStream = File.Create(targetPath))
using (var archive = new System.IO.Compression.ZipArchive(targetStream, ZipArchiveMode.Create)) {
void AddFile(string path, string relativePath) {
var e = archive.CreateEntry(relativePath.Replace("\\", "/"), CompressionLevel.Optimal);
using (var entryStream = e.Open())
using (var fileStream = File.OpenRead(path))
fileStream.CopyTo(entryStream);
atLeastOneFileAdded = true;
}
foreach (var path in paths) {
if (Directory.Exists(path)) {
var dirInfo = new DirectoryInfo(path);
var rootPath = Path.GetDirectoryName(dirInfo.FullName);
foreach (var fsEntry in dirInfo.EnumerateFileSystemInfos("*", SearchOption.AllDirectories)) {
if (fsEntry is FileInfo) {
var relPath = Path.GetRelativePath(rootPath, fsEntry.FullName);
AddFile(fsEntry.FullName, relPath);
}
}
}
else if (File.Exists(path)) {
var name = Path.GetFileName(path);
AddFile(path, name);
}
}
}
finished = true;
}
finally {
try {
if (!finished || !atLeastOneFileAdded)
File.Delete(targetPath);
}
catch {
//Ignore
}
}
}
}
+22
View File
@@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<RootNamespace></RootNamespace>
<NoWarn>CS0649;CS0169</NoWarn>
<NukeRootDirectory>..</NukeRootDirectory>
<NukeScriptDirectory>..</NukeScriptDirectory>
<NukeTelemetryVersion>1</NukeTelemetryVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Nuke.Common" Version="6.2.1" />
</ItemGroup>
<ItemGroup>
<Compile Remove="Numerge/**/*.*" />
<Compile Include="Numerge/Numerge/**/*.cs" />
</ItemGroup>
</Project>
+27
View File
@@ -0,0 +1,27 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=HeapView_002EDelegateAllocation/@EntryIndexedValue">DO_NOT_SHOW</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=VariableHidesOuterVariable/@EntryIndexedValue">DO_NOT_SHOW</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=ClassNeverInstantiated_002EGlobal/@EntryIndexedValue">DO_NOT_SHOW</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=MemberCanBeMadeStatic_002ELocal/@EntryIndexedValue">DO_NOT_SHOW</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/DEFAULT_INTERNAL_MODIFIER/@EntryValue">Implicit</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/DEFAULT_PRIVATE_MODIFIER/@EntryValue">Implicit</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/METHOD_OR_OPERATOR_BODY/@EntryValue">ExpressionBody</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/ThisQualifier/INSTANCE_MEMBERS_QUALIFY_MEMBERS/@EntryValue">0</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ANONYMOUS_METHOD_DECLARATION_BRACES/@EntryValue">NEXT_LINE</s:String>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/KEEP_USER_LINEBREAKS/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_AFTER_INVOCATION_LPAR/@EntryValue">False</s:Boolean>
<s:Int64 x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/MAX_ATTRIBUTE_LENGTH_FOR_SAME_LINE/@EntryValue">120</s:Int64>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_FIELD_ATTRIBUTE_ON_SAME_LINE_EX/@EntryValue">IF_OWNER_IS_SINGLE_LINE</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_ARGUMENTS_STYLE/@EntryValue">WRAP_IF_LONG</s:String>
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_SIMPLE_ANONYMOUSMETHOD_ON_SINGLE_LINE/@EntryValue">False</s:Boolean>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateInstanceFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateStaticFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpAttributeForSingleLineMethodUpgrade/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpKeepExistingMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpPlaceEmbeddedOnSameLineMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpRenamePlacementToArrangementMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpUseContinuousIndentInsideBracesMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EAddAccessorOwnerDeclarationBracesMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002ECSharpPlaceAttributeOnSameLineMigration/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateBlankLinesAroundFieldToBlankLinesAroundProperty/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateThisQualifierSettings/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>