Skip to content

Commit

Permalink
Add support for automatic versioning (#32)
Browse files Browse the repository at this point in the history
* Add GitVersion tool to build script
* Added tag to master version
  • Loading branch information
Kralizek committed Jan 8, 2019
1 parent 3ae712a commit 6a1917c
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 10 deletions.
Binary file added GitVersion.yml
Binary file not shown.
1 change: 1 addition & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ branches:
- master

only_commits:
message: /build/
files:
- src/

Expand Down
30 changes: 23 additions & 7 deletions build.cake
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#tool "nuget:?package=ReportGenerator&version=4.0.5"
#tool "nuget:?package=JetBrains.dotCover.CommandLineTools&version=2018.3.1"
#tool "nuget:?package=GitVersion.CommandLine&version=4.0.0"

#load "./build/types.cake"

Expand All @@ -9,10 +10,6 @@ Setup<BuildState>(_ =>
{
var state = new BuildState
{
Parameters = new BuildParameters
{
CoverageTools = CoverageTool.OpenCover | CoverageTool.DotCover
},
Paths = new BuildPaths
{
SolutionFile = MakeAbsolute(File("./Nybus.sln"))
Expand All @@ -23,6 +20,25 @@ Setup<BuildState>(_ =>
return state;
});

Task("Version")
.Does<BuildState>(state =>
{
var version = GitVersion();
state.Version = new VersionInfo
{
SemVer = version.SemVer
};
if (BuildSystem.IsRunningOnAppVeyor)
{
AppVeyor.UpdateBuildVersion(state.Version.SemVer);
}
Information(version.SemVer);
});

Task("Restore")
.Does<BuildState>(state =>
{
Expand Down Expand Up @@ -142,15 +158,15 @@ Task("UploadTestsToAppVeyor")
});

Task("Test")
.IsDependentOn("Build")
.IsDependentOn("RunTests")
.IsDependentOn("MergeCoverageResults")
.IsDependentOn("GenerateXmlReport")
.IsDependentOn("GenerateHtmlReport")
.IsDependentOn("UploadTestsToAppVeyor");

Task("Pack")
.IsDependentOn("Test")
.IsDependentOn("Version")
.IsDependentOn("Restore")
.Does<BuildState>(state =>
{
var settings = new DotNetCorePackSettings
Expand All @@ -159,7 +175,7 @@ Task("Pack")
NoRestore = true,
OutputDirectory = state.Paths.OutputFolder,
IncludeSymbols = true,
ArgumentCustomization = args => args.Append("-p:SymbolPackageFormat=snupkg")
ArgumentCustomization = args => args.Append($"-p:SymbolPackageFormat=snupkg -p:Version={state.Version.SemVer}")
};
DotNetCorePack(state.Paths.SolutionFile.ToString(), settings);
Expand Down
8 changes: 6 additions & 2 deletions build/types.cake
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
public class BuildState
{
public BuildParameters Parameters { get; set; }
public VersionInfo Version { get; set; }

public BuildPaths Paths { get; set; }
}

public class BuildParameters
{

public CoverageTool CoverageTools { get; set; }
}

public class BuildPaths
Expand All @@ -32,6 +31,11 @@ public class BuildPaths
public FilePath OpenCoverResultFile => OutputFolder.CombineWithFilePath("OpenCover.xml");
}

public class VersionInfo
{
public string SemVer { get; set; }
}

[Flags]
public enum CoverageTool
{
Expand Down
3 changes: 2 additions & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<Project>
<PropertyGroup>
<Authors>Renato Golia</Authors>
<Version>1.0.0-alpha005</Version>
<Company>Nybus Project</Company>
<Product>Nybus</Product>
<license>https://github.com/Nybus-project/Nybus/blob/master/LICENSE</license>
<projectUrl>https://github.com/Nybus-project/Nybus</projectUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>

<NoWarn>NU5105</NoWarn>
</PropertyGroup>

<ItemGroup>
Expand Down

0 comments on commit 6a1917c

Please sign in to comment.