From 1a06bcc7fdd6a30bfbbca101fa1cdb817f4241a6 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Wed, 6 Sep 2023 12:42:47 +0200 Subject: [PATCH] ci: don't push on pull request --- build.cake | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/build.cake b/build.cake index 1c15fa8..2417dbf 100644 --- a/build.cake +++ b/build.cake @@ -15,7 +15,7 @@ Task("Prepare").Does(() => { if (branch != "release") { var buildNum = EnvironmentVariable("CI_PIPELINE_NUMBER"); - if (buildNum != null) + if (!string.IsNullOrEmpty(buildNum)) version += "-ci." + buildNum; } @@ -49,21 +49,24 @@ Task("Pack").IsDependentOn("Test").Does(() => { DotNetPack("MLEM.FNA.sln", settings); }); -Task("Push").WithCriteria(branch == "main" || branch == "release").IsDependentOn("Pack").Does(() => { - DotNetNuGetPushSettings settings; - if (branch == "release") { - settings = new DotNetNuGetPushSettings { - Source = "https://api.nuget.org/v3/index.json", - ApiKey = EnvironmentVariable("NUGET_KEY") - }; - } else { - settings = new DotNetNuGetPushSettings { - Source = "https://nuget.ellpeck.de/v3/index.json", - ApiKey = EnvironmentVariable("BAGET_KEY") - }; - } - settings.SkipDuplicate = true; - DotNetNuGetPush("**/MLEM*.nupkg", settings); +Task("Push") + .WithCriteria(branch == "main" || branch == "release", "Not on main or release branch") + .WithCriteria(string.IsNullOrEmpty(EnvironmentVariable("CI_COMMIT_PULL_REQUEST")), "On pull request") + .IsDependentOn("Pack").Does(() => { + DotNetNuGetPushSettings settings; + if (branch == "release") { + settings = new DotNetNuGetPushSettings { + Source = "https://api.nuget.org/v3/index.json", + ApiKey = EnvironmentVariable("NUGET_KEY") + }; + } else { + settings = new DotNetNuGetPushSettings { + Source = "https://nuget.ellpeck.de/v3/index.json", + ApiKey = EnvironmentVariable("BAGET_KEY") + }; + } + settings.SkipDuplicate = true; + DotNetNuGetPush("**/MLEM*.nupkg", settings); }); Task("Document").Does(() => {