Beispiel #1
0
        private static async Task <int> CreateReleaseAsync(CreateSubOptions subOptions, IFileSystem fileSystem)
        {
            try
            {
                ConfigureLogging(subOptions.LogFilePath);

                var github        = subOptions.CreateGitHubClient();
                var configuration = ConfigurationProvider.Provide(subOptions.TargetDirectory ?? Environment.CurrentDirectory, fileSystem);

                Release release;
                if (!string.IsNullOrEmpty(subOptions.Milestone))
                {
                    release = await CreateReleaseFromMilestone(github, subOptions.RepositoryOwner, subOptions.RepositoryName, subOptions.Milestone, subOptions.TargetCommitish, subOptions.AssetPaths, subOptions.Prerelease, configuration);
                }
                else
                {
                    release = await CreateReleaseFromInputFile(github, subOptions.RepositoryOwner, subOptions.RepositoryName, subOptions.Name, subOptions.InputFilePath, subOptions.TargetCommitish, subOptions.AssetPaths, subOptions.Prerelease);
                }

                Console.WriteLine(release.HtmlUrl);
                return(0);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);

                return(1);
            }
        }
        private static async Task <int> CreateReleaseAsync(CreateSubOptions subOptions)
        {
            Log.Information("Creating release...");
            _vcsProvider = GetVcsProvider(subOptions);

            Core.Model.Release release;
            if (!string.IsNullOrEmpty(subOptions.Milestone))
            {
                Log.Verbose("Milestone {Milestone} was specified", subOptions.Milestone);
                var releaseName = subOptions.Name;
                if (string.IsNullOrWhiteSpace(releaseName))
                {
                    Log.Verbose("No Release Name was specified, using {Milestone}.", subOptions.Milestone);
                    releaseName = subOptions.Milestone;
                }

                release = await _vcsProvider.CreateReleaseFromMilestone(subOptions.RepositoryOwner, subOptions.RepositoryName, subOptions.Milestone, releaseName, subOptions.TargetCommitish, subOptions.AssetPaths, subOptions.Prerelease).ConfigureAwait(false);
            }
            else
            {
                Log.Verbose("No milestone was specified, switching to release creating from input file");
                release = await _vcsProvider.CreateReleaseFromInputFile(subOptions.RepositoryOwner, subOptions.RepositoryName, subOptions.Name, subOptions.InputFilePath, subOptions.TargetCommitish, subOptions.AssetPaths, subOptions.Prerelease).ConfigureAwait(false);
            }

            Log.Information("Drafted release is available at:\n{HtmlUrl}", release.HtmlUrl);
            Log.Verbose("Body:\n{Body}", release.Body);
            return(0);
        }