#update-release -// Merge dev branch to release @{ Parallel.ForEach(GetAllRepos(), CloneOrUpdate); Log.Info("************************************* Checking repos for diffs *************************"); foreach (var repo in GetAllRepos()) { Log.Info("Checking repo: " + repo); // Check if the repo previously had a release branch try { GitCommand(repo, "rev-parse --verify --quiet origin/release"); } catch { Log.Info("Repository " + repo + " does not have a release branch."); continue; } try { GitCommand(repo, "log -1 --exit-code origin/dev..origin/release"); } catch { Log.Warn("Unmerged changes in repository " + repo); GitCommand(repo, "log origin/dev..origin/release"); throw; } } Log.Info("No conflicts in repos, continuing with creating release branch."); foreach (var repo in GetAllRepos()) { GitCommand(repo, "checkout origin/dev -B release"); var filesChanged = false; // Update NuGet.Config var nugetConfigPath = Path.Combine(repo, "NuGet.config"); if (File.Exists(nugetConfigPath)) { var original = File.ReadAllText(nugetConfigPath); var modified = original .Replace("https://dotnet.myget.org/F/aspnetcore-ci-dev", "https://dotnet.myget.org/F/aspnetcore-ci-release"); if (!string.Equals(original, modified, StringComparison.Ordinal)) { File.WriteAllText(nugetConfigPath, modified); GitCommand(repo, "add NuGet.config"); filesChanged = true; } } var buildPs1Path = Path.Combine(repo, "build.ps1"); if (File.Exists(buildPs1Path)) { var original = File.ReadAllText(buildPs1Path); var modified = original .Replace("https://github.com/aspnet/KoreBuild/archive/dev.zip", "https://github.com/aspnet/KoreBuild/archive/release.zip"); if (!string.Equals(original, modified, StringComparison.Ordinal)) { File.WriteAllText(buildPs1Path, modified); GitCommand(repo, "add build.ps1"); filesChanged = true; } } var buildShPath = Path.Combine(repo, "build.sh"); if (File.Exists(buildShPath)) { var original = File.ReadAllText(buildShPath); var modified = original .Replace("https://github.com/aspnet/KoreBuild/archive/dev.zip", "https://github.com/aspnet/KoreBuild/archive/release.zip"); if (!string.Equals(original, modified, StringComparison.Ordinal)) { File.WriteAllText(buildShPath, modified); GitCommand(repo, "add build.sh"); filesChanged = true; } } if (filesChanged) { GitCommand(repo, "commit -m \"Updating to release.\""); } GitCommand(repo, "push origin release:release"); GitCommand(repo, "checkout origin/dev -B dev"); GitCommand(repo, "merge release -s ours"); GitCommand(repo, "push origin dev:dev"); } } #update-master .pull-all -// Merge release branch to master -// 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 @{ var koreBuildTag = GetEnvironmentParameter("KOREBUILD_TAG"); var coherenceFeed = GetEnvironmentParameter("COHERENCE_FEED"); if (string.IsNullOrEmpty(coherenceFeed)) { throw new Exception("COHERENCE_FEED not specified. Usually this is Packages-NoTimestamp directory of Coherence-Signed."); } if (string.IsNullOrEmpty(koreBuildTag)) { throw new Exception("KOREBUILD_TAG environment variable is not specified."); } var excludeReposForJson = new[] { "Coherence", "Coherence-Signed", "dnvm", "Entropy", "Setup", "libuv-build", }; Exec("dotnet", "restore", "tools/PinVersion"); foreach (var repo in GetAllRepos()) { 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, "add NuGet.*"); GitCommand(repo, "commit -m \"Updating NuGet.config\""); } } var reposToPin = GetAllRepos().Except(excludeReposForJson); var repositoryNamesFile = Path.GetTempFileName(); File.WriteAllLines(repositoryNamesFile, reposToPin.Select(r => Path.Combine(Directory.GetCurrentDirectory(), r))); var pinToolsArgs = string.Format(@"run -p tools/PinVersion ""{0}"" ""{1}"" ""{2}""", coherenceFeed, koreBuildTag, repositoryNamesFile); Exec("dotnet", pinToolsArgs, ""); try { File.Delete(repositoryNamesFile); } catch { } foreach (var repo in reposToPin) { var repoPath = Path.Combine(Directory.GetCurrentDirectory(), repo); try { GitCommand(repo, "commit -am \"Updating json files to pin versions and build files to pin KoreBuild\""); } catch { // Don't fail if there was nothing to add. } } foreach (var repo in GetAllRepos()) { GitCommand(repo, "push origin +master:master"); } CallTarget("update-prerelease-tags"); } #update-prerelease-tags -// Update tags on each repo to have the latest release tag @{ var preReleaseTag = GetEnvironmentParameter("PRERELEASETAG"); if (string.IsNullOrEmpty(preReleaseTag)) { throw new Exception("PRERELEASETAG tag not defined"); } var versionFile = "version.txt"; foreach (var repo in GetAllRepos()) { GitCommand(repo, "pull --tags"); string version = null; try { GitCommand(repo, string.Format("describe --tags > ..\\{0}", versionFile)); } catch { version = "1.0.0-" + preReleaseTag; Log.Warn(string.Format("{0} repo not tagged. Using default version {1}.", repo, version)); } if (version == null) { version = File.ReadAllText(versionFile); File.Delete(versionFile); } Log.Info(string.Format("Current version on repo {0} is {1}", repo, version)); var majorVersion = version.Split(new string[]{"-"}, StringSplitOptions.None)[0]; var newVersion = majorVersion + string.Format("-{0}", preReleaseTag); 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, "push origin --tags +" + newVersion); } } functions @{ IEnumerable GetAllRepos() { var nonDefaultRepos = new[] { "CoreCLR", "Coherence", "Coherence-Signed", "KoreBuild", "Universe", "libuv-build", }; return Enumerable.Concat(nonDefaultRepos, repositories); } }