Skip to content

Commit

Permalink
upgrade ci
Browse files Browse the repository at this point in the history
  • Loading branch information
tl-Roberto-Mancinelli committed Nov 22, 2024
1 parent 615c1ef commit 774632b
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 112 deletions.
18 changes: 6 additions & 12 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,23 @@ jobs:
build:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup Java
uses: actions/setup-java@v1
with:
java-version: 11.0.x
- uses: actions/checkout@v4
- name: Setup .NET 9.0
uses: actions/setup-dotnet@v1
uses: actions/setup-dotnet@v2
with:
dotnet-version: 9.0.x
- name: Setup .NET 8.0
uses: actions/setup-dotnet@v1
uses: actions/setup-dotnet@v2
with:
dotnet-version: 8.0.x
- name: Setup .NET 2.1
uses: actions/setup-dotnet@v1
uses: actions/setup-dotnet@v2
with:
dotnet-version: 2.1.x
- name: Restore tools
run: dotnet tool restore
- name: Run the build script
uses: cake-build/cake-action@v1
uses: cake-build/cake-action@v2
env:
COVERALLS_TOKEN: ${{ secrets.COVERALLS_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
Expand All @@ -47,7 +41,7 @@ jobs:
TrueLayer__ClientSecret: ${{ secrets.TRUELAYER__CLIENTSECRET }}
TrueLayer__Payments__SigningKey__KeyId: ${{ secrets.TRUELAYER__PAYMENTS__SIGNINGKEY__KEYID }}
with:
cake-version: 1.3.0
cake-version: 5.0.0
target: CI
verbosity: ${{ github.event.inputs.verbosity }}
- name: Upload pre-release packages
Expand Down
18 changes: 6 additions & 12 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,29 +22,23 @@ jobs:
publish:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup Java
uses: actions/setup-java@v1
with:
java-version: 11.0.x
- uses: actions/checkout@v4
- name: Setup .NET 9.0
uses: actions/setup-dotnet@v1
uses: actions/setup-dotnet@v2
with:
dotnet-version: 9.0.x
- name: Setup .NET 8.0
uses: actions/setup-dotnet@v1
uses: actions/setup-dotnet@v2
with:
dotnet-version: 8.0.x
- name: Setup .NET 2.1
uses: actions/setup-dotnet@v1
uses: actions/setup-dotnet@v2
with:
dotnet-version: 2.1.x
- name: Restore tools
run: dotnet tool restore
- name: Run the build script
uses: cake-build/cake-action@v1
uses: cake-build/cake-action@v2
env:
COVERALLS_TOKEN: ${{ secrets.COVERALLS_TOKEN }}
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
Expand All @@ -58,7 +52,7 @@ jobs:
TrueLayer__ClientSecret: ${{ secrets.TRUELAYER__CLIENTSECRET }}
TrueLayer__Payments__SigningKey__KeyId: ${{ secrets.TRUELAYER__PAYMENTS__SIGNINGKEY__KEYID }}
with:
cake-version: 1.3.0
cake-version: 5.0.0
target: ${{ github.event.inputs.target || 'Publish' }}
verbosity: ${{ github.event.inputs.verbosity || 'Normal' }}
arguments: |
Expand Down
104 changes: 16 additions & 88 deletions build.cake
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
// Install .NET Core Global tools.
#tool "dotnet:?package=dotnet-reportgenerator-globaltool&version=5.0.0"
#tool "dotnet:?package=coveralls.net&version=3.0.0"
#tool "dotnet:?package=dotnet-sonarscanner&version=5.4.0"
#tool nuget:?package=docfx.console&version=2.58.9
#tool nuget:?package=KuduSync.NET&version=1.5.3
#tool "dotnet:?package=dotnet-reportgenerator-globaltool&version=5.4.1"
#tool "dotnet:?package=coveralls.net&version=4.0.1"
#tool "dotnet:?package=dotnet-sonarscanner&version=9.0.2"
#tool nuget:?package=KuduSync.NET&version=1.5.4

// Install addins
#addin nuget:?package=Cake.Coverlet&version=2.5.4
#addin nuget:?package=Cake.Sonar&version=1.1.26
#addin nuget:?package=Cake.DocFx&version=1.0.0
#addin nuget:?package=Cake.Git&version=1.1.0
#addin nuget:?package=Cake.Kudu&version=1.3.0
#addin nuget:?package=Cake.Coverlet&version=4.0.1
#addin nuget:?package=Cake.Sonar&version=1.1.33
#addin nuget:?package=Cake.Git&version=4.0.0
#addin nuget:?package=Cake.Kudu&version=3.0.0

#r "System.Text.Json"
#r "System.IO"
Expand Down Expand Up @@ -83,15 +81,15 @@ Task("SonarBegin")
Url = "https://sonarcloud.io",
Exclusions = "test/**,examples/**",
OpenCoverReportsPath = $"{coveragePath}/*.xml",
Login = sonarToken,
Token = sonarToken,
VsTestReportsPath = $"{artifactsPath}/*.TestResults.xml",
});
});

