Skip to content

Commit

Permalink
Merge pull request #74 from gep13/Issue-59
Browse files Browse the repository at this point in the history
(GH-59) Getting versioning working correctly
  • Loading branch information
gep13 committed Jan 8, 2016
2 parents ebf1bb1 + 8669cbf commit fe0f957
Show file tree
Hide file tree
Showing 13 changed files with 70 additions and 126 deletions.
6 changes: 3 additions & 3 deletions BuildScripts/default.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ properties {
$nugetExe = "..\Tools\NuGet\NuGet.exe";
$projectName = "GitReleaseManager";
$openCoverExe = "..\Source\packages\OpenCover.4.5.3723\OpenCover.Console.exe";
$nunitConsoleExe = "..\Source\packages\NUnit.Runners.2.6.4\tools\nunit-console.exe";
$nunitConsoleExe = "..\Source\packages\NUnit.Console.3.0.1\tools\nunit3-console.exe";
$reportGeneratorExe = "..\Source\packages\ReportGenerator.2.1.8.0\tools\ReportGenerator.exe";
$coverallsExe = "..\Source\packages\coveralls.io.1.3.4\tools\coveralls.net.exe";
$publishCoverityExe = "..\Source\packages\PublishCoverity.0.10.0\PublishCoverity.exe";
Expand Down Expand Up @@ -415,7 +415,7 @@ Task -Name RunGitVersion -Depends __InstallGitVersion -Description "Execute the
exec {
if(isAppVeyor) {
Write-Output "Running on AppVeyor, so UpdateAssemblyInfo will be called."
& $gitVersionExe /output buildserver /UpdateAssemblyInfo true
& $gitVersionExe $rootDirectory /output buildserver /UpdateAssemblyInfo true
$script:version = $env:GitVersion_LegacySemVerPadded
} else {
$output = & $gitVersionExe
Expand Down Expand Up @@ -593,7 +593,7 @@ Task -Name RunCodeCoverage -Description "Use OpenCover, NUnit and Coveralls to a

exec {
Write-Output "Running OpenCover...";
& $openCoverExe -target:$nunitConsoleExe -targetargs:`"$buildArtifactsDirectory\GitReleaseManager.Tests.dll /noshadow /nologo`" -filter:`"+[GitReleaseManager]GitReleaseManager*`" -excludebyattribute:`"System.CodeDom.Compiler.GeneratedCodeAttribute`" -register:user -output:`"$buildArtifactsDirectory\coverage.xml`";
& $openCoverExe -target:$nunitConsoleExe -targetargs:`"$buildArtifactsDirectory\GitReleaseManager.Tests.dll`" -filter:`"+[GitReleaseManager]GitReleaseManager*`" -excludebyattribute:`"System.CodeDom.Compiler.GeneratedCodeAttribute`" -register:user -output:`"$buildArtifactsDirectory\coverage.xml`";
Write-Output "OpenCover Complete";

Write-Output "Running ReportGenerator...";
Expand Down
2 changes: 1 addition & 1 deletion Source/.nuget/packages.config
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="coveralls.io" version="1.3.4" />
<package id="NUnit.Runners" version="2.6.4" />
<package id="NUnit.Console" version="3.0.1" />
<package id="OpenCover" version="4.5.3723" />
<package id="PublishCoverity" version="0.10.0" />
<package id="ReportGenerator" version="2.1.8.0" />
Expand Down
11 changes: 6 additions & 5 deletions Source/GitReleaseManager.Cli/GitReleaseManager.Cli.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<RestorePackages>true</RestorePackages>
<BuildToolsFxCopVersion>1.0.1</BuildToolsFxCopVersion>
<TargetFrameworkProfile />
<IsWebBootstrapper>false</IsWebBootstrapper>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
Expand All @@ -29,7 +30,6 @@
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
Expand Down Expand Up @@ -59,8 +59,9 @@
<CodeAnalysisTreatWarningsAsErrors>True</CodeAnalysisTreatWarningsAsErrors>
</PropertyGroup>
<ItemGroup>
<Reference Include="CommandLine">
<HintPath>..\packages\CommandLineParser.1.9.71\lib\net45\CommandLine.dll</HintPath>
<Reference Include="CommandLine, Version=2.0.275.0, Culture=neutral, PublicKeyToken=de6f01bd326f8c32, processorArchitecture=MSIL">
<HintPath>..\packages\CommandLineParser.2.0.275-beta\lib\net45\CommandLine.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Octokit, Version=0.17.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Octokit.0.17.0\lib\net45\Octokit.dll</HintPath>
Expand Down Expand Up @@ -135,11 +136,11 @@
</PropertyGroup>
<Error Condition="!Exists('..\packages\StyleCop.MSBuild.4.7.49.1\build\StyleCop.MSBuild.Targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\StyleCop.MSBuild.4.7.49.1\build\StyleCop.MSBuild.Targets'))" />
<Error Condition="!Exists('..\packages\StyleCop.Error.MSBuild.1.0.0\build\StyleCop.Error.MSBuild.Targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\StyleCop.Error.MSBuild.1.0.0\build\StyleCop.Error.MSBuild.Targets'))" />
<Error Condition="!Exists('..\packages\Fody.1.29.3\build\dotnet\Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Fody.1.29.3\build\dotnet\Fody.targets'))" />
<Error Condition="!Exists('..\packages\Fody.1.29.4\build\dotnet\Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Fody.1.29.4\build\dotnet\Fody.targets'))" />
</Target>
<Import Project="..\..\BuildScripts\CodeAnalysis.props" Condition="Exists('..\..\BuildScripts\CodeAnalysis.props')" />
<Import Project="..\..\BuildScripts\StyleCop.props" Condition="Exists('..\..\BuildScripts\StyleCop.props')" />
<Import Project="..\packages\StyleCop.MSBuild.4.7.49.1\build\StyleCop.MSBuild.Targets" Condition="Exists('..\packages\StyleCop.MSBuild.4.7.49.1\build\StyleCop.MSBuild.Targets')" />
<Import Project="..\packages\StyleCop.Error.MSBuild.1.0.0\build\StyleCop.Error.MSBuild.Targets" Condition="Exists('..\packages\StyleCop.Error.MSBuild.1.0.0\build\StyleCop.Error.MSBuild.Targets')" />
<Import Project="..\packages\Fody.1.29.3\build\dotnet\Fody.targets" Condition="Exists('..\packages\Fody.1.29.3\build\dotnet\Fody.targets')" />
<Import Project="..\packages\Fody.1.29.4\build\dotnet\Fody.targets" Condition="Exists('..\packages\Fody.1.29.4\build\dotnet\Fody.targets')" />
</Project>
4 changes: 2 additions & 2 deletions Source/GitReleaseManager.Cli/Options/AddAssetSubOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
namespace GitReleaseManager.Cli.Options
{
using System.Collections.Generic;

using CommandLine;

[Verb("addasset", HelpText = "Adds an asset to an existing release.")]
public class AddAssetSubOptions : BaseGitHubSubOptions
{
[OptionList('a', "assets", Separator = ',', HelpText = "Paths to the files to include in the release.", Required = true)]
[Option('a', "assets", Separator = ',', HelpText = "Paths to the files to include in the release.", Required = true)]
public IList<string> AssetPaths { get; set; }

[Option('t', "tagName", HelpText = "The name of the release (Typically this is the generated SemVer Version Number).", Required = true)]
Expand Down
1 change: 1 addition & 0 deletions Source/GitReleaseManager.Cli/Options/CloseSubOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ namespace GitReleaseManager.Cli.Options
{
using CommandLine;

[Verb("close", HelpText = "Closes the milestone.")]
public class CloseSubOptions : BaseGitHubSubOptions
{
[Option('m', "milestone", HelpText = "The milestone to use.", Required = true)]
Expand Down
4 changes: 2 additions & 2 deletions Source/GitReleaseManager.Cli/Options/CreateSubOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
namespace GitReleaseManager.Cli.Options
{
using System.Collections.Generic;

using CommandLine;

[Verb("create", HelpText = "Creates a draft release notes from a milestone.")]
public class CreateSubOptions : BaseGitHubSubOptions
{
[OptionList('a', "assets", Separator = ',', HelpText = "Paths to the files to include in the release.", Required = false)]
[Option('a', "assets", Separator = ',', HelpText = "Paths to the files to include in the release.", Required = false)]
public IList<string> AssetPaths { get; set; }

[Option('c', "targetcommitish", HelpText = "The commit to tag. Can be a branch or SHA. Defaults to repository's default branch.", Required = false)]
Expand Down
1 change: 1 addition & 0 deletions Source/GitReleaseManager.Cli/Options/ExportSubOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ namespace GitReleaseManager.Cli.Options
{
using CommandLine;

[Verb("export", HelpText = "Exports all the Release Notes in markdown format.")]
public class ExportSubOptions : BaseGitHubSubOptions
{
[Option('f', "fileOutputPath", HelpText = "Path to the file export releases.", Required = true)]
Expand Down
3 changes: 3 additions & 0 deletions Source/GitReleaseManager.Cli/Options/InitSubOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

namespace GitReleaseManager.Cli.Options
{
using CommandLine;

[Verb("init", HelpText = "Creates a sample Yaml Configuration file in root directory")]
public class InitSubOptions : BaseSubOptions
{
}
Expand Down
20 changes: 5 additions & 15 deletions Source/GitReleaseManager.Cli/Options/MainOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,26 @@

namespace GitReleaseManager.Cli.Options
{
using CommandLine;
using CommandLine.Text;

public class MainOptions
{
[VerbOption("create", HelpText = "Creates a draft release notes from a milestone.")]
public CreateSubOptions CreateVerb { get; set; }

[VerbOption("addasset", HelpText = "Adds an asset to an existing release.")]
public AddAssetSubOptions AddAssetVerb { get; set; }

[VerbOption("close", HelpText = "Closes the milestone.")]
public CloseSubOptions CloseVerb { get; set; }

[VerbOption("publish", HelpText = "Publishes the release notes and closes the milestone.")]
public PublishSubOptions PublishVerb { get; set; }

[VerbOption("export", HelpText = "Exports all the Release Notes in markdown format.")]
public ExportSubOptions ExportVerb { get; set; }

[VerbOption("init", HelpText = "Creates a sample Yaml Configuration file in root directory")]
public InitSubOptions InitVerb { get; set; }

[VerbOption("showconfig", HelpText = "Shows the current configuration")]
public ShowConfigSubOptions ShowConfigVerb { get; set; }

[HelpVerbOption]
public string DoHelpForVerb(string verbName)
{
return HelpText.AutoBuild(this, verbName);
}
////[HelpVerbOption]
////public string DoHelpForVerb(string verbName)
////{
//// return HelpText.AutoBuild(this, verbName);
////}
}
}
1 change: 1 addition & 0 deletions Source/GitReleaseManager.Cli/Options/PublishSubOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ namespace GitReleaseManager.Cli.Options
{
using CommandLine;

[Verb("publish", HelpText = "Publishes the release notes and closes the milestone.")]
public class PublishSubOptions : BaseGitHubSubOptions
{
[Option('t', "tagName", HelpText = "The name of the release (Typically this is the generated SemVer Version Number).", Required = true)]
Expand Down
3 changes: 3 additions & 0 deletions Source/GitReleaseManager.Cli/Options/ShowConfigSubOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

namespace GitReleaseManager.Cli.Options
{
using CommandLine;

[Verb("showconfig", HelpText = "Shows the current configuration")]
public class ShowConfigSubOptions : BaseSubOptions
{
}
Expand Down
136 changes: 40 additions & 96 deletions Source/GitReleaseManager.Cli/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,108 +28,28 @@ public static class Program
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Justification = "Not required")]
private static int Main(string[] args)
{
var options = new MainOptions();

var result = 1;

if (!Parser.Default.ParseArgumentsStrict(
args,
options,
(verb, subOptions) =>
{
result = 1;
var baseSubOptions = subOptions as BaseSubOptions;
if (baseSubOptions != null)
{
if (string.IsNullOrEmpty(baseSubOptions.TargetDirectory))
{
baseSubOptions.TargetDirectory = Environment.CurrentDirectory;
}
ConfigureLogging(baseSubOptions.LogFilePath);
}
var fileSystem = new FileSystem();
if (verb == "create")
{
var createSubOptions = baseSubOptions as CreateSubOptions;
if (createSubOptions != null)
{
result = CreateReleaseAsync(createSubOptions, fileSystem).Result;
}
}
if (verb == "addasset")
{
var addAssetSubOptions = baseSubOptions as AddAssetSubOptions;
if (addAssetSubOptions != null)
{
result = AddAssetsAsync(addAssetSubOptions).Result;
}
}
if (verb == "close")
{
var closeSubOptions = baseSubOptions as CloseSubOptions;
if (closeSubOptions != null)
{
result = CloseMilestoneAsync(closeSubOptions).Result;
}
}
if (verb == "publish")
{
var publishSubOptions = baseSubOptions as PublishSubOptions;
if (publishSubOptions != null)
{
result = PublishReleaseAsync(publishSubOptions).Result;
}
}
if (verb == "export")
{
var exportSubOptions = baseSubOptions as ExportSubOptions;
if (exportSubOptions != null)
{
result = ExportReleasesAsync(exportSubOptions, fileSystem).Result;
}
}
if (verb == "init")
{
var initSubOptions = baseSubOptions as InitSubOptions;
if (initSubOptions != null)
{
ConfigurationProvider.WriteSample(initSubOptions.TargetDirectory, fileSystem);
result = 0;
}
}
if (verb == "showconfig")
{
var showConfigSubOptions = baseSubOptions as ShowConfigSubOptions;
if (showConfigSubOptions != null)
{
Console.WriteLine(ConfigurationProvider.GetEffectiveConfigAsString(showConfigSubOptions.TargetDirectory, fileSystem));
result = 0;
}
}
}))
{
return 1;
}

return result;
var fileSystem = new FileSystem();

return Parser.Default.ParseArguments<CreateSubOptions, AddAssetSubOptions, CloseSubOptions, PublishSubOptions, ExportSubOptions, InitSubOptions, ShowConfigSubOptions>(args)
.MapResult(
(CreateSubOptions opts) => CreateReleaseAsync(opts, fileSystem).Result,
(AddAssetSubOptions opts) => AddAssetsAsync(opts).Result,
(CloseSubOptions opts) => CloseMilestoneAsync(opts).Result,
(PublishSubOptions opts) => PublishReleaseAsync(opts).Result,
(ExportSubOptions opts) => ExportReleasesAsync(opts, fileSystem).Result,
(InitSubOptions opts) => CreateSampleConfigFile(opts, fileSystem).Result,
(ShowConfigSubOptions opts) => ShowConfig(opts, fileSystem).Result,
errs => 1);
}

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

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

if (!string.IsNullOrEmpty(subOptions.Milestone))
{
Expand All @@ -154,6 +74,8 @@ private static async Task<int> AddAssetsAsync(AddAssetSubOptions subOptions)
{
try
{
ConfigureLogging(subOptions.LogFilePath);

var github = subOptions.CreateGitHubClient();

await AddAssets(github, subOptions.RepositoryOwner, subOptions.RepositoryName, subOptions.TagName, subOptions.AssetPaths);
Expand All @@ -172,6 +94,8 @@ private static async Task<int> CloseMilestoneAsync(CloseSubOptions subOptions)
{
try
{
ConfigureLogging(subOptions.LogFilePath);

var github = subOptions.CreateGitHubClient();

await CloseMilestone(github, subOptions.RepositoryOwner, subOptions.RepositoryName, subOptions.Milestone);
Expand All @@ -190,6 +114,8 @@ private static async Task<int> PublishReleaseAsync(PublishSubOptions subOptions)
{
try
{
ConfigureLogging(subOptions.LogFilePath);

var github = subOptions.CreateGitHubClient();

await PublishRelease(github, subOptions.RepositoryOwner, subOptions.RepositoryName, subOptions.TagName);
Expand All @@ -208,8 +134,10 @@ private static async Task<int> ExportReleasesAsync(ExportSubOptions subOptions,
{
try
{
ConfigureLogging(subOptions.LogFilePath);

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

var releasesMarkdown = await ExportReleases(github, subOptions.RepositoryOwner, subOptions.RepositoryName, subOptions.TagName, configuration);

Expand All @@ -228,6 +156,22 @@ private static async Task<int> ExportReleasesAsync(ExportSubOptions subOptions,
}
}

private static async Task<int> CreateSampleConfigFile(InitSubOptions subOptions, IFileSystem fileSystem)
{
ConfigureLogging(subOptions.LogFilePath);

ConfigurationProvider.WriteSample(subOptions.TargetDirectory ?? Environment.CurrentDirectory, fileSystem);
return 0;
}

private static async Task<int> ShowConfig(ShowConfigSubOptions subOptions, IFileSystem fileSystem)
{
ConfigureLogging(subOptions.LogFilePath);

Console.WriteLine(ConfigurationProvider.GetEffectiveConfigAsString(subOptions.TargetDirectory ?? Environment.CurrentDirectory, fileSystem));
return 0;
}

private static async Task CreateReleaseFromMilestone(GitHubClient github, string owner, string repository, string milestone, string targetCommitish, IList<string> assets, bool prerelease, Config configuration)
{
var releaseNotesBuilder = new ReleaseNotesBuilder(new DefaultGitHubClient(github, owner, repository), owner, repository, milestone, configuration);
Expand Down
4 changes: 2 additions & 2 deletions Source/GitReleaseManager.Cli/packages.config
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="BuildTools.FxCop" version="1.0.1" targetFramework="net45" />
<package id="CommandLineParser" version="1.9.71" targetFramework="net45" />
<package id="CommandLineParser" version="2.0.275-beta" targetFramework="net451" />
<package id="Costura.Fody" version="1.3.3.0" targetFramework="net451" developmentDependency="true" />
<package id="Fody" version="1.29.3" targetFramework="net451" developmentDependency="true" />
<package id="Fody" version="1.29.4" targetFramework="net451" developmentDependency="true" />
<package id="Octokit" version="0.17.0" targetFramework="net451" />
<package id="StyleCop.Error.MSBuild" version="1.0.0" targetFramework="net45" />
<package id="StyleCop.MSBuild" version="4.7.49.1" targetFramework="net45" developmentDependency="true" />
Expand Down

0 comments on commit fe0f957

Please sign in to comment.