Skip to content

Commit 2e3d5e5

Browse files
authored
Merge pull request #898 from GitTools/CakeBuild
Initial Cake Build Script
2 parents aa5bb19 + 249be69 commit 2e3d5e5

16 files changed

+768
-68
lines changed

.gitattributes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# Auto detect text files and perform LF normalization
22
* text=auto eol=crlf
33

4+
# Declare files that will always have LF line endings on checkout.
5+
*.sh text eol=lf
6+
47
# Don't check these into the repo as LF to work around TeamCity bug
58
*.xml -text
69
*.targets -text

.gitignore

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,4 +101,10 @@ site/
101101
# Visual Studio Code
102102
####################
103103

104-
.vscode
104+
.vscode
105+
106+
####################
107+
# Cake
108+
####################
109+
/tools
110+
/*.zip

.travis.yml

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,15 @@
11
language: csharp
2-
solution: src/GitVersion.sln
32
sudo: false
43
mono:
54
- latest
65
os:
76
- linux
87
- osx
9-
before_install: # We need to download nuget.exe due to: https://github.com/travis-ci/travis-ci/issues/5932
8+
before_install:
109
- git fetch --unshallow # Travis always does a shallow clone, but GitVersion needs the full history including branches and tags
11-
- mkdir -p .nuget
12-
- wget -O .nuget/nuget.exe https://dist.nuget.org/win-x86-commandline/latest/nuget.exe
13-
- mono .nuget/nuget.exe
14-
install:
15-
- mono .nuget/nuget.exe restore src/GitVersion.sln -Verbosity detailed
16-
- mono .nuget/nuget.exe install NUnit.Runners -Version 3.2.1 -OutputDirectory ./src/packages
1710
script:
18-
- xbuild ./src/GitVersion.sln /property:Configuration="Debug" /verbosity:detailed
19-
- mono ./build/NuGetCommandLineBuild/tools/GitVersion.exe -l console -output buildserver -updateAssemblyInfo
20-
- xbuild ./src/GitVersion.sln /property:Configuration="Debug" /verbosity:detailed
21-
- mono ./src/packages/NUnit.ConsoleRunner.3.2.1/tools/nunit3-console.exe ./src/GitVersionTask.Tests/bin/Debug/GitVersionTask.Tests.dll ./src/GitVersionCore.Tests/bin/Debug/GitVersionCore.Tests.dll ./src/GitVersionTask.Tests/bin/Debug/GitVersionTask.Tests.dll ./src/GitVersionExe.Tests/bin/Debug/GitVersionExe.Tests.dll --where "cat != NoMono" --noresult
22-
23-
#
24-
# To run a clean build with Mono, executing just one test, do:
25-
# xbuild ./src/GitVersion.sln /t:Clean /verbosity:quiet && xbuild ./src/GitVersion.sln /property:Configuration="Debug" /verbosity:quiet && mono ./src/packages/NUnit.ConsoleRunner.3.2.1/tools/nunit3-console.exe ./src/GitVersionTask.Tests/bin/Debug/GitVersionTask.Tests.dll ./src/GitVersionCore.Tests/bin/Debug/GitVersionCore.Tests.dll ./src/GitVersionTask.Tests/bin/Debug/GitVersionTask.Tests.dll ./src/GitVersionExe.Tests/bin/Debug/GitVersionExe.Tests.dll --noresult --where "test =~ /TheNameOfTheTest/"
26-
#
27-
# To run a clean build with Mono, executing all tests, do:
28-
# xbuild ./src/GitVersion.sln /t:Clean /verbosity:quiet && xbuild ./src/GitVersion.sln /property:Configuration="Debug" /verbosity:quiet && mono ./src/packages/NUnit.ConsoleRunner.3.2.1/tools/nunit3-console.exe ./src/GitVersionTask.Tests/bin/Debug/GitVersionTask.Tests.dll ./src/GitVersionCore.Tests/bin/Debug/GitVersionCore.Tests.dll ./src/GitVersionTask.Tests/bin/Debug/GitVersionTask.Tests.dll ./src/GitVersionExe.Tests/bin/Debug/GitVersionExe.Tests.dll --noresult --where "cat != NoMono" --noresult
29-
#
11+
- ./build.sh
12+
cache:
13+
directories:
14+
- src/packages
15+
- tools

Build.cmd

Lines changed: 0 additions & 17 deletions
This file was deleted.

appveyor.deploy.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
install:
2+
npm i -g tfx-cli
3+
4+
assembly_info:
5+
patch: false
6+
7+
build_script:
8+
- ps: .\deploy.ps1
9+
10+
test: off
11+
skip_non_tags: true

appveyor.yml

Lines changed: 7 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,17 @@
1+
install:
2+
npm i -g tfx-cli
3+
14
assembly_info:
25
patch: false
36

4-
platform:
5-
- Any CPU
6-
77
configuration:
88
- Debug
99

1010
build_script:
11-
- cmd: nuget restore src/GitVersion.sln
12-
- cmd: npm i -g tfx-cli
13-
14-
- cmd: msbuild src/GitVersion.sln "/p:Configuration=%CONFIGURATION%;Platform=%PLATFORM%"
15-
- ps: .\build\NuGetCommandLineBuild\tools\GitVersion.exe /l console /output buildserver /updateAssemblyInfo
16-
- cmd: msbuild src/GitVersion.sln "/p:Configuration=%CONFIGURATION%;Platform=%PLATFORM%"
17-
18-
- cmd: appveyor PushArtifact "build\NuGetExeBuild\GitVersion.Portable.%GitVersion_NuGetVersion%.nupkg"
19-
20-
- cmd: appveyor PushArtifact "build\NuGetCommandLineBuild\GitVersion.CommandLine.%GitVersion_NuGetVersion%.nupkg"
21-
- cmd: appveyor PushArtifact "build\NuGetRefBuild\GitVersion.%GitVersion_NuGetVersion%.nupkg"
22-
- cmd: appveyor PushArtifact "build\NuGetTaskBuild\GitVersionTask.%GitVersion_NuGetVersion%.nupkg"
23-
- ps: appveyor PushArtifact ("build\GemBuild\gitversion-$env:GitVersion_MajorMinorPatch" + (&{If($env:GitVersion_PreReleaseTag -eq '' -or $env:GitVersion_PreReleaseTag -eq $null) {""} Else {"."+$env:GitVersion_PreReleaseTag}}) + ".gem")
24-
25-
- cmd: 7z a "GitVersion_%GitVersion_NuGetVersion%.zip" -r .\build\NuGetCommandLineBuild\Tools\*.*
26-
- cmd: appveyor PushArtifact "GitVersion_%GitVersion_NuGetVersion%.zip"
27-
28-
- cmd: 7z a "GitVersionTfsBuildTask_%GitVersion_NuGetVersion%.zip" -r .\build\GitVersionTfsTaskBuild\GitVersionTask\*.*
29-
- cmd: appveyor PushArtifact "GitVersionTfsBuildTask_%GitVersion_NuGetVersion%.zip"
30-
- cmd: appveyor PushArtifact "build\GitVersionTfsTaskBuild\gittools.gitversion-%GitVersion_SemVer%.vsix"
11+
- ps: .\build.ps1
3112

32-
test_script:
33-
- nunit3-console "src\GitVersionTask.Tests\bin\%CONFIGURATION%\GitVersionTask.Tests.dll" "src\GitVersionExe.Tests\bin\%CONFIGURATION%\GitVersionExe.Tests.dll" "src\GitVersionCore.Tests\bin\%CONFIGURATION%\GitVersionCore.Tests.dll"
13+
test: off
14+
skip_tags: true
3415

3516
cache:
36-
- src\packages -> **\packages.config # preserve "packages" directory in the root of build folder but will reset it if packages.config is modified
17+
- src\packages -> **\packages.config # preserve "packages" directory in the root of build folder but will reset it if packages.config is modified

build.cake

Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
#tool "nuget:?package=NUnit.ConsoleRunner"
2+
#tool "nuget:?package=GitReleaseNotes"
3+
4+
var target = Argument("target", "Default");
5+
var configuration = Argument("configuration", "Release");
6+
7+
string version = null;
8+
string nugetVersion = null;
9+
string preReleaseTag = null;
10+
string semVersion = null;
11+
string milestone = null;
12+
bool publishingError = false;
13+
bool IsTagged = (BuildSystem.AppVeyor.Environment.Repository.Tag.IsTag &&
14+
!string.IsNullOrWhiteSpace(BuildSystem.AppVeyor.Environment.Repository.Tag.Name));
15+
bool IsMainGitVersionRepo = StringComparer.OrdinalIgnoreCase.Equals("gittools/gitversion", BuildSystem.AppVeyor.Environment.Repository.Name);
16+
bool IsPullRequest = BuildSystem.AppVeyor.Environment.PullRequest.IsPullRequest;
17+
18+
void Build(string configuration, string nugetVersion, string semVersion, string version, string preReleaseTag)
19+
{
20+
if(IsRunningOnUnix())
21+
{
22+
XBuild("./src/GitVersion.sln", new XBuildSettings()
23+
.SetConfiguration(configuration)
24+
.WithProperty("POSIX", "True")
25+
.SetVerbosity(Verbosity.Verbose));
26+
}
27+
else
28+
{
29+
var msBuildSettings = new MSBuildSettings()
30+
.SetConfiguration(configuration)
31+
.SetPlatformTarget(PlatformTarget.MSIL)
32+
.WithProperty("Windows", "True")
33+
.UseToolVersion(MSBuildToolVersion.VS2015)
34+
.SetVerbosity(Verbosity.Minimal)
35+
.SetNodeReuse(false);
36+
37+
if (BuildSystem.AppVeyor.IsRunningOnAppVeyor)
38+
{
39+
msBuildSettings = msBuildSettings
40+
.WithProperty("GitVersion_NuGetVersion", nugetVersion)
41+
.WithProperty("GitVersion_SemVer", semVersion)
42+
.WithProperty("GitVersion_MajorMinorPatch", version)
43+
.WithProperty("GitVersion_PreReleaseTag", preReleaseTag);
44+
}
45+
MSBuild("./src/GitVersion.sln", msBuildSettings);
46+
}
47+
}
48+
49+
Task("DogfoodBuild")
50+
.IsDependentOn("NuGet-Package-Restore")
51+
.Does(() =>
52+
{
53+
Build(configuration, nugetVersion, semVersion, version, preReleaseTag);
54+
});
55+
56+
Task("Version")
57+
.IsDependentOn("DogfoodBuild")
58+
.Does(() =>
59+
{
60+
GitVersion(new GitVersionSettings
61+
{
62+
UpdateAssemblyInfo = true,
63+
LogFilePath = "console",
64+
OutputType = GitVersionOutput.BuildServer,
65+
ToolPath = @"src\GitVersionExe\bin\Release\GitVersion.exe"
66+
});
67+
GitVersion assertedVersions = GitVersion(new GitVersionSettings
68+
{
69+
OutputType = GitVersionOutput.Json,
70+
ToolPath = @"src\GitVersionExe\bin\Release\GitVersion.exe"
71+
});
72+
73+
version = assertedVersions.MajorMinorPatch;
74+
nugetVersion = assertedVersions.NuGetVersion;
75+
preReleaseTag = assertedVersions.PreReleaseTag;
76+
semVersion = assertedVersions.LegacySemVerPadded;
77+
});
78+
79+
Task("NuGet-Package-Restore")
80+
.Does(() =>
81+
{
82+
NuGetRestore("./src/GitVersion.sln");
83+
});
84+
85+
Task("Build")
86+
.IsDependentOn("Version")
87+
.IsDependentOn("NuGet-Package-Restore")
88+
.Does(() =>
89+
{
90+
Build(configuration, nugetVersion, semVersion, version, preReleaseTag);
91+
});
92+
93+
Task("Run-NUnit-Tests")
94+
.IsDependentOn("Build")
95+
.Does(() =>
96+
{
97+
var settings = new NUnit3Settings();
98+
if(IsRunningOnUnix())
99+
{
100+
settings.Where = "cat != NoMono";
101+
}
102+
NUnit3(new [] {
103+
"src/GitVersionCore.Tests/bin/" + configuration + "/GitVersionCore.Tests.dll",
104+
"src/GitVersionExe.Tests/bin/" + configuration + "/GitVersionExe.Tests.dll",
105+
"src/GitVersionTask.Tests/bin/" + configuration + "/GitVersionTask.Tests.dll" },
106+
settings);
107+
if (AppVeyor.IsRunningOnAppVeyor)
108+
{
109+
Information("Uploading test results");
110+
AppVeyor.UploadTestResults("TestResult.xml", AppVeyorTestResultsType.NUnit3);
111+
}
112+
});
113+
114+
Task("Zip-Files")
115+
.IsDependentOn("Run-NUnit-Tests")
116+
.Does(() =>
117+
{
118+
Zip("./build/NuGetCommandLineBuild/Tools/", "build/GitVersion_" + nugetVersion + ".zip");
119+
});
120+
121+
Task("Create-Release-Notes")
122+
.IsDependentOn("Build")
123+
.Does(() =>
124+
{
125+
var releaseNotesExitCode = StartProcess(
126+
@"tools\GitReleaseNotes\tools\gitreleasenotes.exe",
127+
new ProcessSettings { Arguments = ". /o build/releasenotes.md" });
128+
if (string.IsNullOrEmpty(System.IO.File.ReadAllText("./build/releasenotes.md")))
129+
System.IO.File.WriteAllText("./build/releasenotes.md", "No issues closed since last release");
130+
131+
if (releaseNotesExitCode != 0) throw new Exception("Failed to generate release notes");
132+
});
133+
134+
Task("Package")
135+
.IsDependentOn("Create-Release-Notes")
136+
.IsDependentOn("Zip-Files");
137+
138+
Task("Upload-AppVeyor-Artifacts")
139+
.IsDependentOn("Package")
140+
.WithCriteria(() => AppVeyor.IsRunningOnAppVeyor)
141+
.Does(() =>
142+
{
143+
var gem = string.IsNullOrEmpty(preReleaseTag) ?
144+
"gitversion-" + version + ".gem" :
145+
"gitversion-" + version + "." + preReleaseTag + ".gem";
146+
147+
System.IO.File.WriteAllLines("build/artifacts", new[]{
148+
"NuGetExeBuild:GitVersion.Portable." + nugetVersion +".nupkg",
149+
"NuGetCommandLineBuild:GitVersion.CommandLine." + nugetVersion +".nupkg",
150+
"NuGetRefBuild:GitVersion." + nugetVersion +".nupkg",
151+
"NuGetTaskBuild:GitVersionTask." + nugetVersion +".nupkg",
152+
"GitVersionTfsTaskBuild:gittools.gitversion." + semVersion +".vsix",
153+
"GemBuild:" + gem,
154+
"zip:GitVersion_" + nugetVersion + ".zip",
155+
"releaseNotes:releasenotes.md"
156+
});
157+
158+
AppVeyor.UploadArtifact("build/NuGetExeBuild/GitVersion.Portable." + nugetVersion +".nupkg");
159+
AppVeyor.UploadArtifact("build/NuGetCommandLineBuild/GitVersion.CommandLine." + nugetVersion +".nupkg");
160+
AppVeyor.UploadArtifact("build/NuGetRefBuild/GitVersion." + nugetVersion +".nupkg");
161+
AppVeyor.UploadArtifact("build/NuGetTaskBuild/GitVersionTask." + nugetVersion +".nupkg");
162+
AppVeyor.UploadArtifact("build/GitVersionTfsTaskBuild/gittools.gitversion-" + semVersion + ".vsix");
163+
AppVeyor.UploadArtifact("build/GitVersion_" + nugetVersion + ".zip");
164+
AppVeyor.UploadArtifact("build/GemBuild/" + gem);
165+
});
166+
167+
168+
Task("Travis")
169+
.IsDependentOn("Run-NUnit-Tests");
170+
171+
Task("Default")
172+
.IsDependentOn("Upload-AppVeyor-Artifacts");
173+
174+
RunTarget(target);

0 commit comments

Comments
 (0)