diff --git a/eng/pipelines/templates/jobs/archetype-sdk-client.yml b/eng/pipelines/templates/jobs/archetype-sdk-client.yml index 8f6be6874c08..41a4c97bd42e 100644 --- a/eng/pipelines/templates/jobs/archetype-sdk-client.yml +++ b/eng/pipelines/templates/jobs/archetype-sdk-client.yml @@ -133,7 +133,7 @@ jobs: pwsh: true workingDirectory: $(Build.SourcesDirectory) filePath: eng/scripts/SetTestPipelineVersion.ps1 - arguments: '-BuildNumber $(Build.BuildNumber)' + arguments: '-BuildID $(Build.BuildId)' - pwsh: | $toxenvvar = "whl,sdist" diff --git a/eng/pipelines/templates/stages/archetype-python-release.yml b/eng/pipelines/templates/stages/archetype-python-release.yml index 09df8083f60d..6fe5269708c9 100644 --- a/eng/pipelines/templates/stages/archetype-python-release.yml +++ b/eng/pipelines/templates/stages/archetype-python-release.yml @@ -37,6 +37,7 @@ stages: pwsh: true workingDirectory: $(Build.SourcesDirectory) filePath: eng/scripts/SetTestPipelineVersion.ps1 + arguments: '-BuildID $(Build.BuildId)' # TEMPORARILY DISABLING 11/16. Will re-enable after patch to common tooling. # - ${{if ne(artifact.skipVerifyChangeLog, 'true')}}: # - template: /eng/common/pipelines/templates/steps/verify-changelog.yml diff --git a/eng/pipelines/templates/steps/build-artifacts.yml b/eng/pipelines/templates/steps/build-artifacts.yml index 77b9ced6f134..5088ca6919a8 100644 --- a/eng/pipelines/templates/steps/build-artifacts.yml +++ b/eng/pipelines/templates/steps/build-artifacts.yml @@ -14,7 +14,7 @@ steps: pwsh: true workingDirectory: $(Build.SourcesDirectory) filePath: eng/scripts/SetTestPipelineVersion.ps1 - arguments: '-BuildNumber $(Build.BuildNumber)' + arguments: '-BuildID $(Build.BuildId)' - script: | echo "##vso[build.addbuildtag]Scheduled" diff --git a/eng/scripts/Language-Settings.ps1 b/eng/scripts/Language-Settings.ps1 index 836f3cc2b01f..60a2c8b35b8a 100644 --- a/eng/scripts/Language-Settings.ps1 +++ b/eng/scripts/Language-Settings.ps1 @@ -117,4 +117,62 @@ function Get-python-GithubIoDocIndex() { $tocContent = Get-TocMapping -metadata $metadata -artifacts $artifacts # Generate yml/md toc files and build site. GenerateDocfxTocContent -tocContent $tocContent -lang "Python" +} + +# Updates a python CI configuration json. +# For "latest", the version attribute is cleared, as default behavior is to pull latest "non-preview". +# For "preview", we update to >= the target releasing package version. +function Update-python-CIConfig($pkgs, $ciRepo, $locationInDocRepo, $monikerId=$null){ + $pkgJsonLoc = (Join-Path -Path $ciRepo -ChildPath $locationInDocRepo) + + if (-not (Test-Path $pkgJsonLoc)) { + Write-Error "Unable to locate package json at location $pkgJsonLoc, exiting." + exit(1) + } + + $allJson = Get-Content $pkgJsonLoc | ConvertFrom-Json + $visibleInCI = @{} + + for ($i=0; $i -lt $allJson.packages.Length; $i++) { + $pkgDef = $allJson.packages[$i] + + if ($pkgDef.package_info.name) { + $visibleInCI[$pkgDef.package_info.name] = $i + } + } + + foreach ($releasingPkg in $pkgs) { + if ($visibleInCI.ContainsKey($releasingPkg.PackageId)) { + $packagesIndex = $visibleInCI[$releasingPkg.PackageId] + $existingPackageDef = $allJson.packages[$packagesIndex] + + if ($releasingPkg.IsPrerelease) { + if (-not $existingPackageDef.package_info.version) { + $existingPackageDef.package_info | Add-Member -NotePropertyName version -NotePropertyValue "" + } + + $existingPackageDef.package_info.version = ">=$($releasingPkg.PackageVersion)" + } + else { + if ($def.version) { + $def.PSObject.Properties.Remove('version') + } + } + } + else { + $newItem = New-Object PSObject -Property @{ + package_info = New-Object PSObject -Property @{ + prefer_source_distribution = "true" + install_type = "pypi" + name=$releasingPkg.PackageId + } + exclude_path = @("test*","example*","sample*","doc*") + } + $allJson.packages += $newItem + } + } + + $jsonContent = $allJson | ConvertTo-Json -Depth 10 | % {$_ -replace "(?m) (?<=^(?: )*)", " " } + + Set-Content -Path $pkgJsonLoc -Value $jsonContent } \ No newline at end of file diff --git a/eng/scripts/SetTestPipelineVersion.ps1 b/eng/scripts/SetTestPipelineVersion.ps1 index 5f2518346016..98e5eb6dc9d7 100644 --- a/eng/scripts/SetTestPipelineVersion.ps1 +++ b/eng/scripts/SetTestPipelineVersion.ps1 @@ -3,7 +3,7 @@ param ( [Parameter(mandatory = $true)] - $BuildNumber + $BuildID ) . "${PSScriptRoot}\..\common\scripts\common.ps1" @@ -23,7 +23,7 @@ LogDebug "Last Published Version $($semVarsSorted[0])" $newVersion = [AzureEngSemanticVersion]::ParsePythonVersionString($semVarsSorted[0]) $newVersion.PrereleaseLabel = "b" -$newVersion.PrereleaseNumber = $BuildNumber +$newVersion.PrereleaseNumber = $BuildID LogDebug "Version to publish [ $($newVersion.ToString()) ]"