Skip to content

Commit b6bc150

Browse files
Update Update Changelog (Azure#15992)
* add function for getting existing package versions * Add SetPackageVersion function * Update versioning tools logic * Add GetPackageInstallNotes function * Add GetPackageInstallNotes function * Remove changes unrelated to update changelog
1 parent de744d1 commit b6bc150

File tree

5 files changed

+38
-14
lines changed

5 files changed

+38
-14
lines changed

eng/pipelines/templates/stages/archetype-python-release.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ parameters:
22
Artifacts: []
33
TestPipeline: false
44
ArtifactName: 'not-specified'
5+
ServiceDirectory: 'not-specified'
56
DependsOn: Build
67
DocArtifact: 'documentation'
78
DevFeedName: 'public/azure-sdk-for-python'
@@ -227,7 +228,7 @@ stages:
227228
displayName: Increment package version
228229
inputs:
229230
scriptPath: 'eng/versioning/version_increment.py'
230-
arguments: '--package-name ${{ artifact.name }}'
231+
arguments: '--package-name ${{ artifact.name }} --service ${{ parameters.ServiceDirectory }}'
231232
- template: /eng/common/pipelines/templates/steps/create-pull-request.yml
232233
parameters:
233234
RepoName: azure-sdk-for-python

eng/scripts/Language-Settings.ps1

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ function Get-python-PackageInfoFromRepo ($pkgPath, $serviceDirectory, $pkgName)
2323
}
2424

