diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index 831d039..da200cd 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -3,7 +3,7 @@ "isRoot": true, "tools": { "cake.tool": { - "version": "3.0.0", + "version": "4.0.0", "commands": [ "dotnet-cake" ] diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 18399be..29f2e2f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,20 +14,20 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-18.04, ubuntu-latest, macos-latest, windows-2019, windows-2022] + os: [ubuntu-20.04, ubuntu-latest, macos-latest, windows-2019, windows-2022] steps: - name: Get the sources - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: fetch-depth: 0 - - name: Install .NET Core SDK (global.json) - uses: actions/setup-dotnet@v1 + - name: Install .NET SDK (global.json) + uses: actions/setup-dotnet@v4 with: - include-prerelease: 'true' + global-json-file: 'global.json' - name: Run Cake script - uses: cake-build/cake-action@v1 + uses: cake-build/cake-action@v2 env: matrix-os: ${{ matrix.os }} with: diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index a7c8654..0000000 --- a/.travis.yml +++ /dev/null @@ -1,22 +0,0 @@ -language: csharp -os: - - osx - - linux - -sudo: required -dist: bionic - -osx_image: xcode11.2 - -mono: - - 5.12.0 - -dotnet: 6.0.100 - -before_install: - - git fetch --unshallow # Travis always does a shallow clone, but GitVersion needs the full history including branches and tags - - git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*" - - git fetch origin - -script: - - ./build.sh \ No newline at end of file diff --git a/README.md b/README.md index e12bc74..6dd52da 100644 --- a/README.md +++ b/README.md @@ -4,10 +4,10 @@ Cake AddIn that extends Cake with Git features using LibGit2 and LibGit2Sharp. -| Build server | Platform | Status | -|-----------------------------|--------------|---------------------------------------------------------------------------------------------------------------------------| -| AppVeyor | Windows | [![Build status](https://ci.appveyor.com/api/projects/status/mycuknigvm2418ht/branch/develop?svg=true)](https://ci.appveyor.com/project/cakecontrib/cake-git/branch/develop) | -| Travis | Linux / OS X | [![Build Status](https://travis-ci.org/cake-contrib/Cake_Git.svg?branch=develop)](https://travis-ci.org/cake-contrib/Cake_Git) | +| Build server | Platform | Status | +|-----------------------------|-------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| AppVeyor | Windows | [![Build status](https://ci.appveyor.com/api/projects/status/mycuknigvm2418ht/branch/develop?svg=true)](https://ci.appveyor.com/project/cakecontrib/cake-git/branch/develop) | +| GitHub Actions | Windows / Linux / macOS | [![Build status](https://github.com/cake-contrib/Cake_Git/actions/workflows/build.yml/badge.svg)](https://github.com/cake-contrib/Cake_Git/actions/workflows/build.yml) | ## Documentation diff --git a/ReleaseNotes.md b/ReleaseNotes.md index ff8b78e..ef24e25 100644 --- a/ReleaseNotes.md +++ b/ReleaseNotes.md @@ -1,3 +1,10 @@ +### New in 4.0.0 (Released 2024/03/06) + +* Update to Cake 4.0 +* Multi-Target .NET 6, 7 & 8 +* Update to LibGit2Sharp 0.29.0 +* Introduce Cake.Frosting.Git addin for using with Cake Frosting + ### New in 3.0.0 (Released 2022/12/14) * Update Cake.Git to target Cake.Core 3.0.0 and net7.0 TFM diff --git a/ReleaseProcess.md b/ReleaseProcess.md new file mode 100644 index 0000000..37cf1ad --- /dev/null +++ b/ReleaseProcess.md @@ -0,0 +1,13 @@ +# How to release a new version of Cake.Git + +* Create release branch `release/vMajor.Minor.Patch` from `develop` (e.g. `git branch release/v3.1.4 develop`) +* Go to the branch (e.g. `git checkout release/v3.1.4`) +* Update the [`ReleaseNotes.md`](ReleaseNotes.md) (the build version number comes from parsing this file) +* Merge the release branch into the `master` branch (e.g. `git merge master`) +* Tag the updated `master` branch with the version (e.g. `git tag v3.1.4`) +* Push the `master` branch with the tag to GitHub (e.g. `git push origin master --tags`) +* The [AppVeyor build](https://ci.appveyor.com/project/cakecontrib/cake-git/history) will publish the NuGet package automatically +* Merge the `master` branch into into `develop` to bring the updated [`ReleaseNotes.md`](ReleaseNotes.md) +* Create and publish a new [release](https://github.com/cake-contrib/Cake_Git/releases) on GitHub +* Close the [milestone](https://github.com/cake-contrib/Cake_Git/milestones) on GitHub +* Publish a notification of the release on the [Cake-Contrib](https://twitter.com/cakecontrib) Twitter account ([see example](https://twitter.com/cakecontrib/status/1603138374994468864)) diff --git a/appveyor.yml b/appveyor.yml index 16305fb..a3357b5 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,6 +1,17 @@ # Operating system (build VM template) os: Visual Studio 2022 +# Ensure required .NET SDKs are installed +install: + - ps: $env:DOTNET_INSTALL_DIR = "$pwd\.dotnetsdk" + - ps: mkdir $env:DOTNET_INSTALL_DIR -Force | Out-Null + - ps: Invoke-WebRequest -Uri "https://dotnet.microsoft.com/download/dotnet/scripts/v1/dotnet-install.ps1" -OutFile "$($env:DOTNET_INSTALL_DIR)/dotnet-install.ps1" + - ps: '& "$($env:DOTNET_INSTALL_DIR)/dotnet-install.ps1" -Version 6.0.418 -InstallDir $env:DOTNET_INSTALL_DIR' + - ps: '& "$($env:DOTNET_INSTALL_DIR)/dotnet-install.ps1" -Version 7.0.405 -InstallDir $env:DOTNET_INSTALL_DIR' + - ps: '& "$($env:DOTNET_INSTALL_DIR)/dotnet-install.ps1" -Version 8.0.101 -InstallDir $env:DOTNET_INSTALL_DIR' + - ps: $env:Path = "$env:DOTNET_INSTALL_DIR;$env:Path" + - ps: dotnet --info + # Build script build_script: - ps: .\build.ps1 --target AppVeyor diff --git a/build.cake b/build.cake index c10c9cf..6412615 100644 --- a/build.cake +++ b/build.cake @@ -44,14 +44,14 @@ Setup(ctx => var assemblyInfo = new AssemblyInfoSettings { Title = "Cake.Git", - Description = "Cake Git AddIn", + Description = "This addin provides aliases for running Git commands from Cake scripts. It is a thin wrapper around the LibGit2Sharp library and provides a way to interact with Git repositories from Cake scripts.", Product = "Cake.Git", Company = "WCOM AB", Version = version, FileVersion = version, InformationalVersion = semVersion, Copyright = string.Format("Copyright © WCOM AB {0}", DateTime.Now.Year), - CLSCompliant = true + CLSCompliant = false }; @@ -76,7 +76,7 @@ Setup(ctx => isLocalBuild, configuration, target, - new[]{ "net6.0", "net7.0" }, + new[]{ "net6.0", "net7.0", "net8.0" }, new DotNetMSBuildSettings() .WithProperty("Version", semVersion) .WithProperty("AssemblyVersion", version) @@ -112,6 +112,7 @@ Setup(ctx => artifactsRoot, nugetRoot, nugetRoot.CombineWithFilePath("Cake.Git." + semVersion + ".nupkg"), + nugetRoot.CombineWithFilePath("Cake.Frosting.Git." + semVersion + ".nupkg"), GetFiles("./**/*.sln") .ToArray(), MakeAbsolute(Directory("./tools/Addins/Cake.Git/Cake.Git")))); @@ -210,6 +211,10 @@ Task("Publish-Artifacts") Task("Create-NuGet-Package") + .IsDependentOn("Create-NuGet-Package-Scripting") + .IsDependentOn("Create-NuGet-Package-Frosting"); + +Task("Create-NuGet-Package-Scripting") .IsDependentOn("Publish-Artifacts") .Does(static (context, data) => { @@ -218,6 +223,11 @@ Task("Create-NuGet-Package") var libGit = context.GetFiles(data.BuildPaths.ArtifactsRoot.FullPath + "/**/LibGit2Sharp*"); var unmanaged = context.GetFiles(data.BuildPaths.ArtifactsRoot.FullPath + "/net6.0/runtimes/**/*"); + data.NuGetPackSettings.Description += Environment.NewLine + Environment.NewLine + + "NOTE:" + Environment.NewLine + + "The addin currently only runs on x64 processors. ARM processors are not supported." + Environment.NewLine + + "This is the version of the addin compatible with Cake Script Runners." + Environment.NewLine + + "For addin compatible with Cake Frosting see Cake.Frosting.Git."; data.NuGetPackSettings.Files = (libGit + cakeGit + cakeGitDoc) .Select(file=>file.FullPath.Substring(data.BuildPaths.ArtifactsRoot.FullPath.Length+1)) .Select(file=>new NuSpecContent {Source = file, Target = "lib/" + file}) @@ -227,7 +237,7 @@ Task("Create-NuGet-Package") .Select(file=>new NuSpecContent {Source = file, Target = "/" + file.Substring(7)})) // cake scripting needs the unmanaged dlls to be in the "wrong" place for some reason.. .Union(unmanaged - .Where(file=>file.FullPath.Contains("/linux-x64/") || file.FullPath.Contains("/win-x64/") || file.FullPath.Contains("/osx/")) + .Where(file=>file.FullPath.Contains("/linux-x64/") || file.FullPath.Contains("/win-x64/") || file.FullPath.Contains("/osx-x64/")) .SelectMany(file => data.TargetFrameworks.Select(tfm => new NuSpecContent { Source = file.FullPath.Substring(data.BuildPaths.ArtifactsRoot.FullPath.Length+1), @@ -249,8 +259,44 @@ Task("Create-NuGet-Package") context.NuGetPack(data.NuGetPackSettings); }); +Task("Create-NuGet-Package-Frosting") + .IsDependentOn("Publish-Artifacts") + .Does(static (context, data) => +{ + var cakeGit = context.GetFiles(data.BuildPaths.ArtifactsRoot.FullPath + "/**/Cake.Git.dll"); + var cakeGitDoc = context.GetFiles(data.BuildPaths.ArtifactsRoot.FullPath + "/**/Cake.Git.xml"); + + data.NuGetPackSettings.Id = "Cake.Frosting.Git"; + data.NuGetPackSettings.Description += Environment.NewLine + Environment.NewLine + + "NOTE:" + Environment.NewLine + + "This is the version of the addin compatible with Cake Frosting." + Environment.NewLine + + "For addin compatible with Cake Script Runners see Cake.Git." + Environment.NewLine; + data.NuGetPackSettings.Files = (cakeGit + cakeGitDoc) + .Select(file=>file.FullPath.Substring(data.BuildPaths.ArtifactsRoot.FullPath.Length+1)) + .Select(file=>new NuSpecContent {Source = file, Target = "lib/" + file}) + // add the icon + .Union(new [] + { + new NuSpecContent + { + Source = context.MakeAbsolute(context.File("./asset/cake-contrib-addin-medium.png")).FullPath, + Target = "images/icon.png", + }, + }) + .ToArray(); + data.NuGetPackSettings.Dependencies = new List + { + new NuSpecDependency { Id = "Cake.Core", Version = "4.0.0" }, + new NuSpecDependency { Id = "LibGit2Sharp", Version = "0.29.0" } + }; + + context.EnsureDirectoryExists(data.BuildPaths.NuGetRoot); + + context.NuGetPack(data.NuGetPackSettings); +}); + Task("Test") - .IsDependentOn("Create-NuGet-Package") + .IsDependentOn("Create-NuGet-Package-Scripting") .WithCriteria(data => StringComparer.OrdinalIgnoreCase.Equals(data.Configuration, "Release")) .DoesForEach( static (data, context) => { @@ -262,7 +308,7 @@ Task("Test") }); } - context.Unzip(data.BuildPaths.Package, data.BuildPaths.AddinDir); + context.Unzip(data.BuildPaths.ScriptingPackage, data.BuildPaths.AddinDir); var cakeSettings = new CakeSettings { Arguments = new Dictionary { @@ -292,7 +338,8 @@ Task("Upload-AppVeyor-Artifacts") .Does(data => { // Upload Artifact - AppVeyor.UploadArtifact(data.BuildPaths.Package); + AppVeyor.UploadArtifact(data.BuildPaths.ScriptingPackage); + AppVeyor.UploadArtifact(data.BuildPaths.FrostingPackage); }); Task("Push-NuGet-Packages") @@ -302,7 +349,15 @@ Task("Push-NuGet-Packages") .Does((context, data) => { context.DotNetNuGetPush( - data.BuildPaths.Package, + data.BuildPaths.ScriptingPackage, + new DotNetNuGetPushSettings + { + Source = data.NuGetSource, + ApiKey = data.NuGetApiKey + } + ); + context.DotNetNuGetPush( + data.BuildPaths.FrostingPackage, new DotNetNuGetPushSettings { Source = data.NuGetSource, @@ -321,7 +376,8 @@ Task("Upload-GitHubActions-Artifacts") var suffix = EnvironmentVariable("matrix-os") ?? GitHubActions.Environment.Runner.OS; Information("Uploading artifacts for {0}...", suffix); - await GitHubActions.Commands.UploadArtifact(data.BuildPaths.Package, string.Concat("NuGet-", suffix)); + await GitHubActions.Commands.UploadArtifact(data.BuildPaths.ScriptingPackage, string.Concat("Scripting-NuGet-", suffix)); + await GitHubActions.Commands.UploadArtifact(data.BuildPaths.FrostingPackage, string.Concat("Frosting-NuGet-", suffix)); await GitHubActions.Commands.UploadArtifact(data.BuildPaths.ArtifactsRoot, string.Concat("Artifacts-", suffix)); }); @@ -355,7 +411,8 @@ RunTarget(target); public record BuildPaths( DirectoryPath ArtifactsRoot, DirectoryPath NuGetRoot, - FilePath Package, + FilePath ScriptingPackage, + FilePath FrostingPackage, ICollection Solutions, DirectoryPath AddinDir) { diff --git a/global.json b/global.json index e00c63f..7eb9bc5 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "7.0.100", + "version": "8.0.100", "rollForward": "feature" } } \ No newline at end of file diff --git a/src/Cake.Git/Cake.Git.csproj b/src/Cake.Git/Cake.Git.csproj index 894c9e2..c167dd8 100644 --- a/src/Cake.Git/Cake.Git.csproj +++ b/src/Cake.Git/Cake.Git.csproj @@ -1,6 +1,6 @@ - net6.0;net7.0 + net6.0;net7.0;net8.0 false $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb @@ -18,10 +18,10 @@ {08F0A5C3-0E9C-451D-B003-14FF73699BE1} - - - - + + + + diff --git a/src/Cake.Git/GitAliases.Branch.cs b/src/Cake.Git/GitAliases.Branch.cs index 5df5d8a..d8948ba 100644 --- a/src/Cake.Git/GitAliases.Branch.cs +++ b/src/Cake.Git/GitAliases.Branch.cs @@ -8,9 +8,6 @@ namespace Cake.Git { - /// - /// Class GitAliases. - /// public static partial class GitAliases { /// diff --git a/src/Cake.Git/GitAliases.Clone.cs b/src/Cake.Git/GitAliases.Clone.cs index 07bfd6c..4e262d6 100644 --- a/src/Cake.Git/GitAliases.Clone.cs +++ b/src/Cake.Git/GitAliases.Clone.cs @@ -189,11 +189,9 @@ string password context.FileSystem.GetDirectory(workFullDirectoryPath).Create(); - var options = new CloneOptions - { - CredentialsProvider = - (url, user, cred) => new UsernamePasswordCredentials { Username = username, Password = password } - }; + var options = new CloneOptions(); + options.FetchOptions.CredentialsProvider = + (url, user, cred) => new UsernamePasswordCredentials { Username = username, Password = password }; return Repository.Clone(sourceUrl, workFullDirectoryPath.FullPath, options); } @@ -265,7 +263,7 @@ GitCloneSettings cloneSettings context.FileSystem.GetDirectory(workFullDirectoryPath).Create(); var options = cloneSettings.ToCloneOptions(); - options.CredentialsProvider = + options.FetchOptions.CredentialsProvider = (url, user, cred) => new UsernamePasswordCredentials { Username = username, Password = password }; return Repository.Clone(sourceUrl, workFullDirectoryPath.FullPath, options); diff --git a/src/Cake.Git/GitAliases.cs b/src/Cake.Git/GitAliases.cs index 87dfd69..ed50887 100644 --- a/src/Cake.Git/GitAliases.cs +++ b/src/Cake.Git/GitAliases.cs @@ -4,7 +4,10 @@ namespace Cake.Git { /// - /// Contains functionality for working with GIT using LibGit2 & LibGit2Sharp + /// Contains functionality for working with GIT using LibGit2 & LibGit2Sharp. + /// + /// NOTE: + /// The addin currently only runs on x64 processors. ARM processors are not supported. /// [CakeAliasCategory("Git")] public static partial class GitAliases diff --git a/src/SolutionInfo.cs b/src/SolutionInfo.cs index aa8a77c..308cd59 100644 --- a/src/SolutionInfo.cs +++ b/src/SolutionInfo.cs @@ -14,5 +14,5 @@ [assembly: AssemblyFileVersion("2.0.0")] [assembly: AssemblyInformationalVersion("2.0.0")] [assembly: AssemblyCopyright("Copyright © WCOM AB 2022")] -[assembly: CLSCompliant(true)] +[assembly: CLSCompliant(false)] diff --git a/test_net8.0.cake b/test_net8.0.cake new file mode 100644 index 0000000..9e0c017 --- /dev/null +++ b/test_net8.0.cake @@ -0,0 +1,2 @@ +#r "./tools/Addins/Cake.Git/Cake.Git/lib/net8.0/Cake.Git.dll" +#load test.cake \ No newline at end of file