Compare commits

..

10 Commits

Author SHA1 Message Date
ray chen
705832762f Used the original BuildHashKey to return hash from non-null args 2025-12-08 19:38:36 +00:00
ray chen
a3c8483cdb Build hash key with non-null arguments 2025-12-08 19:38:36 +00:00
ray chen
e699d11db0 Removed the condition check for Group 2025-12-08 19:38:36 +00:00
ray chen
1dc34d1633 Renamed new property to GroupId 2025-12-08 19:38:36 +00:00
ray chen
13d95d3a46 Updated script to process groupId in work items 2025-12-08 19:38:36 +00:00
ray chen
e10992a7d4 Reverted changes to verify-changelog.yml and script 2025-12-08 19:38:36 +00:00
ray chen
5f2ab2f337 Pass in package info file path 2025-12-08 19:38:36 +00:00
ray chen
8ba2425b96 Added test 2025-12-08 19:38:36 +00:00
ray chen
621e2a905c Used full pkg name for dev ops work item 2025-12-08 19:38:36 +00:00
ray chen
6b28105085 Used full pkg name in release work items 2025-12-08 19:38:36 +00:00
5 changed files with 110 additions and 34 deletions

View File

@ -215,16 +215,17 @@ function FindParentWorkItem($serviceName, $packageDisplayName, $outputCommand =
$packageWorkItems = @{}
$packageWorkItemWithoutKeyFields = @{}
function FindLatestPackageWorkItem($lang, $packageName, $outputCommand = $true, $ignoreReleasePlannerTests = $true, $tag = $null)
function FindLatestPackageWorkItem($lang, $packageName, $groupId = $null, $outputCommand = $true, $ignoreReleasePlannerTests = $true, $tag = $null)
{
# Cache all the versions of this package and language work items
$null = FindPackageWorkItem $lang $packageName -includeClosed $true -outputCommand $outputCommand -ignoreReleasePlannerTests $ignoreReleasePlannerTests -tag $tag
$null = FindPackageWorkItem $lang $packageName -includeClosed $true -outputCommand $outputCommand -ignoreReleasePlannerTests $ignoreReleasePlannerTests -tag $tag -groupId $groupId
$latestWI = $null
foreach ($wi in $packageWorkItems.Values)
{
if ($wi.fields["Custom.Language"] -ne $lang) { continue }
if ($wi.fields["Custom.Package"] -ne $packageName) { continue }
if ($groupId -and $wi.fields["Custom.GroupId"] -ne $groupId) { continue }
if (!$latestWI) {
$latestWI = $wi
@ -238,9 +239,9 @@ function FindLatestPackageWorkItem($lang, $packageName, $outputCommand = $true,
return $latestWI
}
function FindPackageWorkItem($lang, $packageName, $version, $outputCommand = $true, $includeClosed = $false, $ignoreReleasePlannerTests = $true, $tag = $null)
function FindPackageWorkItem($lang, $packageName, $version, $groupId = $null, $outputCommand = $true, $includeClosed = $false, $ignoreReleasePlannerTests = $true, $tag = $null)
{
$key = BuildHashKeyNoNull $lang $packageName $version
$key = BuildHashKey $lang $packageName $version $groupId
if ($key -and $packageWorkItems.ContainsKey($key)) {
return $packageWorkItems[$key]
}
@ -253,6 +254,7 @@ function FindPackageWorkItem($lang, $packageName, $version, $outputCommand = $tr
$fields += "System.Tags"
$fields += "Custom.Language"
$fields += "Custom.Package"
$fields += "Custom.GroupId"
$fields += "Custom.PackageDisplayName"
$fields += "System.Title"
$fields += "Custom.PackageType"
@ -282,6 +284,9 @@ function FindPackageWorkItem($lang, $packageName, $version, $outputCommand = $tr
if ($packageName) {
$query += " AND [Package] = '${packageName}'"
}
if ($groupId) {
$query += " AND [GroupId] = '${groupId}'"
}
if ($version) {
$query += " AND [PackageVersionMajorMinor] = '${version}'"
}
@ -295,7 +300,7 @@ function FindPackageWorkItem($lang, $packageName, $version, $outputCommand = $tr
foreach ($wi in $workItems)
{
$localKey = BuildHashKeyNoNull $wi.fields["Custom.Language"] $wi.fields["Custom.Package"] $wi.fields["Custom.PackageVersionMajorMinor"]
$localKey = BuildHashKey $wi.fields["Custom.Language"] $wi.fields["Custom.Package"] $wi.fields["Custom.PackageVersionMajorMinor"] $wi.fields["Custom.GroupId"]
if (!$localKey) {
$packageWorkItemWithoutKeyFields[$wi.id] = $wi
Write-Host "Skipping package [$($wi.id)]$($wi.fields['System.Title']) which is missing required fields language, package, or version."
@ -461,10 +466,10 @@ function UpdatePackageWorkItemReleaseState($id, $state, $releaseType, $outputCom
function FindOrCreateClonePackageWorkItem($lang, $pkg, $verMajorMinor, $allowPrompt = $false, $outputCommand = $false, $relatedId = $null, $tag= $null, $ignoreReleasePlannerTests = $true)
{
$workItem = FindPackageWorkItem -lang $lang -packageName $pkg.Package -version $verMajorMinor -includeClosed $true -outputCommand $outputCommand -tag $tag -ignoreReleasePlannerTests $ignoreReleasePlannerTests
$workItem = FindPackageWorkItem -lang $lang -packageName $pkg.Package -version $verMajorMinor -includeClosed $true -outputCommand $outputCommand -tag $tag -ignoreReleasePlannerTests $ignoreReleasePlannerTests -groupId $pkg.GroupId
if (!$workItem) {
$latestVersionItem = FindLatestPackageWorkItem -lang $lang -packageName $pkg.Package -outputCommand $outputCommand -tag $tag -ignoreReleasePlannerTests $ignoreReleasePlannerTests
$latestVersionItem = FindLatestPackageWorkItem -lang $lang -packageName $pkg.Package -outputCommand $outputCommand -tag $tag -ignoreReleasePlannerTests $ignoreReleasePlannerTests -groupId $pkg.GroupId
$assignedTo = "me"
$extraFields = @()
if ($latestVersionItem) {
@ -512,6 +517,13 @@ function CreateOrUpdatePackageWorkItem($lang, $pkg, $verMajorMinor, $existingIte
Write-Host "Cannot create or update because one of lang, pkg or verMajorMinor aren't set. [$lang|$($pkg.Package)|$verMajorMinor]"
return
}
# PackageProp object uses Group, while other places use GroupId, such as in work item fields and package csv files.
$pkgGroupId = if ($pkg.PSObject.Properties.Name -contains "GroupId") {
$pkg.GroupId
} else {
$null
}
$pkgName = $pkg.Package
$pkgDisplayName = $pkg.DisplayName
$pkgType = $pkg.Type
@ -523,6 +535,7 @@ function CreateOrUpdatePackageWorkItem($lang, $pkg, $verMajorMinor, $existingIte
$fields = @()
$fields += "`"Language=${lang}`""
$fields += "`"Package=${pkgName}`""
$fields += "`"GroupId=${pkgGroupId}`""
$fields += "`"PackageDisplayName=${pkgDisplayName}`""
$fields += "`"PackageType=${pkgType}`""
$fields += "`"PackageTypeNewLibrary=${pkgNewLibrary}`""
@ -540,6 +553,7 @@ function CreateOrUpdatePackageWorkItem($lang, $pkg, $verMajorMinor, $existingIte
if ($lang -ne $existingItem.fields["Custom.Language"]) { $changedField = "Custom.Language" }
if ($pkgName -ne $existingItem.fields["Custom.Package"]) { $changedField = "Custom.Package" }
if ($pkgGroupId -ne $existingItem.fields["Custom.GroupId"]) { $changedField = "Custom.GroupId" }
if ($verMajorMinor -ne $existingItem.fields["Custom.PackageVersionMajorMinor"]) { $changedField = "Custom.PackageVersionMajorMinor" }
if ($pkgDisplayName -ne $existingItem.fields["Custom.PackageDisplayName"]) { $changedField = "Custom.PackageDisplayName" }
if ($pkgType -ne [string]$existingItem.fields["Custom.PackageType"]) { $changedField = "Custom.PackageType" }
@ -1029,15 +1043,16 @@ function UpdatePackageVersions($pkgWorkItem, $plannedVersions, $shippedVersions)
function UpdateValidationStatus($pkgvalidationDetails, $BuildDefinition, $PipelineUrl)
{
$pkgName = $pkgValidationDetails.Name
$groupId = $pkgValidationDetails.GroupId
$versionString = $pkgValidationDetails.Version
$parsedNewVersion = [AzureEngSemanticVersion]::new($versionString)
$versionMajorMinor = "" + $parsedNewVersion.Major + "." + $parsedNewVersion.Minor
$workItem = FindPackageWorkItem -lang $LanguageDisplayName -packageName $pkgName -version $versionMajorMinor -includeClosed $true -outputCommand $false
$workItem = FindPackageWorkItem -lang $LanguageDisplayName -packageName $pkgName -groupId $groupId -version $versionMajorMinor -includeClosed $true -outputCommand $false
if (!$workItem)
{
Write-Host"No work item found for package [$pkgName]."
Write-Host "No work item found for package [$pkgName] with groupId [$groupId]."
return $false
}
@ -1250,6 +1265,7 @@ function Update-DevOpsReleaseWorkItem {
[Parameter(Mandatory=$true)]
[string]$version,
[string]$plannedDate,
[string]$groupId = $null,
[string]$serviceName = $null,
[string]$packageDisplayName = $null,
[string]$packageRepoPath = "NA",
@ -1277,6 +1293,7 @@ function Update-DevOpsReleaseWorkItem {
$packageInfo = [PSCustomObject][ordered]@{
Package = $packageName
GroupId = $groupId
DisplayName = $packageDisplayName
ServiceName = $serviceName
RepoPath = $packageRepoPath

View File

@ -230,16 +230,30 @@ class PackageProps {
# Returns important properties of the package relative to the language repo
# Returns a PS Object with properties @ { pkgName, pkgVersion, pkgDirectoryPath, pkgReadMePath, pkgChangeLogPath }
# Note: python is required for parsing python package properties.
# GroupId is optional and is used to filter packages for languages that support group identifiers (e.g., Java).
# When GroupId is provided, the function will match both the package name and the group ID.
function Get-PkgProperties {
Param
(
[Parameter(Mandatory = $true)]
[string]$PackageName,
[string]$ServiceDirectory
[string]$ServiceDirectory,
[string]$GroupId
)
Write-Host "Get-PkgProperties called with PackageName: [$PackageName], ServiceDirectory: [$ServiceDirectory], GroupId: [$GroupId]"
$allPkgProps = Get-AllPkgProperties -ServiceDirectory $ServiceDirectory
$pkgProps = $allPkgProps.Where({ $_.Name -eq $PackageName -or $_.ArtifactName -eq $PackageName });
if ([string]::IsNullOrEmpty($GroupId)) {
$pkgProps = $allPkgProps.Where({ $_.Name -eq $PackageName -or $_.ArtifactName -eq $PackageName });
}
else {
$pkgProps = $allPkgProps.Where({
($_.Name -eq $PackageName -or $_.ArtifactName -eq $PackageName) -and
($_.PSObject.Properties.Name -contains "Group" -and $_.Group -eq $GroupId)
});
}
if ($pkgProps.Count -ge 1) {
if ($pkgProps.Count -gt 1) {
@ -248,7 +262,12 @@ function Get-PkgProperties {
return $pkgProps[0]
}
LogError "Failed to retrieve Properties for [$PackageName]"
if ([string]::IsNullOrEmpty($GroupId)) {
LogError "Failed to retrieve Properties for [$PackageName]"
}
else {
LogError "Failed to retrieve Properties for [$PackageName] with GroupId [$GroupId]. Ensure the package has a Group property matching the specified GroupId."
}
return $null
}
@ -568,3 +587,25 @@ function Get-PkgPropsForEntireService ($serviceDirectoryPath) {
return $projectProps
}
# Get the full package name based on packageInfo properties
# Returns Group+ArtifactName if Group exists and has a value, otherwise returns Name
# If UseColonSeparator switch is enabled, returns Group:ArtifactName format (colon separator)
function Get-FullPackageName {
param (
[Parameter(Mandatory=$true)]
[PSCustomObject]$PackageInfo,
[switch]$UseColonSeparator
)
if ($PackageInfo.PSObject.Members.Name -contains "Group") {
$groupId = $PackageInfo.Group
if ($groupId) {
if ($UseColonSeparator) {
return "${groupId}:$($PackageInfo.Name)"
}
return "${groupId}+$($PackageInfo.Name)"
}
}
return $PackageInfo.Name
}

View File

@ -30,6 +30,9 @@ If one isn't provided, then it will compute the next ship date or today's date i
.PARAMETER ReleaseTrackingOnly
Optional: If this switch is passed then the script will only update the release work items and not update the versions in the local repo or validate the changelog.
.PARAMETER GroupId
Optional: The group ID for the package. For Java packages, if not provided, the script will prompt for input with 'com.azure' as the default.
.EXAMPLE
PS> ./eng/common/scripts/Prepare-Release.ps1 <PackageName>
@ -49,7 +52,8 @@ param(
[string]$PackageName,
[string]$ServiceDirectory,
[string]$ReleaseDate, # Pass Date in the form MM/dd/yyyy"
[switch]$ReleaseTrackingOnly = $false
[switch]$ReleaseTrackingOnly = $false,
[string]$GroupId
)
Set-StrictMode -Version 3
@ -57,6 +61,18 @@ Set-StrictMode -Version 3
. ${PSScriptRoot}\Helpers\ApiView-Helpers.ps1
. ${PSScriptRoot}\Helpers\DevOps-WorkItem-Helpers.ps1
# Prompt for GroupId if language is Java and GroupId is not provided
if ($Language -eq 'java' -and [string]::IsNullOrEmpty($GroupId)) {
$userInput = Read-Host "Input the group id, or press Enter to use 'com.azure' as the group id"
if ([string]::IsNullOrWhiteSpace($userInput)) {
$GroupId = "com.azure"
}
else {
$GroupId = $userInput.Trim()
}
Write-Host "Using GroupId: $GroupId" -ForegroundColor Green
}
function Get-ReleaseDay($baseDate)
{
# Find first friday
@ -74,7 +90,7 @@ function Get-ReleaseDay($baseDate)
$ErrorPreference = 'Stop'
$packageProperties = $null
$packageProperties = Get-PkgProperties -PackageName $PackageName -ServiceDirectory $ServiceDirectory
$packageProperties = Get-PkgProperties -PackageName $PackageName -ServiceDirectory $ServiceDirectory -GroupId $GroupId
if (!$packageProperties)
{
@ -128,7 +144,7 @@ if (Test-Path "Function:GetExistingPackageVersions")
}
$currentProjectVersion = $packageProperties.Version
$newVersion = Read-Host -Prompt "Input the new version, or press Enter to use use current project version '$currentProjectVersion'"
$newVersion = Read-Host -Prompt "Input the new version, or press Enter to use current project version '$currentProjectVersion'"
if (!$newVersion)
{
@ -144,6 +160,7 @@ if ($null -eq $newVersionParsed)
$result = Update-DevOpsReleaseWorkItem -language $LanguageDisplayName `
-packageName $packageProperties.Name `
-groupId $packageProperties.Group `
-version $newVersion `
-plannedDate $releaseDateString `
-packageRepoPath $packageProperties.serviceDirectory `
@ -166,7 +183,8 @@ try
}
$url = az keyvault secret show --name "APIURL" --vault-name "AzureSDKPrepRelease-KV" --query "value" --output "tsv"
$apiKey = az keyvault secret show --name "APIKEY" --vault-name "AzureSDKPrepRelease-KV" --query "value" --output "tsv"
Check-ApiReviewStatus -PackageName $packageProperties.Name -packageVersion $newVersion -Language $LanguageDisplayName -url $url -apiKey $apiKey
$fullPackageNameInApiView = Get-FullPackageName -PackageInfo $packageProperties -UseColonSeparator
Check-ApiReviewStatus -PackageName $fullPackageNameInApiView -packageVersion $newVersion -Language $LanguageDisplayName -url $url -apiKey $apiKey
}
catch
{
@ -194,7 +212,7 @@ if (Test-Path "Function:SetPackageVersion")
}
SetPackageVersion -PackageName $packageProperties.Name -Version $newVersion `
-ServiceDirectory $packageProperties.ServiceDirectory -ReleaseDate $releaseDateString `
-PackageProperties $packageProperties -ReplaceLatestEntryTitle $replaceLatestEntryTitle
-PackageProperties $packageProperties -ReplaceLatestEntryTitle $replaceLatestEntryTitle -GroupId $packageProperties.Group
}
else
{

View File

@ -4,6 +4,7 @@
# Version : Version to add or replace in change log
# Unreleased: Default is true. If it is set to false, then today's date will be set in verion title. If it is True then title will show "Unreleased"
# ReplaceLatestEntryTitle: Replaces the latest changelog entry title.
# GroupId: Optional. The group ID for the package. Used for filtering packages in languages that support group identifiers (e.g., Java).
[CmdletBinding()]
param (
@ -14,7 +15,8 @@ param (
[Boolean]$Unreleased = $true,
[Boolean]$ReplaceLatestEntryTitle = $false,
[String]$ChangelogPath,
[String]$ReleaseDate
[String]$ReleaseDate,
[String]$GroupId
)
Set-StrictMode -Version 3
@ -59,7 +61,7 @@ if ($null -eq [AzureEngSemanticVersion]::ParseVersionString($Version))
if ([string]::IsNullOrEmpty($ChangelogPath))
{
$pkgProperties = Get-PkgProperties -PackageName $PackageName -ServiceDirectory $ServiceDirectory
$pkgProperties = Get-PkgProperties -PackageName $PackageName -ServiceDirectory $ServiceDirectory -GroupId $GroupId
$ChangelogPath = $pkgProperties.ChangeLogPath
}

View File

@ -111,13 +111,13 @@ function VerifyAPIReview($packageName, $packageVersion, $language)
}
function IsVersionShipped($packageName, $packageVersion)
function IsVersionShipped($packageName, $packageVersion, $groupId = $null)
{
# This function will decide if a package version is already shipped or not
Write-Host "Checking if a version is already shipped for package $packageName with version $packageVersion."
$parsedNewVersion = [AzureEngSemanticVersion]::new($packageVersion)
$versionMajorMinor = "" + $parsedNewVersion.Major + "." + $parsedNewVersion.Minor
$workItem = FindPackageWorkItem -lang $LanguageDisplayName -packageName $packageName -version $versionMajorMinor -includeClosed $true -outputCommand $false
$workItem = FindPackageWorkItem -lang $LanguageDisplayName -packageName $packageName -groupId $groupId -version $versionMajorMinor -includeClosed $true -outputCommand $false
if ($workItem)
{
# Check if the package version is already shipped
@ -127,7 +127,7 @@ function IsVersionShipped($packageName, $packageVersion)
}
}
else {
Write-Host "No work item found for package [$packageName]. Creating new work item for package."
Write-Host "No work item found for package [$packageName], group [$groupId]. Creating new work item for package."
}
return $false
}
@ -148,6 +148,7 @@ function CreateUpdatePackageWorkItem($pkgInfo)
# Create or update package work item
$result = Update-DevOpsReleaseWorkItem -language $LanguageDisplayName `
-packageName $packageName `
-groupId $pkgInfo.Group `
-version $versionString `
-plannedDate $plannedDate `
-packageRepoPath $pkgInfo.serviceDirectory `
@ -175,15 +176,14 @@ function ProcessPackage($packageInfo)
$pkgName = $packageInfo.Name
$changeLogPath = $packageInfo.ChangeLogPath
$versionString = $packageInfo.Version
Write-Host "Checking if we need to create or update work item for package $pkgName with version $versionString."
$isShipped = IsVersionShipped $pkgName $versionString
Write-Host "Checking if we need to create or update work item for package $pkgName and groupId $packageInfo.Group with version $versionString."
Write-Host "Package name before checking groupId: $pkgName"
$isShipped = IsVersionShipped $pkgName $versionString $packageInfo.Group
if ($isShipped) {
Write-Host "Package work item already exists for version [$versionString] that is marked as shipped. Skipping the update of package work item."
return
}
Write-Host "Validating package $pkgName with version $versionString."
# Change log validation
$changeLogStatus = [PSCustomObject]@{
Name = "Change Log Validation"
@ -197,19 +197,16 @@ function ProcessPackage($packageInfo)
# If there's a groupId that means this is Java and pkgName = GroupId+ArtifactName
# but the VerifyAPIReview requires GroupId:ArtifactName
Write-Host "Package name before checking groupId: $fullPackageName"
if ($packageInfo.PSObject.Members.Name -contains "Group") {
$groupId = $packageInfo.Group
if ($groupId){
$fullPackageName = "${groupId}:$($packageInfo.ArtifactName)"
}
}
# Technically we can use groupId+artifactName format in api view,
# however it will need to migrate the existing data and Java parser also needs the change.
$fullPackageName = Get-FullPackageName -PackageInfo $packageInfo -UseColonSeparator
Write-Host "Checking API review status for package $fullPackageName"
$apireviewDetails = VerifyAPIReview $fullPackageName $packageInfo.Version $Language
# The following object will be used to update package work item, the name should be package name only without groupId
$pkgValidationDetails= [PSCustomObject]@{
Name = $pkgName
GroupId = $packageInfo.Group
Version = $packageInfo.Version
ChangeLogValidation = $changeLogStatus
APIReviewValidation = $apireviewDetails.ApiviewApproval
@ -220,6 +217,7 @@ function ProcessPackage($packageInfo)
Write-Host "Output: $($output)"
# Create json token file in artifact path
# Does the following validation file name also need to use full package name with groupId?
$tokenFile = Join-Path $ArtifactPath "$($packageInfo.ArtifactName)-Validation.json"
$output | Out-File -FilePath $tokenFile -Encoding utf8