@@ -71,6 +71,7 @@ Task("DownloadGitHubReleaseArtifacts")
71
71
if ( ! artifactLookup . ContainsKey ( "NuGetExeBuild" ) ) { throw new Exception ( "NuGetExeBuild artifact missing" ) ; }
72
72
if ( ! artifactLookup . ContainsKey ( "GemBuild" ) ) { throw new Exception ( "GemBuild artifact missing" ) ; }
73
73
if ( ! artifactLookup . ContainsKey ( "GitVersionTfsTaskBuild" ) ) { throw new Exception ( "GitVersionTfsTaskBuild artifact missing" ) ; }
74
+ if ( ! artifactLookup . ContainsKey ( "zip" ) ) { throw new Exception ( "zip artifact missing" ) ; }
74
75
} ) ;
75
76
76
77
Task ( "Publish-NuGetPackage" )
@@ -174,13 +175,59 @@ Task("Publish-VstsTask")
174
175
}
175
176
} ) ;
176
177
178
+
179
+ Task ( "Publish-DockerImage" )
180
+ . IsDependentOn ( "DownloadGitHubReleaseArtifacts" )
181
+ . Does ( ( ) =>
182
+ {
183
+ var returnCode = StartProcess ( "docker" , new ProcessSettings
184
+ {
185
+ Arguments = "build . --build-arg GitVersionZip=" + artifactLookup [ "zip" ] + " --tag gittools/gitversion"
186
+ } ) ;
187
+ if ( returnCode != 0 ) {
188
+ Information ( "Publish-DockerImage Task failed to build image, but continuing with next Task..." ) ;
189
+ publishingError = true ;
190
+ }
191
+
192
+ // Login to dockerhub
193
+ returnCode = StartProcess ( "docker" , new ProcessSettings
194
+ {
195
+ Arguments = "login -u=\" " + EnvironmentVariable ( "DOCKER_USERNAME" ) + "\" -p=\" " + EnvironmentVariable ( "DOCKER_PASSWORD" ) + "\" "
196
+ } ) ;
197
+ if ( returnCode != 0 ) {
198
+ Information ( "Publish-DockerImage Task failed to login, but continuing with next Task..." ) ;
199
+ publishingError = true ;
200
+ }
201
+
202
+ // Publish Tag
203
+ returnCode = StartProcess ( "docker" , new ProcessSettings
204
+ {
205
+ Arguments = "push gittools/gitversion:" + tag
206
+ } ) ;
207
+ if ( returnCode != 0 ) {
208
+ Information ( "Publish-DockerImage Task failed push version tag, but continuing with next Task..." ) ;
209
+ publishingError = true ;
210
+ }
211
+
212
+ // Publish latest
213
+ returnCode = StartProcess ( "docker" , new ProcessSettings
214
+ {
215
+ Arguments = "push gittools/gitversion:latest"
216
+ } ) ;
217
+ if ( returnCode != 0 ) {
218
+ Information ( "Publish-DockerImage Task failed latest tag, but continuing with next Task..." ) ;
219
+ publishingError = true ;
220
+ }
221
+ } ) ;
222
+
177
223
Task ( "Deploy" )
178
224
. IsDependentOn ( "Publish-NuGetPackage" )
179
225
. IsDependentOn ( "Publish-NuGetCommandLine" )
180
226
. IsDependentOn ( "Publish-MsBuildTask" )
181
227
. IsDependentOn ( "Publish-Chocolatey" )
182
228
// .IsDependentOn("Publish-Gem")
183
229
. IsDependentOn ( "Publish-VstsTask" )
230
+ . IsDependentOn ( "Publish-DockerImage" )
184
231
. Finally ( ( ) =>
185
232
{
186
233
if ( publishingError )
0 commit comments