2525
# Returns the pypi publish status of a package id and version.
26-
function IsPythonPackageVersionPublished($pkgId, $pkgVersion) {
26+
function IsPythonPackageVersionPublished($pkgId, $pkgVersion)
27+
{
2728
try
2829
{
2930
$existingVersion = (Invoke-RestMethod -MaximumRetryCount 3 -RetryIntervalSec 10 -Method "Get" -uri "https://pypi.org/pypi/$pkgId/$pkgVersion/json").info.version
@@ -48,7 +49,8 @@ function IsPythonPackageVersionPublished($pkgId, $pkgVersion) {
4849
}
4950

5051
# Parse out package publishing information given a python sdist of ZIP format.
51-
function Get-python-PackageInfoFromPackageFile ($pkg, $workingDirectory) {
52+
function Get-python-PackageInfoFromPackageFile ($pkg, $workingDirectory)
53+
{
5254
$pkg.Basename -match $SDIST_PACKAGE_REGEX | Out-Null
5355

5456
$pkgId = $matches["package"]
@@ -109,7 +111,8 @@ function Publish-python-GithubIODocs ($DocLocation, $PublicArtifactLocation)
109111
}
110112
}
111113

112-
function Get-python-GithubIoDocIndex() {
114+
function Get-python-GithubIoDocIndex()
115+
{
113116
# Update the main.js and docfx.json language content
114117
UpdateDocIndexFiles -appTitleLang Python
115118
# Fetch out all package metadata from csv file.
@@ -125,7 +128,8 @@ function Get-python-GithubIoDocIndex() {
125128
# Updates a python CI configuration json.
126129
# For "latest", the version attribute is cleared, as default behavior is to pull latest "non-preview".
127130
# For "preview", we update to >= the target releasing package version.
128-
function Update-python-CIConfig($pkgs, $ciRepo, $locationInDocRepo, $monikerId=$null){
131+
function Update-python-CIConfig($pkgs, $ciRepo, $locationInDocRepo, $monikerId=$null)
132+
{
129133
$pkgJsonLoc = (Join-Path -Path $ciRepo -ChildPath $locationInDocRepo)
130134

131135
if (-not (Test-Path $pkgJsonLoc)) {
@@ -212,3 +216,13 @@ function Find-python-Artifacts-For-Apireview($artifactDir, $artifactName)
212216
}
213217
return $packages
214218
}
219+
220+
function SetPackageVersion ($PackageName, $Version, $ServiceDirectory, $ReleaseDate, $BuildType=$null, $GroupId=$null)
221+
{
222+
if($null -eq $ReleaseDate)
223+
{
224+
$ReleaseDate = Get-Date -Format "yyyy-MM-dd"
225+
}
226+
pip install -r "$EngDir/versioning/requirements.txt" -q -I
227+
python "$EngDir/versioning/version_set.py" --package-name $PackageName --new-version $Version --service $ServiceDirectory --release-date $ReleaseDate
228+
}

eng/versioning/version_increment.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def increment_version(old_version):
3737
'Examples: All = "azure-*", Single = "azure-keyvault", Targeted Multiple = "azure-keyvault,azure-mgmt-resource"'
3838
),
3939
)
40-
parser.add_argument('--service', help='name of the service for which to set the dev build id (e.g. keyvault)')
40+
parser.add_argument('--service', required=True, help='name of the service for which to set the dev build id (e.g. keyvault)')
4141
args = parser.parse_args()
4242

4343
package_name = args.package_name.replace('_', '-')
@@ -56,4 +56,4 @@ def increment_version(old_version):
5656

5757
set_version_py(target_package[0], new_version)
5858
set_dev_classifier(target_package[0], new_version)
59-
update_change_log(target_package[0], new_version, True, False)
59+
update_change_log(target_package[0], new_version, args.service, args.package_name, True, False)

eng/versioning/version_set.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99

1010
parser.add_argument('--package-name', required=True, help='name of package (accetps both formats: azure-service-package and azure_service_pacage)')
1111
parser.add_argument('--new-version', required=True, help='new package version')
12-
parser.add_argument('--service', help='name of the service for which to set the dev build id (e.g. keyvault)')
12+
parser.add_argument('--service', required=True, help='name of the service for which to set the dev build id (e.g. keyvault)')
13+
parser.add_argument('--release-date', help='date in the format "yyyy-MM-dd"')
1314
parser.add_argument(
1415
dest="glob_string",
1516
nargs="?",
@@ -37,4 +38,4 @@
3738

3839
set_version_py(target_package[0], new_version)
3940
set_dev_classifier(target_package[0], new_version)
40-
update_change_log(target_package[0], new_version, False, True)
41+
update_change_log(target_package[0], new_version, args.service, args.package_name, False, True, args.release_date)

eng/versioning/version_shared.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import logging
1616
from packaging.version import parse
1717

18+
from datetime import date
1819
from setup_parser import parse_setup
1920

2021
root_dir = path.abspath(path.join(path.abspath(__file__), "..", "..", ".."))
@@ -130,21 +131,28 @@ def set_dev_classifier(setup_py_location, version):
130131

131132
setup_py_file.write(replaced_setup_contents)
132133

133-
def update_change_log(setup_py_location, version, is_unreleased, replace_version):
134-
script = os.path.join(root_dir, "eng", "common", "Update-Change-Log.ps1")
134+
def update_change_log(setup_py_location, version, service, package, is_unreleased, replace_version, release_date=None):
135+
script = os.path.join(root_dir, "eng", "common", "scripts", "Update-ChangeLog.ps1")
135136
pkg_root = os.path.abspath(os.path.join(setup_py_location, ".."))
137+
136138
commands = [
137139
"pwsh",
138140
script,
139141
"--Version",
140142
version,
141-
"--ChangeLogPath",
142-
pkg_root,
143+
"--ServiceDirectory",
144+
service,
145+
"--PackageName",
146+
package,
143147
"--Unreleased",
144148
str(is_unreleased),
145-
"--ReplaceVersion",
149+
"--ReplaceLatestEntry",
146150
str(replace_version)
147151
]
152+
if release_date is not None:
153+
commands.append("--ReleaseDate")
154+
commands.append(release_date)
155+
148156
# Run script to update change log
149157
run_check_call(commands, pkg_root)
150158

0 commit comments

Comments
 (0)