Skip to content

Commit

Permalink
Merge branch 'hotfix/2.0.1' into master
Browse files Browse the repository at this point in the history
* hotfix/2.0.1:
  (build) Updating GRM config
  (GH-705) Update notification messages
  (GH-701) Update wording in nuspec file
  (GH-708) Add ability to detect branches when running on detached tags
  (GH-706) Only add ApiKey when on Azure Artifacts
  • Loading branch information
gep13 committed Oct 9, 2020
2 parents 87e2506 + fcd7b4d commit 1c6f09c
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Cake.Recipe/Cake.Recipe.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ This NuGet package contains a set of re-usable scripts that can be added to your

https://cake-contrib.github.io/Cake.Recipe/docs/

NOTE: Currently, Cake.Recipe itself is built using 0.32.1, and as a result, there is an expectation that that any project that is built using Cake.Recipe should also use 0.32.1 of Cake. Currently, attempting to build your project using 0.33.0 will result in errors which come from Cake.Recipe.
NOTE: Currently, Cake.Recipe itself is built using 0.38.4, and as a result, there is an expectation that that any project that is built using Cake.Recipe should also use 0.38.4 of Cake. Using a newer version of Cake may work, but there is no guarantee that it will.
</description>
<license type="expression">MIT</license>
<projectUrl>https://github.com/cake-contrib/Cake.Recipe/</projectUrl>
Expand Down
10 changes: 7 additions & 3 deletions Cake.Recipe/Content/packages.cake
Original file line number Diff line number Diff line change
Expand Up @@ -281,9 +281,13 @@ public void PushNuGetPackages(ICakeContext context, bool isRelease, List<Package
Password = nugetSource.Credentials.Password
};

// This is required so that the X-NuGet-ApiKey is set, which is required when
// pushing to some sources, for example Azure Artifacts.
nugetPushSettings.ApiKey = "RandomToken";
if (nugetSource.Name == "AZURE")
{
// This is required so that the X-NuGet-ApiKey is set. Currently,
// it is only known that this is required when pushing to Azure
// Artifacts, as such, a more general solution hasn't been provided.
nugetPushSettings.ApiKey = "RandomToken";
}

context.Information("Adding NuGet source with user/pass...");
context.NuGetAddSource(isRelease ? string.Format("ReleaseSource_{0}", nugetSource.Name) : string.Format("PreReleaseSource_{0}", nugetSource.Name), nugetSource.PushUrl, nugetSourceSettings);
Expand Down
53 changes: 49 additions & 4 deletions Cake.Recipe/Content/parameters.cake
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,11 @@ public static class BuildParameters
IsMainRepository = StringComparer.OrdinalIgnoreCase.Equals(string.Concat(repositoryOwner, "/", RepositoryName), BuildProvider.Repository.Name);
IsPublicRepository = isPublicRepository;

IsTagged = (
BuildProvider.Repository.Tag.IsTag &&
!string.IsNullOrWhiteSpace(BuildProvider.Repository.Tag.Name)
);

var branchName = BuildProvider.Repository.Branch ?? string.Empty; // This is just to prevent any null reference exceptions
if (StringComparer.OrdinalIgnoreCase.Equals(masterBranchName, branchName))
{
Expand All @@ -546,15 +551,55 @@ public static class BuildParameters
{
BranchType = BranchType.HotFix;
}
else if (IsTagged)
{
BranchType = BranchType.Unknown;
var gitTool = context.Tools.Resolve("git");

if (gitTool != null)
{
IEnumerable<string> redirectedStandardOutput;
IEnumerable<string> redirectedError;

var exitCode = context.StartProcess(
gitTool,
new ProcessSettings {
Arguments = "branch --contains HEAD",
RedirectStandardOutput = true,
RedirectStandardError = true,
},
out redirectedStandardOutput,
out redirectedError
);

if (exitCode == 0)
{
var lines = redirectedStandardOutput.Select(c => c.TrimStart(new []{ ' ', '*' })).ToList();

if (lines.Contains(masterBranchName))
{
BranchType = BranchType.Master;
}
else if (lines.Contains(developBranchName))
{
BranchType = BranchType.Develop;
}
else if (lines.Any(l => l.StartsWith("release", StringComparison.OrdinalIgnoreCase)))
{
BranchType = BranchType.Release;
}
else if (lines.Any(l => l.StartsWith("hotfix", StringComparison.OrdinalIgnoreCase)))
{
BranchType = BranchType.HotFix;
}
}
}
}
else
{
BranchType = BranchType.Unknown;
}

IsTagged = (
BuildProvider.Repository.Tag.IsTag &&
!string.IsNullOrWhiteSpace(BuildProvider.Repository.Tag.Name)
);
TreatWarningsAsErrors = treatWarningsAsErrors;

GitHub = GetGitHubCredentials(context);
Expand Down
17 changes: 16 additions & 1 deletion GitReleaseManager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,19 @@ issue-labels-exclude:
issue-labels-alias:
- name: Documentation
header: Documentation
plural: Documentation
plural: Documentation
create:
include-sha-section: true
sha-section-heading: "SHA256 Hashes of the release artifacts"
sha-section-line-format: "- `{1}\t{0}`"
close:
use-issue-comments: true
issue-comment: |-
:tada: This issue has been resolved in version {milestone} :tada:
The release is available on:
- [GitHub Release](https://github.com/{owner}/{repository}/releases/tag/{milestone})
- [NuGet Package](https://www.nuget.org/packages/{repository}/{milestone})
Your **[GitReleaseManager](https://github.com/GitTools/GitReleaseManager)** bot :package::rocket:
6 changes: 5 additions & 1 deletion recipe.cake
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,17 @@ public class BuildMetaData

Environment.SetVariableNames();

var standardNotificationMessage = "Version {0} of {1} has just been released, this will be available here https://www.nuget.org/packages/{1}, once package indexing is complete.";

BuildParameters.SetParameters(context: Context,
buildSystem: BuildSystem,
sourceDirectoryPath: "./src",
title: "Cake.Recipe",
repositoryOwner: "cake-contrib",
repositoryName: "Cake.Recipe",
appVeyorAccountName: "cakecontrib");
appVeyorAccountName: "cakecontrib",
gitterMessage: "@/all " + standardNotificationMessage,
twitterMessage: standardNotificationMessage);

BuildParameters.PrintParameters(Context);

Expand Down

0 comments on commit 1c6f09c

Please sign in to comment.