Skip to content

Commit

Permalink
Publish packages
Browse files Browse the repository at this point in the history
  • Loading branch information
CharliePoole committed Sep 13, 2021
1 parent 8adcc1f commit c7b63b4
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 1 deletion.
8 changes: 8 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,11 @@ test: off

artifacts:
- path: output\*.nupkg

environment:
MYGET_API_KEY:
secure: wtAvJDVl2tfwiVcyLExFHLvZVfUWiQRHsfdHBFCNEATeCHo1Nd8JP642PfY8xhji
NUGET_API_KEY:
secure: 3ojZLs9hiHk/7047hiirFk/qG2RxUACmA8DAUk+8AoILr5R7c4tDGXeTsBjjhq5h
CHOCO_API_KEY:
secure: aDsu1U+umVYFVybjkBVtVQsatSj3QKbD7VkGQci9mNF3493g9Giao/GABISIaHjT
78 changes: 77 additions & 1 deletion build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,81 @@ Task("TestChocolateyPackage")
new ChocolateyPackageTester(parameters).RunPackageTests();
});

//////////////////////////////////////////////////////////////////////
// PUBLISH
//////////////////////////////////////////////////////////////////////

static bool hadPublishingErrors = false;

Task("PublishPackages")
.Description("Publish nuget and chocolatey packages according to the current settings")
.IsDependentOn("PublishToMyGet")
.IsDependentOn("PublishToNuGet")
.IsDependentOn("PublishToChocolatey")
.Does(() =>
{
if (hadPublishingErrors)
throw new Exception("One of the publishing steps failed.");
});

// This task may either be run by the PublishPackages task,
// which depends on it, or directly when recovering from errors.
Task("PublishToMyGet")
.Description("Publish packages to MyGet")
.Does<BuildParameters>((parameters) =>
{
if (!parameters.ShouldPublishToMyGet)
Information("Nothing to publish to MyGet from this run.");
else
try
{
PushNuGetPackage(parameters.NuGetPackage, parameters.MyGetApiKey, parameters.MyGetPushUrl);
PushChocolateyPackage(parameters.ChocolateyPackage, parameters.MyGetApiKey, parameters.MyGetPushUrl);
}
catch (Exception)
{
hadPublishingErrors = true;
}
});

// This task may either be run by the PublishPackages task,
// which depends on it, or directly when recovering from errors.
Task("PublishToNuGet")
.Description("Publish packages to NuGet")
.Does<BuildParameters>((parameters) =>
{
if (!parameters.ShouldPublishToNuGet)
Information("Nothing to publish to NuGet from this run.");
else
try
{
PushNuGetPackage(parameters.NuGetPackage, parameters.NuGetApiKey, parameters.NuGetPushUrl);
}
catch (Exception)
{
hadPublishingErrors = true;
}
});

// This task may either be run by the PublishPackages task,
// which depends on it, or directly when recovering from errors.
Task("PublishToChocolatey")
.Description("Publish packages to Chocolatey")
.Does<BuildParameters>((parameters) =>
{
if (!parameters.ShouldPublishToChocolatey)
Information("Nothing to publish to Chocolatey from this run.");
else
try
{
PushChocolateyPackage(parameters.ChocolateyPackage, parameters.ChocolateyApiKey, parameters.ChocolateyPushUrl);
}
catch (Exception)
{
hadPublishingErrors = true;
}
});

//////////////////////////////////////////////////////////////////////
// TASK TARGETS
//////////////////////////////////////////////////////////////////////
Expand All @@ -222,7 +297,8 @@ Task("PackageChocolatey")
Task("Appveyor")
.IsDependentOn("Build")
.IsDependentOn("Test")
.IsDependentOn("Package");
.IsDependentOn("Package")
.IsDependentOn("PublishPackages");

Task("Travis")
.IsDependentOn("Build")
Expand Down

0 comments on commit c7b63b4

Please sign in to comment.