Skip to content

Commit

Permalink
Merge pull request #7 from twenzel/UpdateProject
Browse files Browse the repository at this point in the history
Update cake
  • Loading branch information
twenzel authored Jan 24, 2022
2 parents 1e0f549 + 801bd34 commit f342dc4
Show file tree
Hide file tree
Showing 9 changed files with 109 additions and 390 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": "2.0.0",
"commands": [
"dotnet-cake"
]
}
}
}
40 changes: 31 additions & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,42 @@
name: Build & Test

on: [push, pull_request]

on:
push:
branches:
- master
- develop
- main
tags:
- "*"
paths-ignore:
- "README.md"
pull_request:

jobs:
build:

runs-on: windows-latest
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest, ubuntu-18.04, macos-latest]

steps:
- uses: actions/checkout@v1
- name: Setup .NET Core
- name: Checkout the repository
uses: actions/checkout@v2

- name: Fetch all tags and branches
run: git fetch --prune --unshallow

- name: Install .NET SDK
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.100
# gitversion needs 5.0 and we need all SDKs the project is targeting
dotnet-version: |
3.1.x
5.0.x
6.0.x
- name: run cake
uses: ecampidoglio/cake-action@v1.1.1
uses: ecampidoglio/cake-action@v1
with:
target: Pack
cake-version: 0.35.0
target: Test
14 changes: 8 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,22 @@ on:
jobs:
build:

runs-on: windows-latest
runs-on: ubuntu-18.04

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2

- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.100
dotnet-version: |
3.1.x
5.0.x
6.0.x
- name: run cake
uses: ecampidoglio/cake-action@v1.1.1
uses: ecampidoglio/cake-action@v1
with:
target: Publish
cake-version: 0.35.0
target: Publish
env:
nugetApiKey: ${{ secrets.nugetApiKey }}
6 changes: 3 additions & 3 deletions WebOptimizer.Dotless.sln
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27004.2008
# Visual Studio Version 17
VisualStudioVersion = 17.0.32112.339
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WebOptimizer.Dotless", "src\WebOptimizer.Dotless.csproj", "{B30F1B43-84C3-476C-996E-78803CCE9C19}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebOptimizer.Dotless.Test", "test\WebOptimizer.Dotless.Test.csproj", "{080EB5C5-EBBC-4F94-8A0F-238E0542FB35}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WebOptimizer.Dotless.Test", "test\WebOptimizer.Dotless.Test.csproj", "{080EB5C5-EBBC-4F94-8A0F-238E0542FB35}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
69 changes: 32 additions & 37 deletions build.cake
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#tool "nuget:?package=GitVersion.CommandLine&version=4.0.0"
#tool "nuget:?package=nuget.commandline&version=5.3.0"
#tool "dotnet:?package=GitVersion.Tool&version=5.8.1"
#tool "nuget:?package=NuGet.CommandLine&version=5.11.0"

var target = Argument("target", "Default");
var nugetApiKey = Argument("nugetApiKey", EnvironmentVariable("nugetApiKey"));
Expand All @@ -9,9 +9,13 @@ var nugetApiKey = Argument("nugetApiKey", EnvironmentVariable("nugetApiKey"));
/////////////////////////////////////////////////////////////////////
var solution = "./WebOptimizer.Dotless.sln";
var project = "./src/WebOptimizer.Dotless.csproj";
var outputDir = "./buildArtifacts/";
var outputDirNuget = outputDir+"NuGet/";
var testResultsPath = System.IO.Path.Combine(System.IO.Path.GetFullPath(outputDir), "TestResults.xml");
var outputDirRoot = new DirectoryPath("./buildArtifacts/").MakeAbsolute(Context.Environment);
var outputDirPublished = outputDirRoot.Combine("Published");
var outputDirTemp = outputDirRoot.Combine("Temp");
var packageOutputDir = outputDirPublished.Combine("Package");

var outputDirTests = outputDirTemp.Combine("Tests/");

var nugetPublishFeed = "https://api.nuget.org/v3/index.json";


Expand All @@ -23,14 +27,12 @@ Task("Clean")
.Description("Removes the output directory")
.Does(() => {

if (DirectoryExists(outputDir))
{
DeleteDirectory(outputDir, new DeleteDirectorySettings {
EnsureDirectoryDoesNotExist(outputDirRoot, new DeleteDirectorySettings {
Recursive = true,
Force = true
});
}
CreateDirectory(outputDir);
});
CreateDirectory(outputDirRoot);
CreateDirectory(outputDirPublished);
});

GitVersion versionInfo = null;
Expand All @@ -50,48 +52,41 @@ Task("Build")
.IsDependentOn("Version")
.Does(() => {

var settings = new DotNetCoreBuildSettings {
Configuration = "Release",
ArgumentCustomization = args => args.Append("/p:SemVer=" + versionInfo.NuGetVersionV2 + " /p:SourceLinkCreate=true")
};
var msBuildSettings = new DotNetMSBuildSettings()
{
Version = versionInfo.AssemblySemVer,
InformationalVersion = versionInfo.InformationalVersion,
PackageVersion = versionInfo.NuGetVersionV2
}.WithProperty("PackageOutputPath", packageOutputDir.FullPath);

DotNetCoreBuild(project, settings);
var settings = new DotNetBuildSettings {
Configuration = "Release",
MSBuildSettings = msBuildSettings
};

DotNetBuild(project, settings);
});

Task("Test")
.IsDependentOn("Build")
.Does(() =>
{
var settings = new DotNetCoreTestSettings {
Logger = "trx;logfilename=" + testResultsPath
var settings = new DotNetTestSettings {
Loggers = new[]{"trx;"},
ResultsDirectory = outputDirTests,
NoBuild = true
};

DotNetCoreTest("./test/WebOptimizer.Dotless.Test.csproj", settings);
});


Task("Pack")
.IsDependentOn("Test")
.IsDependentOn("Version")
.Does(() => {

var packSettings = new DotNetCorePackSettings
{
Configuration = "Release",
OutputDirectory = outputDirNuget,
ArgumentCustomization = args => args.Append("/p:PackageVersion=" + versionInfo.NuGetVersionV2+ " /p:SourceLinkCreate=true")
};

DotNetCorePack(project, packSettings);
DotNetTest("./test/WebOptimizer.Dotless.Test.csproj", settings);
});

Task("Publish")
.IsDependentOn("Pack")
.IsDependentOn("Test")
.Description("Pushes the created NuGet packages to nuget.org")
.Does(() => {

// Get the paths to the packages.
var packages = GetFiles(outputDirNuget + "*.nupkg");
var packages = GetFiles(packageOutputDir.CombineWithFilePath("*.nupkg").FullPath);

// Push the package.
NuGetPush(packages, new NuGetPushSettings {
Expand Down
Loading

0 comments on commit f342dc4

Please sign in to comment.