1
- #tool "nuget:?package=GitVersion.CommandLine"
2
1
#tool "nuget:?package=NUnit.ConsoleRunner"
2
+ #tool "nuget:?package=GitReleaseNotes"
3
3
4
4
var target = Argument ( "target" , "Default" ) ;
5
5
var configuration = Argument ( "configuration" , "Release" ) ;
@@ -15,26 +15,60 @@ bool IsTagged = (BuildSystem.AppVeyor.Environment.Repository.Tag.IsTag &&
15
15
bool IsMainGitVersionRepo = StringComparer . OrdinalIgnoreCase . Equals ( "gittools/gitversion" , BuildSystem . AppVeyor . Environment . Repository . Name ) ;
16
16
bool IsPullRequest = BuildSystem . AppVeyor . Environment . PullRequest . IsPullRequest ;
17
17
18
- Setup ( context =>
18
+ void Build ( )
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
+ }
28
+ else
29
+ {
30
+ MSBuild ( "./src/GitVersion.sln" , new MSBuildSettings ( )
31
+ . SetConfiguration ( configuration )
32
+ . SetPlatformTarget ( PlatformTarget . MSIL )
33
+ . WithProperty ( "Windows" , "True" )
34
+ . UseToolVersion ( MSBuildToolVersion . VS2015 )
35
+ . SetVerbosity ( Verbosity . Minimal )
36
+ . SetNodeReuse ( false ) ) ;
37
+ }
38
+ }
39
+
40
+ Task ( "DogfoodBuild" )
41
+ . IsDependentOn ( "NuGet-Package-Restore" )
42
+ . Does ( ( ) =>
43
+ {
44
+ Build ( ) ;
45
+ } ) ;
46
+
47
+ Task ( "Version" )
48
+ . IsDependentOn ( "DogfoodBuild" )
49
+ . Does ( ( ) =>
19
50
{
20
51
if ( ! BuildSystem . IsLocalBuild )
21
52
{
22
- GitVersion ( new GitVersionSettings {
53
+ GitVersion ( new GitVersionSettings
54
+ {
23
55
UpdateAssemblyInfo = true ,
24
56
LogFilePath = "console" ,
25
- OutputType = GitVersionOutput . BuildServer
57
+ OutputType = GitVersionOutput . BuildServer ,
58
+ ToolPath = @"src\GitVersionExe\bin\Release\GitVersion.exe"
26
59
} ) ;
27
60
28
- version = context . EnvironmentVariable ( "GitVersion_MajorMinorPatch" ) ;
29
- nugetVersion = context . EnvironmentVariable ( "GitVersion_NuGetVersion" ) ;
30
- preReleaseTag = context . EnvironmentVariable ( "GitVersion_PreReleaseTag" ) ;
31
- semVersion = context . EnvironmentVariable ( "GitVersion_LegacySemVerPadded" ) ;
61
+ version = EnvironmentVariable ( "GitVersion_MajorMinorPatch" ) ;
62
+ nugetVersion = EnvironmentVariable ( "GitVersion_NuGetVersion" ) ;
63
+ preReleaseTag = EnvironmentVariable ( "GitVersion_PreReleaseTag" ) ;
64
+ semVersion = EnvironmentVariable ( "GitVersion_LegacySemVerPadded" ) ;
32
65
milestone = string . Concat ( "v" , version ) ;
33
66
}
34
67
35
68
GitVersion assertedVersions = GitVersion ( new GitVersionSettings
36
69
{
37
- OutputType = GitVersionOutput . Json
70
+ OutputType = GitVersionOutput . Json ,
71
+ ToolPath = @"src\GitVersionExe\bin\Release\GitVersion.exe"
38
72
} ) ;
39
73
40
74
version = assertedVersions . MajorMinorPatch ;
@@ -51,27 +85,11 @@ Task("NuGet-Package-Restore")
51
85
} ) ;
52
86
53
87
Task ( "Build" )
88
+ . IsDependentOn ( "Version" )
54
89
. IsDependentOn ( "NuGet-Package-Restore" )
55
90
. Does ( ( ) =>
56
91
{
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
- }
92
+ Build ( ) ;
75
93
} ) ;
76
94
77
95
Task ( "Run-NUnit-Tests" )
@@ -85,150 +103,48 @@ Task("Zip-Files")
85
103
. IsDependentOn ( "Run-NUnit-Tests" )
86
104
. Does ( ( ) =>
87
105
{
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
-
106
+ Zip ( "./build/NuGetCommandLineBuild/Tools/" , "GitVersion_" + nugetVersion + ".zip" ) ;
107
107
} ) ;
108
108
109
109
Task ( "Create-Release-Notes" )
110
110
. Does ( ( ) =>
111
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
- //});
112
+ var releaseNotesExitCode = StartProcess (
113
+ @"tools\GitReleaseNotes\tools\gitreleasenotes.exe" ,
114
+ new ProcessSettings { Arguments = ". /o artifacts/releasenotes.md" } ) ;
115
+ if ( string . IsNullOrEmpty ( System . IO . File . ReadAllText ( "./artifacts/releasenotes.md" ) ) )
116
+ System . IO . File . WriteAllText ( "./build/releasenotes.md" , "No issues closed since last release" ) ;
117
+
118
+ if ( releaseNotesExitCode != 0 ) throw new Exception ( "Failed to generate release notes" ) ;
118
119
} ) ;
119
120
120
121
Task ( "Package" )
121
- . IsDependentOn ( "Zip-Files" )
122
- . IsDependentOn ( "Create-NuGet-Packages" )
123
- . IsDependentOn ( "Create-Chocolatey-Packages" ) ;
122
+ . IsDependentOn ( "Zip-Files" ) ;
124
123
125
124
Task ( "Upload-AppVeyor-Artifacts" )
126
125
. IsDependentOn ( "Package" )
127
126
. WithCriteria ( ( ) => BuildSystem . AppVeyor . IsRunningOnAppVeyor )
128
127
. Does ( ( ) =>
129
128
{
129
+ System . IO . File . WriteAllLines ( outputDir + "artifacts" , new [ ] {
130
+ "NuGetExeBuild:GitVersion.Portable." + nugetVersion + ".nupkg" ,
131
+ "NuGetCommandLineBuild:GitVersion.CommandLine." + nugetVersion + ".nupkg" ,
132
+ "NuGetRefBuild:GitVersion." + nugetVersion + ".nupkg" ,
133
+ "NuGetTaskBuild:GitVersionTask." + nugetVersion + ".nupkg" ,
134
+ "NuGetExeBuild:GitVersion.Portable." + nugetVersion + ".nupkg" ,
135
+ "zip:GitVersion_" + nugetVersion + ".zip" ,
136
+ "releaseNotes:releasenotes.md"
137
+ } ) ;
138
+
130
139
AppVeyor . UploadArtifact ( "build/NuGetExeBuild/GitVersion.Portable." + nugetVersion + ".nupkg" ) ;
131
140
AppVeyor . UploadArtifact ( "build/NuGetCommandLineBuild/GitVersion.CommandLine." + nugetVersion + ".nupkg" ) ;
132
141
AppVeyor . UploadArtifact ( "build/NuGetRefBuild/GitVersion." + nugetVersion + ".nupkg" ) ;
133
142
AppVeyor . UploadArtifact ( "build/NuGetTaskBuild/GitVersionTask." + nugetVersion + ".nupkg" ) ;
134
143
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 ;
144
+ AppVeyor . UploadArtifact ( "build/GitVersion_" + nugetVersion + ".zip" ) ;
145
+ AppVeyor . UploadArtifact ( "build/GitVersionTfsBuildTask_" + nugetVersion + ".zip" ) ;
216
146
} ) ;
217
147
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
148
233
149
Task ( "Travis" )
234
150
. IsDependentOn ( "Run-NUnit-Tests" ) ;
@@ -237,6 +153,7 @@ Task("ReleaseNotes")
237
153
. IsDependentOn ( "Create-Release-Notes" ) ;
238
154
239
155
Task ( "Default" )
240
- . IsDependentOn ( "Package" ) ;
156
+ . IsDependentOn ( "Package" )
157
+ . IsDependentOn ( "Upload-AppVeyor-Artifacts" ) ;
241
158
242
159
RunTarget ( target ) ;
0 commit comments