Ejemplo n.º 1
0
        private static DependencyUpdateResults UpdateFiles()
        {
            // Ideally this logic would depend on the CLI produces and consumes metadata.  Since it doesn't
            // exist various version information is inspected to obtain the latest CLI version along with
            // the runtime (e.g. shared framework) it depends on.

            BuildInfo cliBuildInfo = BuildInfo.Get(CliBuildInfoName, s_config.CliVersionUrl, fetchLatestReleaseFile: false);

            // Adjust the LatestReleaseVersion since it is not the full version and all consumers here need it to be.
            cliBuildInfo.LatestReleaseVersion = $"{s_config.RuntimeReleasePrefix}-{cliBuildInfo.LatestReleaseVersion}";
            string sharedFrameworkVersion = CliDependencyHelper.GetSharedFrameworkVersion(cliBuildInfo.LatestReleaseVersion);

            IEnumerable <DependencyBuildInfo> buildInfos = new[]
            {
                new DependencyBuildInfo(cliBuildInfo, false, Enumerable.Empty <string>()),
                new DependencyBuildInfo(
                    new BuildInfo()
                {
                    Name = SharedFrameworkBuildInfoName,
                    LatestReleaseVersion = sharedFrameworkVersion,
                    LatestPackages       = new Dictionary <string, string>()
                },
                    false,
                    Enumerable.Empty <string>()),
            };
            IEnumerable <IDependencyUpdater> updaters = GetUpdaters();

            return(DependencyUpdateUtils.Update(updaters, buildInfos));
        }
Ejemplo n.º 2
0
        protected DependencyUpdateResults UpdateToRemote(GitHubClient client)
        {
            // Use the commit hash of the remote dotnet/versions repo master branch.
            string versionsCommitHash = client
                                        .GetReferenceAsync(new GitHubProject("versions", "dotnet"), "heads/master")
                                        .Result.Object.Sha;

            DependencyUpdateResults updateResults = DependencyUpdateUtils.Update(
                CreateUpdaters().ToArray(),
                CreateDependencyInfos(true, versionsCommitHash).ToArray());

            // Update CurrentRef for each applicable build info used.
            if (!string.IsNullOrEmpty(CurrentRefXmlPath))
            {
                foreach (ITaskItem item in updateResults.UsedInfos
                         .OfType <TaskItemBuildDependencyInfo>()
                         .Distinct()
                         .Select(info => info.SourceItem)
                         .Where(item => !string.IsNullOrEmpty(item.GetMetadata(CurrentRefMetadataName))))
                {
                    UpdateProperty(
                        CurrentRefXmlPath,
                        $"{item.ItemSpec}{CurrentRefMetadataName}",
                        versionsCommitHash);
                }
            }

            return(updateResults);
        }
Ejemplo n.º 3
0
        private static DependencyUpdateResults UpdateFiles(IEnumerable <IDependencyInfo> buildInfos)
        {
            string runtimeVersion    = buildInfos.GetBuildVersion(RuntimeBuildInfoName);
            string dockerfileVersion = runtimeVersion.Substring(0, runtimeVersion.LastIndexOf('.'));
            IEnumerable <IDependencyUpdater> updaters = GetUpdaters(dockerfileVersion);

            return(DependencyUpdateUtils.Update(updaters, buildInfos));
        }
Ejemplo n.º 4
0
        private static async Task <DependencyUpdateResults> UpdateFilesAsync()
        {
            IEnumerable <IDependencyInfo> buildInfos = await GetBuildInfoAsync();

            string sdkVersion        = buildInfos.GetBuildVersion(SdkBuildInfoName);
            string dockerfileVersion = sdkVersion.Substring(0, sdkVersion.LastIndexOf('.'));
            IEnumerable <IDependencyUpdater> updaters = GetUpdaters(dockerfileVersion);

            return(DependencyUpdateUtils.Update(updaters, buildInfos));
        }
