Skip to content

Commit

Permalink
Merge pull request #1083 from nunit/issue-1080
Browse files Browse the repository at this point in the history
Add --nopush option to build
  • Loading branch information
CharliePoole authored Jan 5, 2022
2 parents 9a4a55e + c0cf0f9 commit 028ebd3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
17 changes: 13 additions & 4 deletions build.cake
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
static string Target; Target = Argument("target", "Default");
static string Configuration; Configuration = Argument("configuration", "Release");
static bool NoPush; NoPush = HasArgument("nopush");

#load cake/constants.cake
#load cake/header-check.cake
Expand Down Expand Up @@ -580,8 +581,6 @@ Task("CreateDraftRelease")
{
if (IsReleaseBranch)
{
// NOTE: Since this is a release branch, the pre-release label
// is "pre", which we don't want to use for the draft release.
// The branch name contains the full information to be used
// for both the name of the draft release and the milestone,
// i.e. release-2.0.0, release-2.0.0-beta2, etc.
Expand All @@ -590,6 +589,7 @@ Task("CreateDraftRelease")
Information($"Creating draft release for {releaseName}");
if (!NoPush)
try
{
GitReleaseManagerCreate(EnvironmentVariable(GITHUB_ACCESS_TOKEN), GITHUB_OWNER, GITHUB_REPO, new GitReleaseManagerCreateSettings()
Expand Down Expand Up @@ -631,8 +631,17 @@ Task("CreateProductionRelease")
Information($"Publishing release {tagName} to GitHub");
GitReleaseManagerAddAssets(token, GITHUB_OWNER, GITHUB_REPO, tagName, assets);
GitReleaseManagerClose(token, GITHUB_OWNER, GITHUB_REPO, tagName);
if (NoPush)
{
Information($"Assets:");
foreach (var asset in assetList)
Information(" " + asset);
}
else
{
GitReleaseManagerAddAssets(token, GITHUB_OWNER, GITHUB_REPO, tagName, assets);
GitReleaseManagerClose(token, GITHUB_OWNER, GITHUB_REPO, tagName);
}
}
else
{
Expand Down
10 changes: 8 additions & 2 deletions cake/utilities.cake
Original file line number Diff line number Diff line change
Expand Up @@ -237,13 +237,19 @@ public void CopyPackageContents(DirectoryPath packageDir, DirectoryPath outDir)
public void PushNuGetPackage(FilePath package, string apiKey, string url)
{
CheckPackageExists(package);
NuGetPush(package, new NuGetPushSettings() { ApiKey = apiKey, Source = url });
if (NoPush)
Information($"Push {package} to {url}");
else
NuGetPush(package, new NuGetPushSettings() { ApiKey = apiKey, Source = url });
}

public void PushChocolateyPackage(FilePath package, string apiKey, string url)
{
CheckPackageExists(package);
ChocolateyPush(package, new ChocolateyPushSettings() { ApiKey = apiKey, Source = url });
if (NoPush)
Information($"Push {package} to {url}");
else
ChocolateyPush(package, new ChocolateyPushSettings() { ApiKey = apiKey, Source = url });
}

private void CheckPackageExists(FilePath package)
Expand Down

0 comments on commit 028ebd3

Please sign in to comment.