Task("Build")
.Does(() =>
{
DotNetCoreBuild("TrueLayer.sln", new DotNetCoreBuildSettings
DotNetBuild("TrueLayer.sln", new DotNetBuildSettings
{
Configuration = configuration
});
Expand All @@ -104,7 +102,7 @@ Task("Test")
{
var projectName = project.GetFilenameWithoutExtension();

var testSettings = new DotNetCoreTestSettings
var testSettings = new DotNetTestSettings
{
NoBuild = true,
Configuration = configuration,
Expand All @@ -122,15 +120,15 @@ Task("Test")
//Threshold = coverageThreshold
};

DotNetCoreTest(project.ToString(), testSettings, coverletSettings);
DotNetTest(project.ToString(), testSettings, coverletSettings);
}
});


Task("Pack")
.Does(() =>
{
var settings = new DotNetCorePackSettings
var settings = new DotNetPackSettings
{
Configuration = configuration,
OutputDirectory = artifactsPath,
Expand All @@ -139,7 +137,7 @@ Task("Pack")

foreach (var file in GetFiles(packFiles))
{
DotNetCorePack(file.ToString(), settings);
DotNetPack(file.ToString(), settings);
}
});

Expand Down Expand Up @@ -202,7 +200,7 @@ Task("PublishPackages")
{
foreach(var package in GetFiles(packages))
{
DotNetCoreNuGetPush(package.ToString(), new DotNetCoreNuGetPushSettings {
DotNetNuGetPush(package.ToString(), new DotNetNuGetPushSettings {
ApiKey = BuildContext.NugetApiKey,
Source = BuildContext.NugetApiUrl,
SkipDuplicate = true
Expand All @@ -216,77 +214,10 @@ Task("SonarEnd")
{
SonarEnd(new SonarEndSettings
{
Login = sonarToken
Token = sonarToken
});
});

Task("BuildDocs")
.Does(() =>
{
Information("Extracting API Metadata");
DocFxMetadata(docFxConfig);

Information("Building Docs");
DocFxBuild(docFxConfig);
});

Task("ServeDocs")
.IsDependentOn("BuildDocs")
.Does(() =>
{
using (var process = DocFxServeStart(sitePath))
{
// Launch browser or other action based on the site
process.WaitForExit();
}
});

Task("PublishDocs")
.IsDependentOn("BuildDocs")
.WithCriteria(!string.IsNullOrEmpty(gitHubPagesToken))// && currentBranch.FriendlyName == "main")
.Does(() =>
{
// Get the current commit
var sourceCommit = currentBranch.Tip;
var publishFolder = $"./artifacts/docs-publish-{DateTime.Now.ToString("yyyyMMdd_HHmmss")}";
Information("Publishing Folder: {0}", publishFolder);
Information("Getting publish branch...");
GitClone("https://github.com/TrueLayer/truelayer-dotnet.git",
publishFolder,
gitHubUser,
gitHubPagesToken,
new GitCloneSettings { BranchName = "gh-pages" }
);

Information("Sync output files...");

Kudu.Sync(sitePath, publishFolder, new KuduSyncSettings {
ArgumentCustomization = args => args.Append("--ignore").AppendQuoted(".git;CNAME")
});

if (GitHasUncommitedChanges(publishFolder))
{
GitAddAll(publishFolder);
Information("Stage all changes...");

// Only considers modified files - https://github.com/cake-contrib/Cake_Git/issues/77
if (BuildContext.ForcePushDocs || GitHasStagedChanges(publishFolder))
{
Information("Commit all changes...");
GitCommit(
publishFolder,
sourceCommit.Committer.Name,
sourceCommit.Committer.Email,
string.Format("Continuous Integration Publish: {0}\r\n{1}", sourceCommit.Sha, sourceCommit.Message)
);

Information("Pushing all changes...");

GitPush(publishFolder, gitHubUser, gitHubPagesToken, "gh-pages");
}
}
});

Task("Dump").Does(() => BuildContext.PrintParameters(Context));

Task("Default")
Expand All @@ -295,7 +226,6 @@ Task("Default")
.IsDependentOn("Test")
.IsDependentOn("Pack")
.IsDependentOn("GenerateReports")
.IsDependentOn("BuildDocs");

Task("CI")
//.IsDependentOn("SonarBegin")
Expand All @@ -306,11 +236,9 @@ Task("CI")
Task("Publish")
.IsDependentOn("CI")
.IsDependentOn("PublishPackages");
//.IsDependentOn("PublishDocs");

RunTarget(target);


public static class BuildContext
{
public static bool IsTag { get; private set; }
Expand Down

0 comments on commit 774632b

Please sign in to comment.