Пример #1
0
        public async Task Execute(VersionToolOptions options)
        {
            if (string.IsNullOrWhiteSpace(options.RepoOwner))
            {
                throw new ArgumentException("Repo Owner is required");
            }
            if (string.IsNullOrWhiteSpace(options.RepoName))
            {
                throw new ArgumentException("Repo Name is required");
            }
            if (options.IssueNumber <= 0)
            {
                throw new ArgumentException("Issue Number is required");
            }
            var gitRepo = await gitFactory.CreateGitRepo();

            var currentBranchName = gitRepo.CurrentBranchName();
            var xtiBranchName     = XtiBranchName.Parse(currentBranchName);

            if (xtiBranchName is not XtiVersionBranchName)
            {
                throw new ArgumentException($"Branch '{currentBranchName}' is not a version branch");
            }
            var gitHubRepo = await gitFactory.CreateGitHubRepo(options.RepoOwner, options.RepoName);

            var issue = await gitHubRepo.Issue(options.IssueNumber);

            gitRepo.CheckoutBranch(issue.BranchName().Value);
        }
        public async Task Execute(VersionToolOptions options)
        {
            if (string.IsNullOrWhiteSpace(options.RepoOwner))
            {
                throw new ArgumentException("Repo Owner is required");
            }
            if (string.IsNullOrWhiteSpace(options.RepoName))
            {
                throw new ArgumentException("Repo Name is required");
            }
            var gitRepo = await gitFactory.CreateGitRepo();

            var currentBranchName = gitRepo.CurrentBranchName();
            var xtiBranchName     = XtiBranchName.Parse(currentBranchName);

            if (xtiBranchName is not XtiIssueBranchName issueBranchName)
            {
                throw new ArgumentException($"Branch '{currentBranchName}' is not an issue branch");
            }
            var gitHubRepo = await gitFactory.CreateGitHubRepo(options.RepoOwner, options.RepoName);

            var issue = await gitHubRepo.Issue(issueBranchName.IssueNumber);

            gitRepo.CommitChanges(issue.Title);
            await gitHubRepo.CompleteIssue(issueBranchName);

            var milestoneName = XtiMilestoneName.Parse(issue.Milestone.Title);
            var branchName    = milestoneName.Version.BranchName();

            gitRepo.CheckoutBranch(branchName.Value);
        }
Пример #3
0
        public async Task Execute(VersionToolOptions options)
        {
            if (string.IsNullOrWhiteSpace(options.RepoOwner))
            {
                throw new ArgumentException("Repo Owner is required");
            }
            if (string.IsNullOrWhiteSpace(options.RepoName))
            {
                throw new ArgumentException("Repo Name is required");
            }
            if (string.IsNullOrWhiteSpace(options.IssueTitle))
            {
                throw new ArgumentException("Issue Title is required");
            }
            var gitRepo = await gitFactory.CreateGitRepo();

            var currentBranchName = gitRepo.CurrentBranchName();
            var gitHubRepo        = await gitFactory.CreateGitHubRepo(options.RepoOwner, options.RepoName);

            XtiGitVersion xtiGitVersion;
            var           xtiBranchName = XtiBranchName.Parse(currentBranchName);

            if (xtiBranchName is XtiIssueBranchName issueBranchName)
            {
                if (options.StartIssue)
                {
                    throw new ArgumentException("Unable to start issue when not a version branch");
                }
                var branchIssue = await gitHubRepo.Issue(issueBranchName.IssueNumber);

                var xtiMilestoneName = XtiMilestoneName.Parse(branchIssue.Milestone.Title);
                xtiGitVersion = xtiMilestoneName.Version;
            }
            else if (xtiBranchName is XtiVersionBranchName versionBranchName)
            {
                xtiGitVersion = versionBranchName.Version;
            }
            else
            {
                throw new ArgumentException($"Branch '{currentBranchName}' is not an issue branch or a version branch");
            }
            var issue = await gitHubRepo.CreateIssue(xtiGitVersion, options.IssueTitle);

            if (options.StartIssue)
            {
                gitRepo.CheckoutBranch(issue.BranchName().Value);
            }
        }
