Skip to content

Commit

Permalink
Housekeeping - Bump to latest version of Cake (#53)
Browse files Browse the repository at this point in the history
* Bump to Cake 3.0.0
  • Loading branch information
Romanx authored Nov 17, 2022
1 parent 70f380c commit f9cde5c
Show file tree
Hide file tree
Showing 16 changed files with 270 additions and 540 deletions.
12 changes: 12 additions & 0 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"version": 1,
"isRoot": true,
"tools": {
"cake.tool": {
"version": "3.0.0",
"commands": [
"dotnet-cake"
]
}
}
}
34 changes: 34 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Build and Test
on:
push:
pull_request:
branches: [ main ]
paths:
- '**.cs'
- '**.csproj'
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macOS-latest]
steps:
- name: Get the sources
uses: actions/checkout@v2
with:
fetch-depth: 0 # avoid shallow clone so nbgv can do its work.
- name: Nerdbank.GitVersioning
uses: dotnet/[email protected]
with:
setAllVars: true
- name: Run the build script
uses: cake-build/cake-action@v1
with:
target: Pack
- name: Upload a Build Artifact
uses: actions/[email protected]
if: runner.os == 'Windows'
with:
if-no-files-found: warn
name: packages
path: ./artifacts/*.nupkg
34 changes: 34 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Publish

on:
push:
branches:
- main

jobs:
release:
name: Release
if: "!contains(github.event.head_commit.message, 'skip-ci')"
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Setup dotnet
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.x

- name: Nerdbank.GitVersioning
uses: dotnet/[email protected]
with:
setAllVars: true

- name: Build
uses: cake-build/cake-action@v1
env:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
with:
target: Github
7 changes: 3 additions & 4 deletions Cake.Coverlet.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26124.0
# Visual Studio Version 17
VisualStudioVersion = 17.4.32804.182
MinimumVisualStudioVersion = 15.0.26124.0
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{E0CB0BC0-F7D4-4D3B-97C3-15C790FFC71D}"
EndProject
Expand All @@ -10,15 +10,14 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{A651E8AD-703B-4B21-B344-68F5F09CDA67}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
appveyor.yml = appveyor.yml
build.cake = build.cake
readme.md = readme.md
version.json = version.json
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{EEC95ADF-2D7A-4B97-9D4E-27F2F198FFC6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cake.Coverlet.Tests", "test\Cake.Coverlet.Tests\Cake.Coverlet.Tests.csproj", "{77208523-570A-4419-B4C9-F26B33D3BAA0}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Cake.Coverlet.Tests", "test\Cake.Coverlet.Tests\Cake.Coverlet.Tests.csproj", "{77208523-570A-4419-B4C9-F26B33D3BAA0}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
18 changes: 0 additions & 18 deletions appveyor.yml

This file was deleted.

45 changes: 33 additions & 12 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -25,32 +25,53 @@ Task("Restore")
.IsDependentOn("Clean")
.Does(() =>
{
DotNetCoreRestore("./Cake.Coverlet.sln");
DotNetRestore("./Cake.Coverlet.sln");
});

Task("Build")
.IsDependentOn("Restore")
.Does<MyBuildData>((data) =>
{
DotNetCoreBuild("./Cake.Coverlet.sln", data.BuildSettings);
DotNetBuild("./Cake.Coverlet.sln", data.BuildSettings);
});

Task("Test")
.IsDependentOn("Build")
.Does<MyBuildData>((data) =>
{
DotNetCoreTest("./test/Cake.Coverlet.Tests", data.TestSettings);
DotNetTest("./test/Cake.Coverlet.Tests", data.TestSettings);
});

Task("Pack")
.IsDependentOn("Test")
.Does<MyBuildData>((data) =>
{
DotNetCorePack("./src/Cake.Coverlet/Cake.Coverlet.csproj", data.PackSettings);
DotNetPack("./src/Cake.Coverlet/Cake.Coverlet.csproj", data.PackSettings);
});

Task("AppVeyor")
.IsDependentOn("Pack");
Task("Publish")
.IsDependentOn("Pack")
.Does<MyBuildData>((ICakeContext context, MyBuildData data) =>
{
// Make sure that there is an API key.
var apiKey = context.EnvironmentVariable("NUGET_API_KEY");
if (string.IsNullOrWhiteSpace(apiKey)) {
throw new CakeException("No NuGet API key specified.");
}

// Publish all projects
foreach(var file in GetFiles($"./{data.ArtifactsDirectory}/*.nupkg"))
{
context.Information("Publishing {0}...", file.GetFilename().FullPath);
context.NuGetPush(file, new NuGetPushSettings {
ApiKey = apiKey,
Source = "https://api.nuget.org/v3/index.json"
});
}
});

Task("Github")
.IsDependentOn("Publish");

Task("Default")
.IsDependentOn("Pack");
Expand All @@ -61,9 +82,9 @@ public class MyBuildData
{
public string Configuration { get; }
public ConvertableDirectoryPath ArtifactsDirectory { get; }
public DotNetCoreBuildSettings BuildSettings { get; }
public DotNetCorePackSettings PackSettings { get; }
public DotNetCoreTestSettings TestSettings { get; }
public DotNetBuildSettings BuildSettings { get; }
public DotNetPackSettings PackSettings { get; }
public DotNetTestSettings TestSettings { get; }
public IReadOnlyList<ConvertableDirectoryPath> BuildDirs { get; }

public MyBuildData(
Expand All @@ -75,20 +96,20 @@ public class MyBuildData
ArtifactsDirectory = artifactsDirectory;
BuildDirs = buildDirectories;

BuildSettings = new DotNetCoreBuildSettings {
BuildSettings = new DotNetBuildSettings {
Configuration = configuration,
NoRestore = true,
ArgumentCustomization = args => args.Append("/property:WarningLevel=0") // Until Warnings are fixed in StyleCop
};

PackSettings = new DotNetCorePackSettings
PackSettings = new DotNetPackSettings
{
OutputDirectory = ArtifactsDirectory,
NoBuild = true,
Configuration = Configuration,
};

TestSettings = new DotNetCoreTestSettings
TestSettings = new DotNetTestSettings
{
NoBuild = true,
Configuration = Configuration
Expand Down
Loading

0 comments on commit f9cde5c

Please sign in to comment.