Ejemplo n.º 5
0
        private async Task <DependencyUpdateResults> UpdateFilesAsync()
        {
            var buildInfo = await GetBuildInfoAsync();

            var runtimeVersion    = new NuGetVersion(buildInfo.SimpleVersion);
            var dockerfileVersion = $"{runtimeVersion.Major}.{runtimeVersion.Minor}";
            var updaters          = GetUpdaters(dockerfileVersion);

            return(DependencyUpdateUtils.Update(updaters, new[] { buildInfo }));
        }
Ejemplo n.º 6
0
        private DependencyUpdateResults UpdateFiles(IEnumerable <IDependencyInfo> buildInfos)
        {
            List <IDependencyUpdater> updaters = new List <IDependencyUpdater>();

            updaters.AddRange(CreateManifestUpdaters());
            updaters.Add(ScriptRunnerUpdater.GetDockerfileUpdater(Program.RepoRoot));
            updaters.Add(ScriptRunnerUpdater.GetReadMeUpdater(Program.RepoRoot));

            return(DependencyUpdateUtils.Update(updaters, buildInfos));
        }
Ejemplo n.º 7
0
        private static DependencyUpdateResults UpdateFiles(IEnumerable <IDependencyInfo> buildInfos)
        {
            string buildVersion = buildInfos.GetBuildVersion(RuntimeBuildInfoName) ??
                                  buildInfos.GetBuildVersion(SdkBuildInfoName) ??
                                  buildInfos.GetBuildVersion(AspNetCoreBuildInfoName);
            string productVersion    = buildVersion.Split('-')[0];
            string dockerfileVersion = productVersion.Substring(0, productVersion.LastIndexOf('.'));
            IEnumerable <IDependencyUpdater> updaters = GetUpdaters(dockerfileVersion, buildInfos);

            return(DependencyUpdateUtils.Update(updaters, buildInfos));
        }
        private DependencyUpdateResults UpdateFiles(IEnumerable <IDependencyInfo> buildInfos)
        {
            List <IDependencyUpdater> updaters = new List <IDependencyUpdater>();

            updaters.AddRange(CreateManifestUpdaters());
            updaters.AddRange(CreateLcuUpdaters());
            updaters.AddRange(CreateVsUpdaters());
            updaters.AddRange(CreateNuGetUpdaters());
            updaters.Add(new ReadmeUpdater());

            return(DependencyUpdateUtils.Update(updaters, buildInfos));
        }
Ejemplo n.º 9
0
        private static DependencyUpdateResults UpdateFiles(IEnumerable <IDependencyInfo> buildInfos)
        {
            // NOTE: dotnet-monitor will diverge its versioning in the future; this will need to be refactored in
            // some way to allow updaters to be collected for each product's individual version.
            string buildVersion = buildInfos.GetBuildVersion(RuntimeBuildInfoName) ??
                                  buildInfos.GetBuildVersion(SdkBuildInfoName) ??
                                  buildInfos.GetBuildVersion(AspNetCoreBuildInfoName) ??
                                  buildInfos.GetBuildVersion(MonitorBuildInfoName);
            string productVersion    = buildVersion.Split('-')[0];
            string dockerfileVersion = productVersion.Substring(0, productVersion.LastIndexOf('.'));
            IEnumerable <IDependencyUpdater> updaters = GetUpdaters(dockerfileVersion, buildInfos);

            return(DependencyUpdateUtils.Update(updaters, buildInfos));
        }