Пример #4
0
        public async Task Execute(VersionToolOptions options)
        {
            if (string.IsNullOrWhiteSpace(options.AppName))
            {
                throw new ArgumentException("App Name is required");
            }
            if (string.IsNullOrWhiteSpace(options.AppType))
            {
                throw new ArgumentException("App Type is required");
            }
            if (string.IsNullOrWhiteSpace(options.RepoOwner))
            {
                throw new ArgumentException("Repo Owner is required");
            }
            if (string.IsNullOrWhiteSpace(options.RepoName))
            {
                throw new ArgumentException("Repo Name is required");
            }
            var gitRepo = await gitFactory.CreateGitRepo();

            var currentBranchName = gitRepo.CurrentBranchName();
            var gitHubRepo        = await gitFactory.CreateGitHubRepo(options.RepoOwner, options.RepoName);

            var defaultBranchName = await gitHubRepo.DefaultBranchName();

            if (!currentBranchName.Equals(defaultBranchName, StringComparison.OrdinalIgnoreCase))
            {
                throw new ArgumentException($"Current branch '{currentBranchName}' is not the default branch '{defaultBranchName}'");
            }
            var versionType      = AppVersionType.Values.Value(options.VersionType);
            var newVersionResult = await hubApi.AppRegistration.NewVersion.Execute(new NewVersionRequest
            {
                AppKey      = options.AppKey(),
                VersionType = versionType
            });

            var version    = newVersionResult.Data;
            var gitVersion = new XtiGitVersion(version.VersionType.DisplayText, version.VersionKey);
            await gitHubRepo.CreateNewVersion(gitVersion);

            var newVersionBranchName = gitVersion.BranchName();

            gitRepo.CheckoutBranch(newVersionBranchName.Value);
        }
Пример #5
0
        public async Task Execute(VersionToolOptions options)
        {
            if (string.IsNullOrWhiteSpace(options.AppName))
            {
                throw new ArgumentException("App Name is required");
            }
            if (string.IsNullOrWhiteSpace(options.AppType))
            {
                throw new ArgumentException("App Type is required");
            }
            if (string.IsNullOrWhiteSpace(options.RepoOwner))
            {
                throw new ArgumentException("Repo Owner is required");
            }
            if (string.IsNullOrWhiteSpace(options.RepoName))
            {
                throw new ArgumentException("Repo Name is required");
            }
            var gitRepo = await gitFactory.CreateGitRepo();

            var currentBranchName = gitRepo.CurrentBranchName();
            var xtiBranchName     = XtiBranchName.Parse(currentBranchName);

            if (xtiBranchName is not XtiVersionBranchName versionBranchName)
            {
                throw new ArgumentException($"Branch '{currentBranchName}' is not a version branch");
            }
            var gitHubRepo = await gitFactory.CreateGitHubRepo(options.RepoOwner, options.RepoName);

            gitRepo.CommitChanges($"Version {versionBranchName.Version.Key}");
            await gitHubRepo.CompleteVersion(versionBranchName);

            var defaultBranchName = await gitHubRepo.DefaultBranchName();

            gitRepo.CheckoutBranch(defaultBranchName);
            await hubApi.AppRegistration.EndPublish.Invoke(new GetVersionRequest
            {
                AppKey     = options.AppKey(),
                VersionKey = AppVersionKey.Parse(versionBranchName.Version.Key)
            });

            gitRepo.DeleteBranch(versionBranchName.Value);
        }
Пример #6
0
        public async Task Execute(VersionToolOptions options)
        {
            if (string.IsNullOrWhiteSpace(options.RepoOwner))
            {
                throw new ArgumentException("Repo Owner is required");
            }
            if (string.IsNullOrWhiteSpace(options.RepoName))
            {
                throw new ArgumentException("Repo Name is required");
            }
            var gitRepo = await gitFactory.CreateGitRepo();

            var currentBranchName = gitRepo.CurrentBranchName();
            var gitHubRepo        = await gitFactory.CreateGitHubRepo(options.RepoOwner, options.RepoName);

            XtiMilestoneName milestoneName;
            var xtiBranchName = XtiBranchName.Parse(currentBranchName);

            if (xtiBranchName is XtiIssueBranchName issueBranchName)
            {
                var issue = await gitHubRepo.Issue(issueBranchName.IssueNumber);

                milestoneName = XtiMilestoneName.Parse(issue.Milestone.Title);
            }
            else if (xtiBranchName is XtiVersionBranchName versionBranchName)
            {
                milestoneName = versionBranchName.Version.MilestoneName();
            }
            else
            {
                throw new ArgumentException($"Branch '{currentBranchName}' is not an issue branch or a version branch");
            }
            var milestone = await gitHubRepo.Milestone(milestoneName.Value);

            var issues = await gitHubRepo.OpenIssues(milestone);

            foreach (var issue in issues)
            {
                Console.WriteLine($"{issue.Number}: {issue.Title}");
            }
        }
