static async Task Main(string[] args) { var config = ProcessArguments(args); if (config.GitRemoteUserName.Length == 0) { config.GitRemoteUserName = config.GitRemoteName; } await GitHub.CleanupUnusedBranches(config.GitRemoteUserName, config.MonoRepo, BranchPrefix, config.PersonalAccessToken, config.DryRun, config.Verbose); PullRequest?pr = await GetPullRequest(config); if (pr == null && config.PullRequestNumber != null) { return; } string local_branch_name, remote_branch_name, remote_name, remote_mono_repo; if (pr != null) { // We want to check if the branch for this PR, needs an update or not remote_mono_repo = $"{pr.HeadRepoOwner}/mono"; remote_branch_name = pr.HeadRef; remote_name = config.GitRemoteName; // Use the branch name that the PR uses local_branch_name = pr.HeadRef; } else { GitHub.Trace($"no pr found, setting remote_mono_repo to {config.MonoRepo}", config.Verbose); remote_mono_repo = config.MonoRepo; remote_branch_name = config.MonoBranch; remote_name = config.GitRemoteOriginName; local_branch_name = $"{BranchPrefix}_{config.MonoBranch}_{Guid.NewGuid ()}"; } string msbuildBranchHead, msbuildRefInMono; try { bool required; (required, msbuildBranchHead, msbuildRefInMono) = await IsMSBuildBumpRequired( msbuild_repo : config.MSBuildRepo, msbuild_branch : config.MSBuildBranch, mono_repo : remote_mono_repo, mono_branch : remote_branch_name, verbose : config.Verbose); if (!required) { Console.WriteLine($"-> Ref is updated already, nothing to be done."); return; } } catch (HttpRequestException hre) { Console.WriteLine($"Error checking if bump is required: {hre.Message}"); return; } Repository repo = new Repository(config.MonoWorkingDir); GitHub.PrepareMonoWorkingDirectory(repo: repo, mono_working_dir: config.MonoWorkingDir, remote_name: remote_name, remote_branch_name: remote_branch_name, local_branch_name: local_branch_name, verbose: config.Verbose); if (!(await UpdateMSBuildPy(msbuildBranchHead, config.MonoWorkingDir, repo))) { Console.WriteLine($"Error: unable to update msbuild.py"); return; } // git commit var commit_msg = $"[{config.MonoBranch}] Bump msbuild to track {config.MSBuildBranch}"; var sig = repo.Config.BuildSignature(DateTimeOffset.Now); repo.Commit(commit_msg, sig, sig); if (!GitHub.GitPush(config.MonoWorkingDir, config.GitRemoteName, local_branch_name, local_branch_name, config.DryRun)) { Console.WriteLine($"Error: git push failed"); return; } if (!config.DryRun && pr != null) { Console.WriteLine($"---- Updated PR: {pr.HTML_URL} ---"); } if (!config.DryRun && pr == null) { // Create new pull request var title = $"[{config.MonoBranch}] Bump msbuild to track {config.MSBuildBranch}"; (var result, var html_url, _) = await GitHub.CreatePullRequest( target_owner_repo : remote_mono_repo, base_branch_name : config.MonoBranch, head_ref : $"{config.GitRemoteUserName}:{local_branch_name}", personal_access_token : config.PersonalAccessToken, title : title, body : String.Empty, reviewers : config.Reviewers, verbose : config.Verbose); if (result) { Console.WriteLine($"----------- Created new PR at {html_url} ----------"); } else { Console.WriteLine("Failed to create PR."); } } await CheckRoslynAndNuGet(config.MonoRepo, config.MonoBranch, config.MSBuildRepo, msbuildRefInMono, msbuildBranchHead, config.Verbose); }
static async Task Main(string[] args) { var config = ProcessArguments(args); if (config.GitRemoteUserName.Length == 0) { config.GitRemoteUserName = config.GitRemoteName; } await GitHub.CleanupUnusedBranches(config.GitRemoteUserName, config.RuntimeRepo, BranchPrefix, config.PersonalAccessToken, config.DryRun, config.Verbose); Repository repo = new Repository(config.RuntimeWorkingDir); string remote_name, remote_branch_name, local_branch_name, remote_runtime_repo; remote_name = config.GitRemoteName; remote_branch_name = config.RuntimeBranch; remote_runtime_repo = "dotnet/runtime"; local_branch_name = $"{BranchPrefix}_{config.RuntimeBranch}_{Guid.NewGuid ()}"; GitHub.PrepareMonoWorkingDirectory( repo: repo, mono_working_dir: config.RuntimeWorkingDir, remote_name: remote_name, remote_branch_name: remote_branch_name, local_branch_name: local_branch_name, verbose: config.Verbose); string DockerImage = await GetDockerImage(config); Console.WriteLine(DockerImage); if (!await UpdateYml(DockerImage, repo, config)) { Console.WriteLine($"Error: unable to update platform-matrix.yml"); return; } var commit_msg = $"[{config.RuntimeBranch}] Bump Docker image with Emscripten {config.EmsdkVer}"; var sig = repo.Config.BuildSignature(DateTimeOffset.Now); repo.Commit(commit_msg, sig, sig); if (!GitHub.GitPush(config.RuntimeWorkingDir, config.GitRemoteName, local_branch_name, local_branch_name, config.DryRun)) { Console.WriteLine($"Error: git push failed"); return; } if (!config.DryRun) { // Create new pull request var title = $"[{config.RuntimeBranch}] Bump Docker image with Emscripten {config.EmsdkVer}"; (var result, var html_url, _) = await GitHub.CreatePullRequest( target_owner_repo : remote_runtime_repo, base_branch_name : config.RuntimeBranch, head_ref : $"{config.GitRemoteUserName}:{local_branch_name}", personal_access_token : config.PersonalAccessToken, title : title, body : String.Empty, reviewers : config.Reviewers, verbose : config.Verbose); if (result) { Console.WriteLine($"----------- Created new PR at {html_url} ----------"); } else { Console.WriteLine("Failed to create PR."); } } }