@@ -69,6 +69,7 @@ function ParseMavenPackage($pkg, $workingDirectory) {
6969 PackageId = $pkgId
7070 GroupId = $groupId
7171 PackageVersion = $pkgVersion
72+ ReleaseTag = " $ ( $pkgId ) _$ ( $pkgVersion ) "
7273 Deployable = $forceCreate -or ! (IsMavenPackageVersionPublished - pkgId $pkgId - pkgVersion $pkgVersion - groupId $groupId.Replace (" ." , " /" ))
7374 ReleaseNotes = $releaseNotes
7475 ReadmeContent = $readmeContent
@@ -150,6 +151,7 @@ function ParseNPMPackage($pkg, $workingDirectory) {
150151 $resultObj = New-Object PSObject - Property @ {
151152 PackageId = $pkgId
152153 PackageVersion = $pkgVersion
154+ ReleaseTag = " $ ( $pkgId ) _$ ( $pkgVersion ) "
153155 Deployable = $forceCreate -or ! (IsNPMPackageVersionPublished - pkgId $pkgId - pkgVersion $pkgVersion )
154156 ReleaseNotes = $releaseNotes
155157 ReadmeContent = $readmeContent
@@ -208,6 +210,7 @@ function ParseNugetPackage($pkg, $workingDirectory) {
208210 return New-Object PSObject - Property @ {
209211 PackageId = $pkgId
210212 PackageVersion = $pkgVersion
213+ ReleaseTag = " $ ( $pkgId ) _$ ( $pkgVersion ) "
211214 Deployable = $forceCreate -or ! (IsNugetPackageVersionPublished - pkgId $pkgId - pkgVersion $pkgVersion )
212215 ReleaseNotes = $releaseNotes
213216 ReadmeContent = $readmeContent
@@ -272,6 +275,7 @@ function ParsePyPIPackage($pkg, $workingDirectory) {
272275 return New-Object PSObject - Property @ {
273276 PackageId = $pkgId
274277 PackageVersion = $pkgVersion
278+ ReleaseTag = " $ ( $pkgId ) _$ ( $pkgVersion ) "
275279 Deployable = $forceCreate -or ! (IsPythonPackageVersionPublished - pkgId $pkgId - pkgVersion $pkgVersion )
276280 ReleaseNotes = $releaseNotes
277281 ReadmeContent = $readmeContent
@@ -300,6 +304,7 @@ function ParseCArtifact($pkg, $workingDirectory) {
300304 return New-Object PSObject - Property @ {
301305 PackageId = ' '
302306 PackageVersion = $pkgVersion
307+ ReleaseTag = $pkgVersion
303308 # Artifact info is always considered deployable for C becasue it is not
304309 # deployed anywhere. Dealing with duplicate tags happens downstream in
305310 # CheckArtifactShaAgainstTagsList
@@ -331,6 +336,7 @@ function ParseCppArtifact($pkg, $workingDirectory) {
331336 return New-Object PSObject - Property @ {
332337 PackageId = $pkgName
333338 PackageVersion = $pkgVersion
339+ ReleaseTag = " $ ( $pkgId ) _$ ( $pkgVersion ) "
334340 # Artifact info is always considered deployable for now becasue it is not
335341 # deployed anywhere. Dealing with duplicate tags happens downstream in
336342 # CheckArtifactShaAgainstTagsList
@@ -387,52 +393,84 @@ function GetExistingTags($apiUrl) {
387393 }
388394}
389395
390- # Walk across all build artifacts, check them against the appropriate repository, return a list of tags/releases
391- function VerifyPackages ($pkgRepository , $artifactLocation , $workingDirectory , $apiUrl , $releaseSha , $continueOnError = $false ) {
392- $pkgList = [array ]@ ()
393- $ParsePkgInfoFn = " "
396+ # Retrieve release tag for artiface package. If multiple packages, then output the first one.
397+ function RetrieveReleaseTag ($pkgRepository , $artifactLocation , $continueOnError = $true ) {
398+ if (! $artifactLocation ) {
399+ return " "
400+ }
401+ try {
402+ $pkgs , $parsePkgInfoFn = RetrievePackages - pkgRepository $pkgRepository - artifactLocation $artifactLocation
403+ if (! $pkgs -or ! $pkgs [0 ]) {
404+ Write-Host " No packages retrieved from artifact location."
405+ return " "
406+ }
407+ if ($pkgs.Count -gt 1 ) {
408+ Write-Host " There are more than 1 packages retieved from artifact location."
409+ foreach ($pkg in $pkgs ) {
410+ Write-Host " The package name is $ ( $pkg.BaseName ) "
411+ }
412+ return " "
413+ }
414+ $parsedPackage = & $parsePkgInfoFn - pkg $pkgs [0 ] - workingDirectory $artifactLocation
415+ return $parsedPackage.ReleaseTag
416+ }
417+ catch {
418+ if ($continueOnError ) {
419+ return " "
420+ }
421+ Write-Error " No release tag retrieved from $artifactLocation "
422+ }
423+ }
424+ function RetrievePackages ($pkgRepository , $artifactLocation ) {
425+ $parsePkgInfoFn = " "
394426 $packagePattern = " "
395-
427+ $pkgRepository = $pkgRepository .Trim ()
396428 switch ($pkgRepository ) {
397429 " Maven" {
398- $ParsePkgInfoFn = " ParseMavenPackage"
430+ $parsePkgInfoFn = " ParseMavenPackage"
399431 $packagePattern = " *.pom"
400432 break
401433 }
402434 " Nuget" {
403- $ParsePkgInfoFn = " ParseNugetPackage"
435+ $parsePkgInfoFn = " ParseNugetPackage"
404436 $packagePattern = " *.nupkg"
405437 break
406438 }
407439 " NPM" {
408- $ParsePkgInfoFn = " ParseNPMPackage"
440+ $parsePkgInfoFn = " ParseNPMPackage"
409441 $packagePattern = " *.tgz"
410442 break
411443 }
412444 " PyPI" {
413- $ParsePkgInfoFn = " ParsePyPIPackage"
445+ $parsePkgInfoFn = " ParsePyPIPackage"
414446 $packagePattern = " *.zip"
415447 break
416448 }
417449 " C" {
418- $ParsePkgInfoFn = " ParseCArtifact"
450+ $parsePkgInfoFn = " ParseCArtifact"
419451 $packagePattern = " *.json"
420452 }
421453 " CPP" {
422- $ParsePkgInfoFn = " ParseCppArtifact"
454+ $parsePkgInfoFn = " ParseCppArtifact"
423455 $packagePattern = " *.json"
424456 }
425457 default {
426458 Write-Host " Unrecognized Language: $language "
427459 exit (1 )
428460 }
429461 }
462+ $pkgs = Get-ChildItem - Path $artifactLocation - Include $packagePattern - Recurse - File
463+ return $pkgs , $parsePkgInfoFn
464+ }
430465
431- $pkgs = (Get-ChildItem - Path $artifactLocation - Include $packagePattern - Recurse - File)
466+ # Walk across all build artifacts, check them against the appropriate repository, return a list of tags/releases
467+ function VerifyPackages ($pkgRepository , $artifactLocation , $workingDirectory , $apiUrl , $releaseSha , $continueOnError = $false ) {
468+ $pkgList = [array ]@ ()
469+ $pkgs , $parsePkgInfoFn = RetrievePackages - pkgRepository $pkgRepository - artifactLocation $artifactLocation
432470
433471 foreach ($pkg in $pkgs ) {
434472 try {
435- $parsedPackage = & $ParsePkgInfoFn - pkg $pkg - workingDirectory $workingDirectory
473+ $parsedPackage = & $parsePkgInfoFn - pkg $pkg - workingDirectory $workingDirectory
436474
437475 if ($parsedPackage -eq $null ) {
438476 continue
@@ -444,17 +482,11 @@ function VerifyPackages($pkgRepository, $artifactLocation, $workingDirectory, $a
444482 exit (1 )
445483 }
446484
447- $tag = if ($parsedPackage.packageId ) {
448- " $ ( $parsedPackage.packageId ) _$ ( $parsedPackage.PackageVersion ) "
449- } else {
450- $parsedPackage.PackageVersion
451- }
452-
453485 $pkgList += New-Object PSObject - Property @ {
454486 PackageId = $parsedPackage.PackageId
455487 PackageVersion = $parsedPackage.PackageVersion
456488 GroupId = $parsedPackage.GroupId
457- Tag = $tag
489+ Tag = $parsedPackage .ReleaseTag
458490 ReleaseNotes = $parsedPackage.ReleaseNotes
459491 ReadmeContent = $parsedPackage.ReadmeContent
460492 IsPrerelease = [AzureEngSemanticVersion ]::ParseVersionString($parsedPackage.PackageVersion ).IsPrerelease
@@ -511,4 +543,4 @@ function CheckArtifactShaAgainstTagsList($priorExistingTagList, $releaseSha, $ap
511543 Write-Host " Tags already existing with different SHA versions. Exiting."
512544 exit (1 )
513545 }
514- }
546+ }
0 commit comments