1
+ #tool "nuget:?package=GitVersion.CommandLine"
2
+ #tool "nuget:?package=NUnit.ConsoleRunner"
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
+ Setup ( context =>
19
+ {
20
+ if ( ! BuildSystem . IsLocalBuild )
21
+ {
22
+ GitVersion ( new GitVersionSettings {
23
+ UpdateAssemblyInfo = true ,
24
+ LogFilePath = "console" ,
25
+ OutputType = GitVersionOutput . BuildServer
26
+ } ) ;
27
+
28
+ version = context . EnvironmentVariable ( "GitVersion_MajorMinorPatch" ) ;
29
+ nugetVersion = context . EnvironmentVariable ( "GitVersion_NuGetVersion" ) ;
30
+ preReleaseTag = context . EnvironmentVariable ( "GitVersion_PreReleaseTag" ) ;
31
+ semVersion = context . EnvironmentVariable ( "GitVersion_LegacySemVerPadded" ) ;
32
+ milestone = string . Concat ( "v" , version ) ;
33
+ }
34
+
35
+ GitVersion assertedVersions = GitVersion ( new GitVersionSettings
36
+ {
37
+ OutputType = GitVersionOutput . Json
38
+ } ) ;
39
+
40
+ version = assertedVersions . MajorMinorPatch ;
41
+ nugetVersion = assertedVersions . NuGetVersion ;
42
+ preReleaseTag = assertedVersions . PreReleaseTag ;
43
+ semVersion = assertedVersions . LegacySemVerPadded ;
44
+ milestone = string . Concat ( "v" , version ) ;
45
+ } ) ;
46
+
47
+ Task ( "NuGet-Package-Restore" )
48
+ . Does ( ( ) =>
49
+ {
50
+ NuGetRestore ( "./src/GitVersion.sln" ) ;
51
+ } ) ;
52
+
53
+ Task ( "Build" )
54
+ . IsDependentOn ( "NuGet-Package-Restore" )
55
+ . Does ( ( ) =>
56
+ {
57
+ if ( IsRunningOnUnix ( ) )
58
+ {
59
+ XBuild ( "./Source/Gep13.Cake.Sample.WebApplication.sln" , new XBuildSettings ( )
60
+ . SetConfiguration ( configuration )
61
+ . WithProperty ( "POSIX" , "True" )
62
+ . SetVerbosity ( Verbosity . Verbose )
63
+ ) ;
64
+ }
65
+ else
66
+ {
67
+ MSBuild ( "./src/GitVersion.sln" , new MSBuildSettings ( )
68
+ . SetConfiguration ( configuration )
69
+ . SetPlatformTarget ( PlatformTarget . MSIL )
70
+ . WithProperty ( "Windows" , "True" )
71
+ . UseToolVersion ( MSBuildToolVersion . VS2015 )
72
+ . SetVerbosity ( Verbosity . Minimal )
73
+ . SetNodeReuse ( false ) ) ;
74
+ }
75
+ } ) ;
76
+
77
+ Task ( "Run-NUnit-Tests" )
78
+ . IsDependentOn ( "Build" )
79
+ . Does ( ( ) =>
80
+ {
81
+ NUnit3 ( "src/*.Tests/bin/" + configuration + "/*.Tests.dll" ) ;
82
+ } ) ;
83
+
84
+ Task ( "Zip-Files" )
85
+ . IsDependentOn ( "Run-NUnit-Tests" )
86
+ . Does ( ( ) =>
87
+ {
88
+ var files = GetFiles ( "./build/NuGetCommandLineBuild/Tools/*.*" ) ;
89
+
90
+ Zip ( "./" , "GitVersion_" + nugetVersion + ".zip" , files ) ;
91
+
92
+ files = GetFiles ( "./build/GitVersionTfsTaskBuild/GitVersionTask/*.*" ) ;
93
+
94
+ Zip ( "./" , "GitVersionTfsBuildTask_" + nugetVersion + ".zip" , files ) ;
95
+ } ) ;
96
+
97
+ Task ( "Create-NuGet-Packages" )
98
+ . Does ( ( ) =>
99
+ {
100
+
101
+ } ) ;
102
+
103
+ Task ( "Create-Chocolatey-Packages" )
104
+ . Does ( ( ) =>
105
+ {
106
+
107
+ } ) ;
108
+
109
+ Task ( "Create-Release-Notes" )
110
+ . Does ( ( ) =>
111
+ {
112
+ //GitReleaseManagerCreate(parameters.GitHub.UserName, parameters.GitHub.Password, "cake-build", "cake", new GitReleaseManagerCreateSettings {
113
+ // Milestone = parameters.Version.Milestone,
114
+ // Name = parameters.Version.Milestone,
115
+ // Prerelease = true,
116
+ // TargetCommitish = "main"
117
+ //});
118
+ } ) ;
119
+
120
+ Task ( "Package" )
121
+ . IsDependentOn ( "Zip-Files" )
122
+ . IsDependentOn ( "Create-NuGet-Packages" )
123
+ . IsDependentOn ( "Create-Chocolatey-Packages" ) ;
124
+
125
+ Task ( "Upload-AppVeyor-Artifacts" )
126
+ . IsDependentOn ( "Package" )
127
+ . WithCriteria ( ( ) => BuildSystem . AppVeyor . IsRunningOnAppVeyor )
128
+ . Does ( ( ) =>
129
+ {
130
+ AppVeyor . UploadArtifact ( "build/NuGetExeBuild/GitVersion.Portable." + nugetVersion + ".nupkg" ) ;
131
+ AppVeyor . UploadArtifact ( "build/NuGetCommandLineBuild/GitVersion.CommandLine." + nugetVersion + ".nupkg" ) ;
132
+ AppVeyor . UploadArtifact ( "build/NuGetRefBuild/GitVersion." + nugetVersion + ".nupkg" ) ;
133
+ AppVeyor . UploadArtifact ( "build/NuGetTaskBuild/GitVersionTask." + nugetVersion + ".nupkg" ) ;
134
+ AppVeyor . UploadArtifact ( "build/GitVersionTfsTaskBuild/gittools.gitversion-" + semVersion + ".vsix" ) ;
135
+ AppVeyor . UploadArtifact ( "GitVersion_" + nugetVersion + ".zip" ) ;
136
+ AppVeyor . UploadArtifact ( "GitVersionTfsBuildTask_" + nugetVersion + ".zip" ) ;
137
+ } ) ;
138
+
139
+ Task ( "Publish-MyGet" )
140
+ . IsDependentOn ( "Package" )
141
+ . WithCriteria ( ( ) => ! BuildSystem . IsLocalBuild )
142
+ . WithCriteria ( ( ) => ! IsPullRequest )
143
+ . WithCriteria ( ( ) => IsMainGitVersionRepo )
144
+ . Does ( ( ) =>
145
+ {
146
+
147
+ } )
148
+ . OnError ( exception =>
149
+ {
150
+ Information ( "Publish-MyGet Task failed, but continuing with next Task..." ) ;
151
+ publishingError = true ;
152
+ } ) ;
153
+
154
+ Task ( "Publish-NuGet" )
155
+ . IsDependentOn ( "Package" )
156
+ . WithCriteria ( ( ) => ! BuildSystem . IsLocalBuild )
157
+ . WithCriteria ( ( ) => ! IsPullRequest )
158
+ . WithCriteria ( ( ) => IsMainGitVersionRepo )
159
+ . WithCriteria ( ( ) => IsTagged )
160
+ . Does ( ( ) =>
161
+ {
162
+
163
+ } )
164
+ . OnError ( exception =>
165
+ {
166
+ Information ( "Publish-NuGet Task failed, but continuing with next Task..." ) ;
167
+ publishingError = true ;
168
+ } ) ;
169
+
170
+ Task ( "Publish-Chocolatey" )
171
+ . IsDependentOn ( "Package" )
172
+ . WithCriteria ( ( ) => ! BuildSystem . IsLocalBuild )
173
+ . WithCriteria ( ( ) => ! IsPullRequest )
174
+ . WithCriteria ( ( ) => IsMainGitVersionRepo )
175
+ . WithCriteria ( ( ) => IsTagged )
176
+ . Does ( ( ) =>
177
+ {
178
+
179
+ } )
180
+ . OnError ( exception =>
181
+ {
182
+ Information ( "Publish-Chocolatey Task failed, but continuing with next Task..." ) ;
183
+ publishingError = true ;
184
+ } ) ;
185
+
186
+ Task ( "Publish-Gem" )
187
+ . IsDependentOn ( "Package" )
188
+ . WithCriteria ( ( ) => ! BuildSystem . IsLocalBuild )
189
+ . WithCriteria ( ( ) => ! IsPullRequest )
190
+ . WithCriteria ( ( ) => IsMainGitVersionRepo )
191
+ . WithCriteria ( ( ) => IsTagged )
192
+ . Does ( ( ) =>
193
+ {
194
+
195
+ } )
196
+ . OnError ( exception =>
197
+ {
198
+ Information ( "Publish-Gem Task failed, but continuing with next Task..." ) ;
199
+ publishingError = true ;
200
+ } ) ;
201
+
202
+ Task ( "Publish-GitHub-Release" )
203
+ . IsDependentOn ( "Package" )
204
+ . WithCriteria ( ( ) => ! BuildSystem . IsLocalBuild )
205
+ . WithCriteria ( ( ) => ! IsPullRequest )
206
+ . WithCriteria ( ( ) => IsMainGitVersionRepo )
207
+ . WithCriteria ( ( ) => IsTagged )
208
+ . Does ( ( ) =>
209
+ {
210
+
211
+ } )
212
+ . OnError ( exception =>
213
+ {
214
+ Information ( "Publish-GitHub-Release Task failed, but continuing with next Task..." ) ;
215
+ publishingError = true ;
216
+ } ) ;
217
+
218
+ Task ( "AppVeyor" )
219
+ . IsDependentOn ( "Upload-AppVeyor-Artifacts" )
220
+ . IsDependentOn ( "Publish-MyGet" )
221
+ . IsDependentOn ( "Publish-NuGet" )
222
+ . IsDependentOn ( "Publish-Chocolatey" )
223
+ . IsDependentOn ( "Publish-Gem" )
224
+ . IsDependentOn ( "Publish-GitHub-Release" )
225
+ . Finally ( ( ) =>
226
+ {
227
+ if ( publishingError )
228
+ {
229
+ throw new Exception ( "An error occurred during the publishing of Cake. All publishing tasks have been attempted." ) ;
230
+ }
231
+ } ) ;
232
+
233
+ Task ( "Travis" )
234
+ . IsDependentOn ( "Run-NUnit-Tests" ) ;
235
+
236
+ Task ( "ReleaseNotes" )
237
+ . IsDependentOn ( "Create-Release-Notes" ) ;
238
+
239
+ Task ( "Default" )
240
+ . IsDependentOn ( "Package" ) ;
241
+
242
+ RunTarget ( target ) ;
0 commit comments