Ejemplo n.º 10
0
        public static void Main(string[] args)
        {
            HandleDebugSwitch(ref args);

            bool onlyUpdate = args.Length > 0 && string.Equals("--Update", args[0], StringComparison.OrdinalIgnoreCase);

            List <BuildInfo> buildInfos = new List <BuildInfo>();

            buildInfos.Add(GetBuildInfo("CoreSetup", s_config.CoreSetupVersionFragment, fetchLatestReleaseFile: false));

            if (s_config.HasRoslynVersionFragment)
            {
                buildInfos.Add(GetBuildInfo("Roslyn", s_config.RoslynVersionFragment, fetchLatestReleaseFile: false));
            }

            IEnumerable <IDependencyUpdater> updaters = GetUpdaters();
            var dependencyBuildInfos = buildInfos.Select(buildInfo =>
                                                         new BuildDependencyInfo(
                                                             buildInfo,
                                                             upgradeStableVersions: true,
                                                             disabledPackages: Enumerable.Empty <string>()));
            DependencyUpdateResults updateResults = DependencyUpdateUtils.Update(updaters, dependencyBuildInfos);

            if (!onlyUpdate && updateResults.ChangesDetected())
            {
                GitHubAuth    gitHubAuth     = new GitHubAuth(s_config.Password, s_config.UserName, s_config.Email);
                GitHubProject origin         = new GitHubProject(s_config.GitHubProject, s_config.UserName);
                GitHubBranch  upstreamBranch = new GitHubBranch(
                    s_config.GitHubUpstreamBranch,
                    new GitHubProject(s_config.GitHubProject, s_config.GitHubUpstreamOwner));

                string suggestedMessage = updateResults.GetSuggestedCommitMessage();
                string body             = string.Empty;
                if (s_config.GitHubPullRequestNotifications.Any())
                {
                    body += PullRequestCreator.NotificationString(s_config.GitHubPullRequestNotifications);
                }

                new PullRequestCreator(gitHubAuth)
                .CreateOrUpdateAsync(
                    suggestedMessage,
                    suggestedMessage + $" ({upstreamBranch.Name})",
                    body,
                    upstreamBranch,
                    origin,
                    new PullRequestOptions())
                .Wait();
            }
        }
Ejemplo n.º 11
0
        public static void Main(string[] args)
        {
            DebugHelper.HandleDebugSwitch(ref args);

            bool onlyUpdate;

            ParseArgs(args, out onlyUpdate);

            List <BuildInfo> buildInfos = new List <BuildInfo>();

            buildInfos.Add(GetBuildInfo("CoreFx", s_config.CoreFxVersionUrl, fetchLatestReleaseFile: false));
            buildInfos.Add(GetBuildInfo("CoreClr", s_config.CoreClrVersionUrl, fetchLatestReleaseFile: false));
            buildInfos.Add(GetBuildInfo("Standard", s_config.StandardVersionUrl, fetchLatestReleaseFile: false));

            IEnumerable <IDependencyUpdater> updaters = GetUpdaters();
            var dependencyBuildInfos = buildInfos.Select(buildInfo =>
                                                         new DependencyBuildInfo(
                                                             buildInfo,
                                                             upgradeStableVersions: true,
                                                             disabledPackages: Enumerable.Empty <string>()));
            DependencyUpdateResults updateResults = DependencyUpdateUtils.Update(updaters, dependencyBuildInfos);

            if (!onlyUpdate && updateResults.ChangesDetected())
            {
                GitHubAuth    gitHubAuth     = new GitHubAuth(s_config.Password, s_config.UserName, s_config.Email);
                GitHubProject origin         = new GitHubProject(s_config.GitHubProject, s_config.UserName);
                GitHubBranch  upstreamBranch = new GitHubBranch(
                    s_config.GitHubUpstreamBranch,
                    new GitHubProject(s_config.GitHubProject, s_config.GitHubUpstreamOwner));

                string suggestedMessage = updateResults.GetSuggestedCommitMessage();
                string body             = string.Empty;
                if (s_config.GitHubPullRequestNotifications.Any())
                {
                    body += PullRequestCreator.NotificationString(s_config.GitHubPullRequestNotifications);
                }

                new PullRequestCreator(gitHubAuth, origin, upstreamBranch)
                .CreateOrUpdateAsync(
                    suggestedMessage,
                    suggestedMessage + $" ({upstreamBranch.Name})",
                    body)
                .Wait();
            }
        }
Ejemplo n.º 12
0
        public static void Main(string[] args)
        {
            Trace.Listeners.Add(new TextWriterTraceListener(Console.Out));

            if (!ParseArgs(args, out bool updateOnly))
            {
                return;
            }

            IEnumerable <IDependencyUpdater>  updaters = GetUpdaters();
            IEnumerable <DependencyBuildInfo> buildInfoDependencies = GetBuildInfoDependencies();

            DependencyUpdateResults updateResults = DependencyUpdateUtils.Update(updaters, buildInfoDependencies);

            if (!updateOnly && updateResults.ChangesDetected())
            {
                CreatePullRequest(updateResults);
            }
        }
