This repository has been archived by the owner on Jul 27, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 49
Initial use of GitVersion #226
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
aa54405
Initial use of GitVersion
CharliePoole 975875c
Extract PR number
CharliePoole b486c27
Add branch name to ci builds
CharliePoole 10abbd8
Fix errors and refactor so properties are all set in constructor
CharliePoole d261fec
Use GitVer version for packaging locally and on Travis
CharliePoole 87bb6ca
Use GitVer version for packaging on AppVeyor
CharliePoole a0ef16a
Exclude pdb files from zip for now
CharliePoole d9606c0
Update CommonAssemblyInfo for CI builds
CharliePoole e08bac4
Remove Debugging info from script
CharliePoole c3e8757
Merge branch 'master' into issue-206
CharliePoole 68781f8
Ignore files in .vscode dir
CharliePoole 924e2f5
Merge branch 'issue-206' of https://github.com/CharliePoole/nunit-gui…
CharliePoole 62a1cfd
Fix build.sh arguments
CharliePoole File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
// See https://go.microsoft.com/fwlink/?LinkId=733558 | ||
// for the documentation about the tasks.json format | ||
"version": "2.0.0", | ||
"tasks": [ | ||
{ | ||
"type": "cake", | ||
"script": "Package", | ||
"problemMatcher": [ | ||
"$eslint-stylish" | ||
] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
mode: ContinuousDelivery | ||
branches: | ||
master: | ||
tag: dev | ||
increment: Minor | ||
releases?[/-]: | ||
tag: ci | ||
increment: Minor | ||
features?[/-]: | ||
tag: ci | ||
increment: Minor | ||
issues?[/-]: | ||
tag: ci | ||
increment: Minor | ||
(pull|pull\-requests|pr)[/-]: | ||
tag: pr | ||
increment: Minor | ||
ignore: | ||
sha: [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
#tool nuget:?package=NUnit.ConsoleRunner&version=3.7.0 | ||
#tool nuget:?package=GitVersion.CommandLine | ||
|
||
using System.Text.RegularExpressions; | ||
|
||
////////////////////////////////////////////////////////////////////// | ||
// ARGUMENTS | ||
|
@@ -8,15 +11,11 @@ var target = Argument("target", "Default"); | |
var configuration = Argument("configuration", "Debug"); | ||
|
||
////////////////////////////////////////////////////////////////////// | ||
// SET PACKAGE VERSION | ||
// SET PACKAGE VERSION DEFAULTS | ||
////////////////////////////////////////////////////////////////////// | ||
|
||
var version = "0.5"; | ||
var modifier = ""; | ||
|
||
var isAppveyor = BuildSystem.IsRunningOnAppVeyor; | ||
var dbgSuffix = configuration == "Debug" ? "-dbg" : ""; | ||
var packageVersion = version + modifier + dbgSuffix; | ||
GitVersion GitVersionInfo { get; set; } | ||
BuildInfo Build { get; set;} | ||
|
||
////////////////////////////////////////////////////////////////////// | ||
// DEFINE RUN CONSTANTS | ||
|
@@ -41,10 +40,6 @@ var PACKAGE_SOURCE = new string[] | |
"https://www.myget.org/F/nunit-gui-team/api/v2" | ||
}; | ||
|
||
// Packages | ||
var SRC_PACKAGE = PACKAGE_DIR + "NUnit-Gui-" + version + modifier + "-src.zip"; | ||
var ZIP_PACKAGE = PACKAGE_DIR + "NUnit-Gui-" + packageVersion + ".zip"; | ||
|
||
////////////////////////////////////////////////////////////////////// | ||
// CLEAN | ||
////////////////////////////////////////////////////////////////////// | ||
|
@@ -57,63 +52,44 @@ Task("Clean") | |
|
||
|
||
////////////////////////////////////////////////////////////////////// | ||
// INITIALIZE FOR BUILD | ||
// RESTORE NUGET PACKAGES | ||
////////////////////////////////////////////////////////////////////// | ||
|
||
Task("InitializeBuild") | ||
Task("RestorePackages") | ||
.Does(() => | ||
{ | ||
NuGetRestore(GUI_SOLUTION, new NuGetRestoreSettings | ||
{ | ||
Source = PACKAGE_SOURCE, | ||
Verbosity = NuGetVerbosity.Detailed | ||
}); | ||
}); | ||
|
||
if (BuildSystem.IsRunningOnAppVeyor) | ||
////////////////////////////////////////////////////////////////////// | ||
// SET BUILD INFO | ||
////////////////////////////////////////////////////////////////////// | ||
Task("SetBuildInfo") | ||
.Does(() => | ||
{ | ||
var settings = new GitVersionSettings(); | ||
if (!BuildSystem.IsLocalBuild) | ||
{ | ||
var tag = AppVeyor.Environment.Repository.Tag; | ||
|
||
if (tag.IsTag) | ||
{ | ||
packageVersion = tag.Name; | ||
} | ||
else | ||
{ | ||
var buildNumber = AppVeyor.Environment.Build.Number.ToString("00000"); | ||
var branch = AppVeyor.Environment.Repository.Branch; | ||
var isPullRequest = AppVeyor.Environment.PullRequest.IsPullRequest; | ||
|
||
if (branch == "master" && !isPullRequest) | ||
{ | ||
packageVersion = version + "-dev-" + buildNumber + dbgSuffix; | ||
} | ||
else | ||
{ | ||
var suffix = "-ci-" + buildNumber + dbgSuffix; | ||
|
||
if (isPullRequest) | ||
suffix += "-pr-" + AppVeyor.Environment.PullRequest.Number; | ||
else | ||
suffix += "-" + branch; | ||
|
||
// Nuget limits "special version part" to 20 chars. Add one for the hyphen. | ||
if (suffix.Length > 21) | ||
suffix = suffix.Substring(0, 21); | ||
|
||
packageVersion = version + suffix; | ||
} | ||
} | ||
|
||
AppVeyor.UpdateBuildVersion(packageVersion); | ||
settings.UpdateAssemblyInfo = true; | ||
settings.UpdateAssemblyInfoFilePath = "src/CommonAssemblyInfo.cs"; | ||
} | ||
|
||
GitVersionInfo = GitVersion(settings); | ||
Build = new BuildInfo(GitVersionInfo); | ||
}); | ||
|
||
////////////////////////////////////////////////////////////////////// | ||
// BUILD | ||
////////////////////////////////////////////////////////////////////// | ||
|
||
Task("Build") | ||
.IsDependentOn("InitializeBuild") | ||
.IsDependentOn("Clean") | ||
.IsDependentOn("RestorePackages") | ||
.IsDependentOn("SetBuildInfo") | ||
.Does(() => | ||
{ | ||
if(IsRunningOnWindows()) | ||
|
@@ -167,9 +143,7 @@ Task("PackageZip") | |
BIN_DIR + "CHANGES.txt", | ||
BIN_DIR + "nunit-gui.exe", | ||
BIN_DIR + "nunit-gui.exe.config", | ||
BIN_DIR + "nunit-gui.pdb", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the motivation for not providing pdbs ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. They break the build under Mono 4.6.2, which doesn't produce them. We could put them back if we used logic to include them only when they actually are present. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok. Let us just leave them out to begin with. Then we can always include them later. |
||
BIN_DIR + "nunit.uikit.dll", | ||
BIN_DIR + "nunit.uikit.pdb", | ||
BIN_DIR + "nunit.engine.api.dll", | ||
BIN_DIR + "nunit.engine.dll", | ||
BIN_DIR + "Mono.Cecil.dll", | ||
|
@@ -179,7 +153,7 @@ Task("PackageZip") | |
BIN_DIR + "nunit-agent-x86.exe.config" | ||
}; | ||
|
||
Zip(BIN_DIR, File(ZIP_PACKAGE), zipFiles); | ||
Zip(BIN_DIR, File(PACKAGE_DIR + "NUnit-Gui-" + Build.PackageVersion + ".zip"), zipFiles); | ||
}); | ||
|
||
Task("PackageChocolatey") | ||
|
@@ -188,12 +162,12 @@ Task("PackageChocolatey") | |
{ | ||
CreateDirectory(PACKAGE_DIR); | ||
|
||
ChocolateyPack("choco/nunit-gui.nuspec", | ||
new ChocolateyPackSettings() | ||
{ | ||
Version = packageVersion, | ||
OutputDirectory = PACKAGE_DIR, | ||
Files = new ChocolateyNuSpecContent[] | ||
ChocolateyPack("choco/nunit-gui.nuspec", | ||
new ChocolateyPackSettings() | ||
{ | ||
Version = Build.PackageVersion, | ||
OutputDirectory = PACKAGE_DIR, | ||
Files = new ChocolateyNuSpecContent[] | ||
{ | ||
new ChocolateyNuSpecContent() { Source = "../LICENSE" }, | ||
new ChocolateyNuSpecContent() { Source = "../CHANGES.txt" }, | ||
|
@@ -211,16 +185,86 @@ Task("PackageChocolatey") | |
new ChocolateyNuSpecContent() { Source = "nunit-agent-x86.exe.ignore", Target="tools" }, | ||
new ChocolateyNuSpecContent() { Source = "nunit.choco.addins", Target="tools" } | ||
} | ||
}); | ||
}); | ||
}); | ||
|
||
////////////////////////////////////////////////////////////////////// | ||
// TASK TARGETS | ||
// BUILD INFO | ||
////////////////////////////////////////////////////////////////////// | ||
|
||
Task("Rebuild") | ||
.IsDependentOn("Clean") | ||
.IsDependentOn("Build"); | ||
class BuildInfo | ||
{ | ||
public BuildInfo(GitVersion gitVersion) | ||
{ | ||
Version = gitVersion.MajorMinorPatch; | ||
BranchName = gitVersion.BranchName; | ||
BuildNumber = gitVersion.CommitsSinceVersionSourcePadded; | ||
|
||
// Initially assume it's neither master nor a PR | ||
IsMaster = false; | ||
IsPullRequest = false; | ||
PullRequestNumber = string.Empty; | ||
|
||
if (BranchName == "master") | ||
{ | ||
IsMaster = true; | ||
PreReleaseSuffix = "dev-" + BuildNumber; | ||
} | ||
else | ||
{ | ||
var re = new Regex(@"(pull|pull\-requests?|pr)[/-](\d*)[/-]"); | ||
var match = re.Match(BranchName); | ||
|
||
if (match.Success) | ||
{ | ||
IsPullRequest = true; | ||
PullRequestNumber = match.Groups[2].Value; | ||
PreReleaseSuffix = "pr-" + PullRequestNumber + "-" + BuildNumber; | ||
} | ||
else | ||
{ | ||
PreReleaseSuffix = "ci-" + BuildNumber + "-" + Regex.Replace(BranchName, "[^0-9A-Za-z-]+", "-"); | ||
// Nuget limits "special version part" to 20 chars. | ||
if (PreReleaseSuffix.Length > 20) | ||
PreReleaseSuffix = PreReleaseSuffix.Substring(0, 20); | ||
} | ||
} | ||
|
||
PackageVersion = Version + "-" + PreReleaseSuffix; | ||
|
||
AssemblyVersion = gitVersion.AssemblySemVer; | ||
AssemblyFileVersion = PackageVersion; | ||
} | ||
|
||
public string BranchName { get; private set; } | ||
public string Version { get; private set; } | ||
public bool IsMaster { get; private set; } | ||
public bool IsPullRequest { get; private set; } | ||
public string PullRequestNumber { get; private set; } | ||
public string BuildNumber { get; private set; } | ||
public string PreReleaseSuffix { get; private set; } | ||
public string PackageVersion { get; private set; } | ||
|
||
public string AssemblyVersion { get; private set; } | ||
public string AssemblyFileVersion { get; private set; } | ||
|
||
public string Dump() | ||
{ | ||
var NL = Environment.NewLine; | ||
return " BranchName: " + BranchName + NL + | ||
" Version: " + Version + NL + | ||
" PreReleaseSuffix: " + PreReleaseSuffix + NL + | ||
" IsPullRequest: " + IsPullRequest.ToString() + NL + | ||
" PullRequestNumber: " + PullRequestNumber + NL + | ||
" AssemblyVersion: " + AssemblyVersion + NL + | ||
" AssemblyFileVersion: " + AssemblyFileVersion + NL + | ||
" Package Version: " + PackageVersion + NL; | ||
} | ||
} | ||
|
||
////////////////////////////////////////////////////////////////////// | ||
// TASK TARGETS | ||
////////////////////////////////////////////////////////////////////// | ||
|
||
Task("Package") | ||
.IsDependentOn("PackageZip") | ||
|
@@ -232,7 +276,8 @@ Task("Appveyor") | |
.IsDependentOn("Package"); | ||
|
||
Task("Travis") | ||
.IsDependentOn("Build"); | ||
.IsDependentOn("Build") | ||
.IsDependentOn("PackageZip"); | ||
|
||
Task("Default") | ||
.IsDependentOn("Build"); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this file included on purpose? I can google that it defines a vscode task, but I cannot find the script Package that is mentioned.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's because I executed tasks in the script under VsCode. File should be in .gitignore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The script is build.cake, Package is a target.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. The
"script": "Package"
was a bit misleading 😄