Merge pull request #99 from binarymash/feature/macBuild

Fixes to get build running again on macOS.
This commit is contained in:
Tom Pallister 2017-06-10 15:07:43 +01:00 committed by GitHub
commit 47e56039de

View File

@ -92,7 +92,7 @@ Task("Version")
if (AppVeyor.IsRunningOnAppVeyor) if (AppVeyor.IsRunningOnAppVeyor)
{ {
Information("Persisting version number..."); Information("Persisting version number...");
PersistVersion(nugetVersion); PersistVersion(committedVersion, nugetVersion);
buildVersion = nugetVersion; buildVersion = nugetVersion;
} }
else else
@ -229,7 +229,7 @@ Task("CreatePackages")
EnsureDirectoryExists(packagesDir); EnsureDirectoryExists(packagesDir);
CopyFiles("./src/**/Ocelot.*.nupkg", packagesDir); CopyFiles("./src/**/Ocelot.*.nupkg", packagesDir);
GenerateReleaseNotes(); GenerateReleaseNotes(releaseNotesFile);
System.IO.File.WriteAllLines(artifactsFile, new[]{ System.IO.File.WriteAllLines(artifactsFile, new[]{
"nuget:Ocelot." + buildVersion + ".nupkg", "nuget:Ocelot." + buildVersion + ".nupkg",
@ -251,9 +251,9 @@ Task("ReleasePackagesToUnstableFeed")
.IsDependentOn("CreatePackages") .IsDependentOn("CreatePackages")
.Does(() => .Does(() =>
{ {
if (ShouldPublishToUnstableFeed()) if (ShouldPublishToUnstableFeed(nugetFeedUnstableBranchFilter, versioning.BranchName))
{ {
PublishPackages(nugetFeedUnstableKey, nugetFeedUnstableUploadUrl, nugetFeedUnstableSymbolsUploadUrl); PublishPackages(packagesDir, artifactsFile, nugetFeedUnstableKey, nugetFeedUnstableUploadUrl, nugetFeedUnstableSymbolsUploadUrl);
} }
}); });
@ -306,7 +306,7 @@ Task("ReleasePackagesToStableFeed")
.IsDependentOn("DownloadGitHubReleaseArtifacts") .IsDependentOn("DownloadGitHubReleaseArtifacts")
.Does(() => .Does(() =>
{ {
PublishPackages(nugetFeedStableKey, nugetFeedStableUploadUrl, nugetFeedStableSymbolsUploadUrl); PublishPackages(packagesDir, artifactsFile, nugetFeedStableKey, nugetFeedStableUploadUrl, nugetFeedStableSymbolsUploadUrl);
}); });
Task("Release") Task("Release")
@ -326,9 +326,9 @@ private GitVersion GetNuGetVersionForCommit()
} }
/// Updates project version in all of our projects /// Updates project version in all of our projects
private void PersistVersion(string version) private void PersistVersion(string committedVersion, string newVersion)
{ {
Information(string.Format("We'll search all csproj files for {0} and replace with {1}...", committedVersion, version)); Information(string.Format("We'll search all csproj files for {0} and replace with {1}...", committedVersion, newVersion));
var projectFiles = GetFiles("./**/*.csproj"); var projectFiles = GetFiles("./**/*.csproj");
@ -339,24 +339,30 @@ private void PersistVersion(string version)
Information(string.Format("Updating {0}...", file)); Information(string.Format("Updating {0}...", file));
var updatedProjectFile = System.IO.File.ReadAllText(file) var updatedProjectFile = System.IO.File.ReadAllText(file)
.Replace(committedVersion, version); .Replace(committedVersion, newVersion);
System.IO.File.WriteAllText(file, updatedProjectFile); System.IO.File.WriteAllText(file, updatedProjectFile);
} }
} }
/// generates release notes based on issues closed in GitHub since the last release /// generates release notes based on issues closed in GitHub since the last release
private void GenerateReleaseNotes() private void GenerateReleaseNotes(ConvertableFilePath file)
{ {
Information("Generating release notes at " + releaseNotesFile); if(!IsRunningOnWindows())
{
Warning("We are not running on Windows so we cannot generate release notes.");
return;
}
Information("Generating release notes at " + file);
var releaseNotesExitCode = StartProcess( var releaseNotesExitCode = StartProcess(
@"tools/GitReleaseNotes/tools/gitreleasenotes.exe", @"tools/GitReleaseNotes/tools/gitreleasenotes.exe",
new ProcessSettings { Arguments = ". /o " + releaseNotesFile }); new ProcessSettings { Arguments = ". /o " + file });
if (string.IsNullOrEmpty(System.IO.File.ReadAllText(releaseNotesFile))) if (string.IsNullOrEmpty(System.IO.File.ReadAllText(file)))
{ {
System.IO.File.WriteAllText(releaseNotesFile, "No issues closed since last release"); System.IO.File.WriteAllText(file, "No issues closed since last release");
} }
if (releaseNotesExitCode != 0) if (releaseNotesExitCode != 0)
@ -366,7 +372,7 @@ private void GenerateReleaseNotes()
} }
/// Publishes code and symbols packages to nuget feed, based on contents of artifacts file /// Publishes code and symbols packages to nuget feed, based on contents of artifacts file
private void PublishPackages(string feedApiKey, string codeFeedUrl, string symbolFeedUrl) private void PublishPackages(ConvertableDirectoryPath packagesDir, ConvertableFilePath artifactsFile, string feedApiKey, string codeFeedUrl, string symbolFeedUrl)
{ {
var artifacts = System.IO.File var artifacts = System.IO.File
.ReadAllLines(artifactsFile) .ReadAllLines(artifactsFile)
@ -375,6 +381,8 @@ private void PublishPackages(string feedApiKey, string codeFeedUrl, string symbo
var codePackage = packagesDir + File(artifacts["nuget"]); var codePackage = packagesDir + File(artifacts["nuget"]);
Information("Pushing package " + codePackage);
NuGetPush( NuGetPush(
codePackage, codePackage,
new NuGetPushSettings { new NuGetPushSettings {
@ -401,17 +409,17 @@ private string GetResource(string url)
} }
} }
private bool ShouldPublishToUnstableFeed() private bool ShouldPublishToUnstableFeed(string filter, string branchName)
{ {
var regex = new System.Text.RegularExpressions.Regex(nugetFeedUnstableBranchFilter); var regex = new System.Text.RegularExpressions.Regex(filter);
var publish = regex.IsMatch(versioning.BranchName); var publish = regex.IsMatch(branchName);
if (publish) if (publish)
{ {
Information("Branch " + versioning.BranchName + " will be published to the unstable feed"); Information("Branch " + branchName + " will be published to the unstable feed");
} }
else else
{ {
Information("Branch " + versioning.BranchName + " will not be published to the unstable feed"); Information("Branch " + branchName + " will not be published to the unstable feed");
} }
return publish; return publish;
} }