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"); } var gitRepo = await gitFactory.CreateGitRepo(); var branchName = gitRepo.CurrentBranchName(); var xtiBranchName = XtiBranchName.Parse(branchName); if (xtiBranchName is not XtiVersionBranchName versionBranchName) { throw new ArgumentException($"Branch '{branchName}' is not a version branch"); } var version = await hubApi.AppRegistration.BeginPublish.Invoke(new GetVersionRequest { AppKey = options.AppKey(), VersionKey = AppVersionKey.Parse(versionBranchName.Version.Key) }); var output = new VersionOutput(); output.Output(version, options.OutputPath); }
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); }
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); }
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"); } var currentVersion = await hubApi.AppRegistration.GetVersion.Invoke(new GetVersionRequest { AppKey = options.AppKey(), VersionKey = AppVersionKey.Current }); var output = new VersionOutput(); output.Output(currentVersion, options.OutputPath); }
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 }); }