Ejemplo n.º 13
0
        protected override void TraceListenedExecute()
        {
            // Use the commit sha of versions repo master (not just "master") for stable upgrade.
            var    gitHubAuth = new GitHubAuth(GitHubAuthToken, GitHubUser, GitHubEmail);
            var    client     = new GitHubClient(gitHubAuth);
            string masterSha  = client
                                .GetReferenceAsync(new GitHubProject("versions", "dotnet"), "heads/master")
                                .Result.Object.Sha;

            foreach (ITaskItem item in DependencyBuildInfo)
            {
                if (!string.IsNullOrEmpty(item.GetMetadata(CurrentRefMetadataName)))
                {
                    item.SetMetadata(CurrentRefMetadataName, masterSha);
                }
                string autoUpgradeBranch = item.GetMetadata(AutoUpgradeBranchMetadataName);
                if (!string.IsNullOrEmpty(autoUpgradeBranch))
                {
                    item.SetMetadata(CurrentBranchMetadataName, autoUpgradeBranch);
                }
            }

            DependencyUpdateResults updateResults = DependencyUpdateUtils.Update(
                CreateUpdaters().ToArray(),
                CreateBuildInfoDependencies().ToArray());

            // Update CurrentRef and CurrentBranch for each applicable build info used.
            if (!string.IsNullOrEmpty(CurrentRefXmlPath))
            {
                foreach (BuildInfo info in updateResults.UsedBuildInfos)
                {
                    ITaskItem infoItem = FindDependencyBuildInfo(info.Name);

                    if (!string.IsNullOrEmpty(infoItem.GetMetadata(CurrentRefMetadataName)))
                    {
                        UpdateProperty(
                            CurrentRefXmlPath,
                            $"{info.Name}{CurrentRefMetadataName}",
                            masterSha);
                    }

                    string autoUpgradeBranch = infoItem.GetMetadata(AutoUpgradeBranchMetadataName);
                    if (!string.IsNullOrEmpty(autoUpgradeBranch))
                    {
                        UpdateProperty(
                            CurrentRefXmlPath,
                            $"{info.Name}{CurrentBranchMetadataName}",
                            autoUpgradeBranch);
                    }
                }
            }

            if (updateResults.ChangesDetected())
            {
                var origin = new GitHubProject(ProjectRepoName, GitHubUser);

                var upstreamBranch = new GitHubBranch(
                    ProjectRepoBranch,
                    new GitHubProject(ProjectRepoName, ProjectRepoOwner));

                string suggestedMessage = updateResults.GetSuggestedCommitMessage();
                string body             = string.Empty;
                if (NotifyGitHubUsers != null)
                {
                    body += PullRequestCreator.NotificationString(NotifyGitHubUsers.Select(item => item.ItemSpec));
                }

                var prCreator = new PullRequestCreator(gitHubAuth, origin, upstreamBranch, GitHubAuthor);
                prCreator.CreateOrUpdateAsync(
                    suggestedMessage,
                    suggestedMessage + $" ({ProjectRepoBranch})",
                    body,
                    forceCreate: AlwaysCreateNewPullRequest).Wait();
            }
            else
            {
                Log.LogMessage("No update required: no changes detected.");
            }
        }
Ejemplo n.º 14
0
        private static DependencyUpdateResults UpdateFiles(IEnumerable <IDependencyInfo> buildInfos)
        {
            IEnumerable <IDependencyUpdater> updaters = GetUpdaters();

            return(DependencyUpdateUtils.Update(updaters, buildInfos));
        }
Ejemplo n.º 15
0
 protected override void TraceListenedExecute()
 {
     DependencyUpdateUtils.Update(
         CreateUpdaters().ToArray(),
         CreateLocalDependencyInfos().ToArray());
 }
Ejemplo n.º 16
0
 protected override void TraceListenedExecute()
 {
     DependencyUpdateUtils.Update(
         CreateUpdaters().ToArray(),
         CreateBuildInfoDependencies().ToArray());
 }