Skip to content

Commit

Permalink
Begun adding Nuget push
Browse files Browse the repository at this point in the history
  • Loading branch information
franhoey committed Jan 8, 2024
1 parent 26bf3c5 commit 88787c0
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 12 deletions.
60 changes: 52 additions & 8 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,35 @@
///////////////////////////////////////////////////////////////////////////////

var target = Argument("target", "Default");
var configuration = Argument("configuration", "Release");
var packageversion = Argument("packageversion", "0.1");

///////////////////////////////////////////////////////////////////////////////
// TASKS
// Variables and Constants
///////////////////////////////////////////////////////////////////////////////

const string BuildArtifacts = "./BuildArtifacts";

///////////////////////////////////////////////////////////////////////////////
// TASKS
///////////////////////////////////////////////////////////////////////////////

//Todo: Add test for DisableTokenReplacement

Task("Build")
.Does(() =>
{
DotNetClean("./src/Cake.grate/Cake.grate.csproj");
DotNetClean("./src/Cake.grate/Cake.grate.csproj");

var settings = new DotNetBuildSettings
{
Configuration = configuration
};
var settings = new DotNetBuildSettings
{
Configuration = "Release",
MSBuildSettings = new DotNetMSBuildSettings
{
Version = packageversion
}
};

DotNetBuild("./src/Cake.grate/Cake.grate.csproj", settings);
DotNetBuild("./src/Cake.grate/Cake.grate.csproj", settings);
});

Task("Test")
Expand All @@ -31,10 +40,45 @@ Task("Test")
DotNetTest("./src/Cake.grate.Tests/Cake.grate.Tests.csproj");
});

Task("Pack")
.Does(() =>
{
CleanDirectory(BuildArtifacts);

var settings = new DotNetPackSettings
{
Configuration = "Release",
OutputDirectory = BuildArtifacts,
NoBuild = true, //already built
MSBuildSettings = new DotNetMSBuildSettings
{
Version = packageversion
}
};
DotNetPack("./src/Cake.grate/Cake.grate.csproj", settings);
});

Task("Push")
.Does(() =>
{
var settings = new DotNetNuGetPushSettings
{
Source = "https://api.nuget.org/v3/index.json",
ApiKey = EnvironmentVariable<string>("NugetKey", "")
};
var packageFilePath = GetFiles($"{BuildArtifacts}/Cake.grate*.nupkg").Single();
DotNetNuGetPush(packageFilePath, settings);
});

Task("Build-And-Test")
.IsDependentOn("Build")
.IsDependentOn("Test");

Task("Deploy")
.IsDependentOn("Build-And-Test")
.IsDependentOn("Pack");
// .IsDependentOn("Push");


Task("Default")
.Does(() =>
Expand Down
7 changes: 3 additions & 4 deletions src/Cake.grate/Cake.grate.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,15 @@
<FullYear Condition="'$(StartYear)'!='$(EndYear)'">$(StartYear)-$(EndYear)</FullYear>

<!-- Properties related to packaging -->
<!-- TODO: Complete project properties -->
<Authors>Fran Hoey</Authors>
<Copyright>Copyright © $(FullYear) — Fran Hoey</Copyright>
<Description>Makes grate available as a tool in Cake.</Description>
<PackageIconUrl>https://cdn.jsdelivr.net/gh/cake-contrib/graphics/png/cake-contrib-medium.png</PackageIconUrl>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<!--<PackageProjectUrl>https://github.com/cake-contrib/Cake.ESLint</PackageProjectUrl>-->
<PackageProjectUrl>https://github.com/cake-contrib/Cake.grate</PackageProjectUrl>
<PackageTags>cake;addin;grate;build;cake-build;script;cake-addin</PackageTags>
<!--<RepositoryUrl>https://github.com/cake-contrib/Cake.ESLint.git</RepositoryUrl>
<PackageReleaseNotes>https://github.com/cake-contrib/Cake.ESLint/releases/tag/$(Version)</PackageReleaseNotes>-->
<RepositoryUrl>https://github.com/cake-contrib/Cake.grate</RepositoryUrl>
<PackageReleaseNotes>https://github.com/cake-contrib/Cake.grate/releases/tag/$(Version)</PackageReleaseNotes>
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>

Expand Down

0 comments on commit 88787c0

Please sign in to comment.