Refactoring script to create master branch

This commit is contained in:
Pranav K 2015-10-16 09:55:36 -07:00
parent fb6bbee561
commit 0ea0a44e15
1 changed files with 45 additions and 46 deletions

View File

@ -192,43 +192,30 @@ var buildTarget = "compile"
#pull-all #pull-all
-Parallel.ForEach(GetAllRepos(), CloneOrUpdate); -Parallel.ForEach(GetAllRepos(), CloneOrUpdate);
#update-master #update-master .pull-all
-// Merge release branch to master -// Merge release branch to master
@{
foreach (var repo in GetAllRepos())
{
CloneOrUpdate(repo);
GitCommand(repo, "checkout origin/release -B master");
if(File.Exists(Path.Combine(repo, "NuGet.config")))
{
File.Copy(Path.Combine("build-template", "NuGet.master.config"),
Path.Combine(repo, "NuGet.config"),
overwrite: true);
GitCommand(repo, "commit -am \"Updating NuGet.config\"");
}
GitCommand(repo, "push origin master:master -f");
}
}
#pin-version
-// Pin versions of packages in project.json and updated project.lock.json -// Pin versions of packages in project.json and updated project.lock.json
-// More information https://github.com/aspnet/Universe/wiki/%23pin-version-:-Pinning-package-version-for-a-particular-release-in-project.json -// More information https://github.com/aspnet/Universe/wiki/%23pin-version-:-Pinning-package-version-for-a-particular-release-in-project.json
@{ @{
var coherenceFeed = Environment.GetEnvironmentVariable("COHERENCE_FEED");
if (string.IsNullOrEmpty(coherenceFeed)) var COHERENCE_FEED = Environment.GetEnvironmentVariable("COHERENCE_FEED");
if (string.IsNullOrEmpty(COHERENCE_FEED))
{ {
throw new Exception("COHERENCE_FEED not specified. Usually this is Packages-NoTimestamp directory of Coherence-Signed."); throw new Exception("COHERENCE_FEED not specified. Usually this is Packages-NoTimestamp directory of Coherence-Signed.");
} }
var korebuildVersion = Environment.GetEnvironmentVariable("KOREBUILD_VERSION"); var KOREBUILD_VERSION = Environment.GetEnvironmentVariable("KOREBUILD_VERSION");
if (string.IsNullOrEmpty(korebuildVersion)) if (string.IsNullOrEmpty(KOREBUILD_VERSION))
{ {
throw new Exception("KOREBUILD_VERSION environment variable is not specified."); throw new Exception("KOREBUILD_VERSION environment variable is not specified.");
} }
var NUGET_VERSION = Environment.GetEnvironmentVariable("NUGET_VERSION");
if (string.IsNullOrEmpty(NUGET_VERSION))
{
throw new Exception("NUGET_VERSION not specified. This is most recent stable build of NuGet from http://dist.nuget.org/index.html. e.g. v3.2");
}
var excludeReposForJson = new[] var excludeReposForJson = new[]
{ {
"Coherence", "Coherence",
@ -237,23 +224,35 @@ var buildTarget = "compile"
"Entropy" "Entropy"
}; };
var repos = GetAllRepos().Except(excludeReposForJson); Exec("cmd", "/C dnu restore", @"tools\PinVersion");
Parallel.ForEach(repos, CloneOrUpdate);
foreach (var repo in repos) foreach (var repo in GetAllRepos())
{ {
GitCommand(repo, "checkout master"); GitCommand(repo, "checkout origin/release -B master");
if (File.Exists(Path.Combine(repo, "build.cmd"))) if (File.Exists(Path.Combine(repo, "NuGet.config")))
{ {
File.Copy(Path.Combine("build-template", "build.cmd"), File.Copy(Path.Combine("build-template", "NuGet.master.config"),
Path.Combine(repo, "build.cmd"), Path.Combine(repo, "NuGet.config"),
overwrite: true); overwrite: true);
GitCommand(repo, "add NuGet.*");
GitCommand(repo, "commit -m \"Updating NuGet.config\"");
} }
}
var reposToPin = GetAllRepos().Except(excludeReposForJson);
foreach (var repo in reposToPin)
{
var repoPath = Path.Combine(Directory.GetCurrentDirectory(), repo); var repoPath = Path.Combine(Directory.GetCurrentDirectory(), repo);
Exec("dnx", string.Format(@".\tools\PinVersion run ""{0}"" ""{1}"" ""{2}""", repo, coherenceFeed, korebuildVersion), string.Empty); Exec("dnx",
string.Format(@"run ""{0}"" ""{1}"" ""{2}"" ""{3}""",
Path.Combine(Directory.GetCurrentDirectory(), repo),
COHERENCE_FEED,
KOREBUILD_VERSION,
NUGET_VERSION),
@"tools\PinVersion");
// Build projects to produce project.lock.json // Build projects to produce project.lock.json
Exec("build.cmd", "compile", repo); Exec("build.cmd", "compile", repo);
@ -267,7 +266,7 @@ var buildTarget = "compile"
} }
// Add the project.json and project.lock.json files // Add the project.json and project.lock.json files
foreach(var file in Directory.GetFiles(repo, "project*", SearchOption.AllDirectories)) foreach(var file in Directory.GetFiles(repo, "project*.json", SearchOption.AllDirectories))
{ {
var gitFilePath = file.Substring(file.IndexOf(repo) + repo.Length + 1); var gitFilePath = file.Substring(file.IndexOf(repo) + repo.Length + 1);
@ -279,29 +278,29 @@ var buildTarget = "compile"
} }
GitCommand(repo, "commit -am \"Updating json files to pin versions and build.cmd to pin KoreBuild and DNX\""); GitCommand(repo, "commit -am \"Updating json files to pin versions and build.cmd to pin KoreBuild and DNX\"");
GitCommand(repo, "push origin master:master -f");
} }
foreach (var repo in GetAllRepos())
{
GitCommand(repo, "push origin +master:master");
}
CallTarget("update-prerelease-tags");
} }
#update-prerelease-tags #update-prerelease-tags
-// Update tags on each repo to have the latest release tag -// Update tags on each repo to have the latest release tag
@{ @{
var newPreRelease = Environment.GetEnvironmentVariable("PRERELEASETAG"); var PRERELEASETAG = Environment.GetEnvironmentVariable("PRERELEASETAG");
if(string.IsNullOrEmpty(newPreRelease)) if (string.IsNullOrEmpty(PRERELEASETAG))
{ {
Log.Warn("No prerelease tag defined"); throw new Exception("PRERELEASETAG tag not defined");
return;
} }
var versionFile = "version.txt"; var versionFile = "version.txt";
foreach (var repo in GetAllRepos()) foreach (var repo in GetAllRepos())
{ {
CloneOrUpdate(repo);
GitCommand(repo, "checkout master");
GitCommand(repo, "pull --tags"); GitCommand(repo, "pull --tags");
try try
@ -321,13 +320,13 @@ var buildTarget = "compile"
var majorVersion = version.Split(new string[]{"-"}, StringSplitOptions.None)[0]; var majorVersion = version.Split(new string[]{"-"}, StringSplitOptions.None)[0];
var newVersion = majorVersion + string.Format("-{0}", newPreRelease); var newVersion = majorVersion + string.Format("-{0}", PRERELEASETAG);
Log.Info(string.Format("New version for repo is {0}", newVersion)); Log.Info(string.Format("New version for repo is {0}", newVersion));
GitCommand(repo, string.Format("tag -f -a {0} -m \"Tag for new release {0}\"", newVersion)); GitCommand(repo, string.Format("tag -f -a {0} -m \"Tag for new release {0}\"", newVersion));
GitCommand(repo, "push -f --tags "); GitCommand(repo, "push origin --tags +" + newVersion);
} }
} }