Пример #7
0
        public async Task Execute(VersionToolOptions options)
        {
            AppVersionModel version;
            var             gitRepo = await gitFactory.CreateGitRepo();

            var currentBranchName = gitRepo.CurrentBranchName();
            var xtiBranchName     = XtiBranchName.Parse(currentBranchName);

            if (xtiBranchName is XtiIssueBranchName issueBranchName && !string.IsNullOrWhiteSpace(options.RepoOwner))
            {
                var gitHubRepo = await gitFactory.CreateGitHubRepo(options.RepoOwner, options.RepoName);

                var issue = await gitHubRepo.Issue(issueBranchName.IssueNumber);

                var milestoneName = XtiMilestoneName.Parse(issue.Milestone.Title);
                var versionKey    = AppVersionKey.Parse(milestoneName.Version.Key);
                version = await hubApi.AppRegistration.GetVersion.Invoke(new GetVersionRequest
                {
                    AppKey     = options.AppKey(),
                    VersionKey = versionKey
                });
            }
Пример #8
0
        public async Task Run(AppKey appKey, string appsToImport, string repoOwner, string repoName)
        {
            var versionToolOutput = await getVersionKey(appKey);

            var versionKey = AppVersionKey.Parse(versionToolOutput.VersionKey);

            if (hostEnv.IsProduction())
            {
                versionToolOutput = await beginPublish(appKey);
            }
            else
            {
                versionKey = AppVersionKey.Current;
            }
            var gitHubRepo = await gitFactory.CreateGitHubRepo(repoOwner, repoName);

            GitHubRelease release = null;

            if (!appKey.Type.Equals(AppType.Values.Package) && hostEnv.IsProduction())
            {
                var tagName = $"v{versionToolOutput.VersionNumber}";
                release = await gitHubRepo.Release(tagName);

                if (release != null)
                {
                    foreach (var asset in release.Assets)
                    {
                        Console.WriteLine($"Deleting release {release.TagName} asset {asset.ID}");
                        await gitHubRepo.DeleteReleaseAsset(asset);
                    }
                    await gitHubRepo.DeleteRelease(release);
                }
                Console.WriteLine($"Creating release {tagName}");
                release = await gitHubRepo.CreateRelease(tagName, versionToolOutput.VersionKey, "");
            }
            var publishDir = getPublishDir(appKey, versionKey);

            if (Directory.Exists(publishDir))
            {
                Directory.Delete(publishDir, true);
            }
            await publishSetup(appKey, versionKey);

            if (appKey.Type.Equals(AppType.Values.WebApp))
            {
                await buildWebApp(appKey, versionKey, appsToImport);
                await runDotNetPublish(appKey, versionKey);
                await copyToWebExports(appKey, versionKey);
            }
            else if (appKey.Type.Equals(AppType.Values.Service))
            {
                await runDotnetBuild();
                await runDotNetPublish(appKey, versionKey);
            }
            else
            {
                await runDotnetBuild();
            }
            if (!appKey.Type.Equals(AppType.Values.Package) && hostEnv.IsProduction())
            {
                await uploadReleaseAssets(appKey, versionKey, gitHubRepo, release);

                var versionsPath = Path.Combine(publishDir, "versions.json");
                if (File.Exists(versionsPath))
                {
                    Console.WriteLine("Uploading versions.json");
                    using var versionStream = new MemoryStream(File.ReadAllBytes(versionsPath));
                    await gitHubRepo.UploadReleaseAsset(release, new FileUpload(versionStream, "versions.json", "text/plain"));
                }
                Console.WriteLine($"Finalizing release {release.TagName}");
                await gitHubRepo.FinalizeRelease(release);
            }
            await packLibProjects(appKey, versionToolOutput.VersionNumber);
            await completeVersion(appKey, repoOwner, repoName);
        }