Skip to content

Commit

Permalink
nuke build, minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
MiloszKrajewski committed Feb 21, 2023
1 parent 58120f5 commit e264aab
Show file tree
Hide file tree
Showing 55 changed files with 938 additions and 760 deletions.
12 changes: 12 additions & 0 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@
"commands": [
"r"
]
},
"dotnet-outdated-tool": {
"version": "4.5.0",
"commands": [
"dotnet-outdated"
]
},
"paket": {
"version": "7.2.0",
"commands": [
"paket"
]
}
}
}
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
COMPOSE_PROJECT_NAME=K4os.Text.BaseX
39 changes: 39 additions & 0 deletions .github/workflows/continuous.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# ------------------------------------------------------------------------------
# <auto-generated>
#
# This code was generated.
#
# - To turn off auto-generation set:
#
# [GitHubActions (AutoGenerate = false)]
#
# - To trigger manual generation invoke:
#
# nuke --generate-configuration GitHubActions_continuous --host GitHubActions
#
# </auto-generated>
# ------------------------------------------------------------------------------

name: continuous

on: [push]

jobs:
windows-latest:
name: windows-latest
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- name: Cache .nuke/temp, ~/.nuget/packages
uses: actions/cache@v3
with:
path: |
.nuke/temp
~/.nuget/packages
key: ${{ runner.os }}-${{ hashFiles('**/global.json', '**/*.csproj') }}
- name: Run './build.cmd Release'
run: ./build.cmd Release
- uses: actions/upload-artifact@v3
with:
name: .output
path: .output
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ packages/
BenchmarkDotNet.Artifacts/

.secrets.cfg
*.snk
.signing.snk

*.bak
*.bak
*.user
3 changes: 3 additions & 0 deletions .nuke/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
temp/
bin/
obj/
116 changes: 116 additions & 0 deletions .nuke/build.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "Build Schema",
"$ref": "#/definitions/build",
"definitions": {
"build": {
"type": "object",
"properties": {
"Continue": {
"type": "boolean",
"description": "Indicates to continue a previously failed build attempt"
},
"Debug": {
"type": "boolean",
"description": "Use debug configuration"
},
"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"
},
"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": [
"Build",
"Clean",
"PublishToGitHub",
"PublishToNuget",
"Rebuild",
"Release",
"Restore",
"Test"
]
}
},
"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": [
"Build",
"Clean",
"PublishToGitHub",
"PublishToNuget",
"Rebuild",
"Release",
"Restore",
"Test"
]
}
},
"Verbosity": {
"type": "string",
"description": "Logging verbosity during build execution. Default is 'Normal'",
"enum": [
"Minimal",
"Normal",
"Quiet",
"Verbose"
]
}
}
}
}
}
11 changes: 11 additions & 0 deletions .nuke/build/.editorconfig
Original file line number Diff line number Diff line change
@@ -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
16 changes: 16 additions & 0 deletions .nuke/build/Configuration.cs
Original file line number Diff line number Diff line change
@@ -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;
}
}
12 changes: 12 additions & 0 deletions .nuke/build/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?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)../'))" />-->

<PropertyGroup>
<ManagePackageVersionsCentrally>false</ManagePackageVersionsCentrally>
</PropertyGroup>

</Project>
13 changes: 13 additions & 0 deletions .nuke/build/Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?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)../'))" />-->

<ItemGroup>
<None Remove="../../Directory.Build.*" Visible="false"/>
<None Remove="Directory.Build.*" Visible="false"/>
</ItemGroup>

</Project>
15 changes: 15 additions & 0 deletions .nuke/build/Extensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System.Collections.Generic;
using JetBrains.Annotations;

// ReSharper disable once CheckNamespace
namespace System;

public static class Extensions
{
public static string Join(this IEnumerable<string> source, string separator) =>
string.Join(separator, source);

[CanBeNull]
public static string NullIfEmpty([CanBeNull] this string value) =>
string.IsNullOrWhiteSpace(value) ? null : value;
}
74 changes: 74 additions & 0 deletions .nuke/build/GitHubReleaser.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
using System;
using System.IO;
using System.Threading.Tasks;
using NuGet.Versioning;
using Nuke.Common.ChangeLog;
using Nuke.Common.Git;
using Nuke.Common.IO;
using Nuke.Common.Tools.GitHub;
using Nuke.Common.Tools.GitVersion;
using Octokit;
using Octokit.Internal;
using Serilog;

public class GitHubReleaser
{
static async Task UploadReleaseAssetToGithub(Release release, string asset)
{
await using var artifactStream = File.OpenRead(asset);
var fileName = Path.GetFileName(asset);
var assetUpload = new ReleaseAssetUpload {
FileName = fileName,
ContentType = "application/octet-stream",
RawData = artifactStream,
};
Log.Information("Uploading {FileName}...", fileName);
await GitHubTasks.GitHubClient.Repository.Release.UploadAsset(release, assetUpload);
}

public static async Task Release(
string token,
NuGetVersion packageVersion,
GitRepository gitRepository,
GitVersion gitVersion,
ReleaseNotes releaseNotes,
AbsolutePath[] artifacts)
{
var credentials = new Credentials(token);

GitHubTasks.GitHubClient = new GitHubClient(
new ProductHeaderValue(nameof(GitHubReleaser)),
new InMemoryCredentialStore(credentials));

var releaseTag = packageVersion.ToString();
var repositoryOwner = gitRepository.GetGitHubOwner();
var repositoryName = gitRepository.GetGitHubName();

Log.Information("Creating draft release {ReleaseTag}...", releaseTag);

var newRelease = new NewRelease(releaseTag) {
TargetCommitish = gitVersion.Sha,
Draft = true,
Name = $"v{releaseTag}",
Prerelease = packageVersion.IsPrerelease,
Body = releaseNotes.Notes.Join("\n"),
};

var createdRelease = await GitHubTasks
.GitHubClient
.Repository
.Release.Create(repositoryOwner, repositoryName, newRelease);

foreach (var artifact in artifacts)
await UploadReleaseAssetToGithub(createdRelease, artifact);

Log.Information("Publishing release {ReleaseTag}...", releaseTag);
await GitHubTasks
.GitHubClient
.Repository
.Release
.Edit(
repositoryOwner, repositoryName, createdRelease.Id,
new ReleaseUpdate { Draft = false });
}
}
Loading

0 comments on commit e264aab

Please sign in to comment.