@@ -216,34 +216,36 @@ stages:
216216 $xml = [Xml] (Get-Content .\src\Microsoft.OpenApi.Hidi\Microsoft.OpenApi.Hidi.csproj)
217217 $version = $xml.Project.PropertyGroup.Version
218218 echo $version
219- echo "##vso[task.setvariable variable=version ]$version"
219+ echo "##vso[task.setvariable variable=hidiversion ]$version"
220220
221221 # publish hidi as an .exe
222222 - task : DotNetCoreCLI@2
223+ displayName : publish Hidi as executable
223224 inputs :
224225 command : ' publish'
225- arguments : -c Release --runtime win-x64 /p:PublishSingleFile=true --self-contained --output $(Build.ArtifactStagingDirectory)/Microsoft.OpenApi.Hidi-v$(version ) --no-dependencies
226+ arguments : -c Release --runtime win-x64 /p:PublishSingleFile=true --self-contained --output $(Build.ArtifactStagingDirectory)/Microsoft.OpenApi.Hidi-v$(hidiversion ) --no-dependencies
226227 projects : ' src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj'
227228 publishWebProjects : False
228229 zipAfterPublish : false
229230
230- - task : PublishBuildArtifacts@1
231- displayName : ' Publish Artifact: Hidi'
232- inputs :
233- ArtifactName : Microsoft.OpenApi.Hidi-v$(version)
234- PathtoPublish : ' $(Build.ArtifactStagingDirectory)/Microsoft.OpenApi.Hidi-v$(version)'
235-
236231 - task : PublishBuildArtifacts@1
237232 displayName : ' Publish Artifact: Nugets'
238233 inputs :
239234 ArtifactName : Nugets
240235 PathtoPublish : ' $(Build.ArtifactStagingDirectory)/Nugets'
241236
237+ - task : PublishBuildArtifacts@1
238+ displayName : ' Publish Artifact: Hidi'
239+ inputs :
240+ ArtifactName : Microsoft.OpenApi.Hidi-v$(hidiversion)
241+ PathtoPublish : ' $(Build.ArtifactStagingDirectory)/Microsoft.OpenApi.Hidi-v$(hidiversion)'
242+
242243- stage : deploy
243244 condition : and(contains(variables['build.sourceBranch'], 'refs/heads/vnext'), succeeded())
244245 dependsOn : build
245246 jobs :
246- - deployment : deploy
247+ - deployment : deploy_hidi
248+ dependsOn : []
247249 environment : nuget-org
248250 strategy :
249251 runOnce :
@@ -256,10 +258,88 @@ stages:
256258 inputs :
257259 artifact : Nugets
258260 source : current
261+ # TODO update that script so it looks at the artifact name (name starts with) rather than a fixed index
262+ - powershell : |
263+ $url = "$($env:SYSTEM_TEAMFOUNDATIONCOLLECTIONURI)$env:SYSTEM_TEAMPROJECTID/_apis/build/builds/$env:BUILD_BUILDID/artifacts?api-version=4.1"
264+ Write-Host "URL: $url"
265+ $pipeline = Invoke-RestMethod -Uri $url -Headers @{
266+ Authorization = "Bearer $env:SYSTEM_ACCESSTOKEN"
267+ }
268+ Write-Host "artifactName:" ($artifactName = $Pipeline.value.name[1])
269+ #Set Variable $artifactName
270+ Write-Host "##vso[task.setvariable variable=artifactName; isSecret=false; isOutput=true;]$artifactName"
271+ displayName: 'Fetch Artifact Name'
272+ - task : DownloadPipelineArtifact@2
273+ displayName : Download hidi executable from artifacts
274+ inputs :
275+ artifact : $(artifactName)
276+ source : current
277+ - task : NuGetCommand@2
278+ displayName : ' NuGet push'
279+ inputs :
280+ command : push
281+ packagesToPush : ' $(Pipeline.Workspace)/Nugets/Microsoft.OpenApi.Hidi.*.nupkg'
282+ nuGetFeedType : external
283+ publishFeedCredentials : ' OpenAPI Nuget Connection'
284+ - task : GitHubRelease@1
285+ displayName : ' GitHub release (create)'
286+ inputs :
287+ gitHubConnection : ' Github-MaggieKimani1'
288+ tagSource : userSpecifiedTag
289+ tag : ' $(artifactName)'
290+ title : ' $(artifactName)'
291+ releaseNotesSource : inline
292+ assets : ' $(System.DefaultWorkingDirectory)\**\*.exe'
293+ changeLogType : issueBased
294+
295+ - deployment : deploy_lib
296+ dependsOn : []
297+ environment : nuget-org
298+ strategy :
299+ runOnce :
300+ deploy :
301+ pool :
302+ vmImage : ubuntu-latest
303+ steps :
304+ - task : DownloadPipelineArtifact@2
305+ displayName : Download nupkg from artifacts
306+ inputs :
307+ artifact : Nugets
308+ source : current
309+ - powershell : |
310+ $fileNames = "$(Pipeline.Workspace)/Nugets/Microsoft.OpenApi.Hidi.*.nupkg", "$(Pipeline.Workspace)/Nugets/Microsoft.OpenApi.Readers.*.nupkg", "$(Pipeline.Workspace)/Nugets/Microsoft.OpenApi.Workbench.*.nupkg"
311+ foreach($fileName in $fileNames) {
312+ if(Test-Path $fileName) {
313+ rm $fileName -Verbose
314+ }
315+ }
316+ displayName: remove other nupkgs to avoid duplication
259317 - task : NuGetCommand@2
260318 displayName : ' NuGet push'
261319 inputs :
262320 command : push
263321 packagesToPush : ' $(Pipeline.Workspace)/Nugets/Microsoft.OpenApi.*.nupkg'
264322 nuGetFeedType : external
265323 publishFeedCredentials : ' OpenAPI Nuget Connection'
324+
325+ - deployment : deploy_readers
326+ dependsOn : deploy_lib
327+ environment : nuget-org
328+ strategy :
329+ runOnce :
330+ deploy :
331+ pool :
332+ vmImage : ubuntu-latest
333+ steps :
334+ - task : DownloadPipelineArtifact@2
335+ displayName : Download nupkg from artifacts
336+ inputs :
337+ artifact : Nugets
338+ source : current
339+ - task : NuGetCommand@2
340+ displayName : ' NuGet push'
341+ inputs :
342+ command : push
343+ packagesToPush : ' $(Pipeline.Workspace)/Nugets/Microsoft.OpenApi.Readers.*.nupkg'
344+ nuGetFeedType : external
345+ publishFeedCredentials : ' OpenAPI Nuget Connection'
0 commit comments