@@ -11,7 +11,7 @@ trigger:
1111 - support/v2
1212 tags :
1313 include :
14- - ' v *'
14+ - ' v3. *'
1515pr :
1616 branches :
1717 include :
@@ -56,6 +56,18 @@ extends:
5656 targetPath : ' $(Build.ArtifactStagingDirectory)'
5757 steps :
5858
59+ - pwsh : |
60+ $ErrorActionPreference = 'Stop'
61+ $version = ([xml](Get-Content Directory.Build.props)).Project.PropertyGroup.Version
62+ if ($env:BUILD_SOURCEBRANCH -like 'refs/tags/*') {
63+ if ($env:BUILD_SOURCEBRANCH -cnotmatch '^refs/tags/v(3\.\d+\.\d+(?:-[0-9A-Za-z]+(?:[.-][0-9A-Za-z]+)*)?)$') {
64+ throw "Expected an OData v3.x release tag, got $env:BUILD_SOURCEBRANCH."
65+ }
66+ if ($Matches[1] -cne $version) { throw "OData tag must exactly match Directory.Build.props version $version." }
67+ }
68+ Write-Host "##vso[task.setvariable variable=ODataVersion]$version"
69+ displayName: 'Validate OData component tag and project version'
70+
5971 - task : UseDotNet@2
6072 displayName : ' Use .NET 6' # needed for ESRP signing
6173 inputs :
@@ -173,8 +185,13 @@ extends:
173185 displayName : ' pack'
174186 inputs :
175187 command : pack
176- projects : src/Microsoft.OpenApi.OData.Reader/Microsoft.OpenAPI.OData.Reader.csproj
177- arguments : ' -o $(Build.ArtifactStagingDirectory) --configuration $(BuildConfiguration) --no-build --include-symbols --include-source /p:SymbolPackageFormat=snupkg'
188+ packagesToPack : src/Microsoft.OpenApi.OData.Reader/Microsoft.OpenAPI.OData.Reader.csproj
189+ configuration : ' $(BuildConfiguration)'
190+ packDirectory : ' $(Build.ArtifactStagingDirectory)'
191+ nobuild : true
192+ includesymbols : true
193+ includesource : true
194+ buildProperties : ' SymbolPackageFormat=snupkg'
178195
179196 - task : EsrpCodeSigning@6
180197 displayName : ' ESRP CodeSigning Nuget Packages'
@@ -186,7 +203,7 @@ extends:
186203 AuthAKVName : ' akv-prod-eastus'
187204 AuthCertName : ' ReferenceLibraryPrivateCert'
188205 AuthSignCertName : ' ReferencePackagePublisherCertificate'
189- Pattern : ' * .nupkg'
206+ Pattern : ' Microsoft.OpenApi.OData.$(ODataVersion) .nupkg'
190207 signConfigType : inlineSignParams
191208 inlineOperation : |
192209 [
@@ -211,7 +228,7 @@ extends:
211228 PendingAnalysisWaitTimeoutMinutes : ' 5'
212229
213230 - stage : deploy
214- condition : and(contains( variables['build.sourceBranch '], 'refs/tags/v'), succeeded( ))
231+ condition : and(succeeded(), startsWith( variables['Build.SourceBranch '], 'refs/tags/v3.' ))
215232 dependsOn : build
216233 jobs :
217234 - deployment : deploy
@@ -229,10 +246,20 @@ extends:
229246 pool :
230247 vmImage : ubuntu-latest
231248 steps :
249+ - pwsh : |
250+ $ErrorActionPreference = 'Stop'
251+ if ($env:BUILD_SOURCEBRANCH -cnotmatch '^refs/tags/v(3\.\d+\.\d+(?:-[0-9A-Za-z]+(?:[.-][0-9A-Za-z]+)*)?)$') {
252+ throw "Expected an OData v3.x release tag, got $env:BUILD_SOURCEBRANCH."
253+ }
254+ $version = $Matches[1]
255+ $packages = @(Get-ChildItem -LiteralPath '$(Pipeline.Workspace)' -Recurse -File -Filter "Microsoft.OpenApi.OData.$version.nupkg")
256+ if ($packages.Count -ne 1) { throw "Expected exactly one OData package matching tag version $version." }
257+ Write-Host "##vso[task.setvariable variable=ODataPackagePath]$($packages[0].FullName)"
258+ displayName: 'Verify exact OData release package'
232259 - task : 1ES.PublishNuget@1
233260 displayName : ' NuGet push'
234261 inputs :
235- packagesToPush : ' $(Pipeline.Workspace)/Microsoft.OpenApi.OData.*.nupkg '
262+ packagesToPush : ' $(ODataPackagePath) '
236263 nuGetFeedType : external
237264 publishFeedCredentials : ' OpenAPI Nuget Connection'
238265 packageParentPath : ' $(Pipeline.Workspace)'
@@ -254,21 +281,25 @@ extends:
254281 vmImage : ubuntu-latest
255282 steps :
256283 - pwsh : |
257- $artifactName = Get-ChildItem -Path $(Pipeline.Workspace) -Filter Microsoft.OpenApi.OData.*.nupkg -recurse | select -First 1
258- $artifactVersion= $artifactName.Name -replace "Microsoft.OpenApi.OData.", "" -replace ".nupkg", ""
259- #Set Variable $artifactName and $artifactVersion
260- Write-Host "##vso[task.setvariable variable=artifactVersion; isSecret=false;]$artifactVersion"
261- echo "$artifactVersion"
262- displayName: 'Fetch Artifact Name'
284+ $ErrorActionPreference = 'Stop'
285+ if ($env:BUILD_SOURCEBRANCH -cnotmatch '^refs/tags/v(3\.\d+\.\d+(?:-[0-9A-Za-z]+(?:[.-][0-9A-Za-z]+)*)?)$') {
286+ throw "Expected an OData v3.x release tag, got $env:BUILD_SOURCEBRANCH."
287+ }
288+ $version = $Matches[1]
289+ $packages = @(Get-ChildItem -LiteralPath '$(Pipeline.Workspace)' -Recurse -File -Filter "Microsoft.OpenApi.OData.$version.nupkg")
290+ if ($packages.Count -ne 1) { throw "Expected exactly one OData package matching tag version $version." }
291+ Write-Host "##vso[task.setvariable variable=ODataReleaseVersion]$version"
292+ Write-Host "##vso[task.setvariable variable=ODataPackagePath]$($packages[0].FullName)"
293+ displayName: 'Verify OData tag and exact GitHub release asset'
263294 - task : GitHubRelease@1
264295 displayName : ' GitHub release'
265- condition : succeededOrFailed ()
296+ condition : succeeded ()
266297 inputs :
267298 gitHubConnection : ' Github-MaggieKimani1'
268299 action : edit
269300 tagSource : userSpecifiedTag
270- tag : ' v$(artifactVersion )'
271- title : ' v$(artifactVersion )'
301+ tag : ' v$(ODataReleaseVersion )'
302+ title : ' v$(ODataReleaseVersion )'
272303 releaseNotesSource : inline
273- assets : ' $(Pipeline.Workspace)\**\Microsoft.OpenApi.OData.*.nupkg '
304+ assets : ' $(ODataPackagePath) '
274305 addChangeLog : false
0 commit comments