Skip to content

Commit fcfea68

Browse files
Update Update changelog (Azure#18463)
* Add function to retrieve package versions from nuget * update logic in increment_or_set_library_version function in eng\versioning\set_versions.py to allow increment as well as just setting versions * Add SetPackageVersion function * Add GetPackageInstallNotes function * Remove changes not related to changelogs
1 parent d8bf63f commit fcfea68

File tree

2 files changed

+71
-49
lines changed

2 files changed

+71
-49
lines changed

eng/scripts/Language-Settings.ps1

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ function Get-java-PackageInfoFromRepo ($pkgPath, $serviceDirectory, $pkgName)
2525
}
2626

2727
# Returns the maven (really sonatype) publish status of a package id and version.
28-
function IsMavenPackageVersionPublished($pkgId, $pkgVersion, $groupId)
28+
function IsMavenPackageVersionPublished($pkgId, $pkgVersion, $groupId)
2929
{
3030
try
3131
{
@@ -58,7 +58,8 @@ function IsMavenPackageVersionPublished($pkgId, $pkgVersion, $groupId)
5858
}
5959

6060
# Parse out package publishing information given a maven POM file
61-
function Get-java-PackageInfoFromPackageFile ($pkg, $workingDirectory) {
61+
function Get-java-PackageInfoFromPackageFile ($pkg, $workingDirectory)
62+
{
6263
[xml]$contentXML = Get-Content $pkg
6364

6465
$pkgId = $contentXML.project.artifactId
@@ -156,7 +157,8 @@ function Publish-java-GithubIODocs ($DocLocation, $PublicArtifactLocation)
156157
}
157158
}
158159

159-
function Get-java-GithubIoDocIndex() {
160+
function Get-java-GithubIoDocIndex()
161+
{
160162
# Update the main.js and docfx.json language content
161163
UpdateDocIndexFiles -appTitleLang "Java"
162164
# Fetch out all package metadata from csv file.
@@ -175,7 +177,8 @@ function Get-java-GithubIoDocIndex() {
175177

176178
# a "package.json configures target packages for all the monikers in a Repository, it also has a slightly different
177179
# schema than the moniker-specific json config that is seen in python and js
178-
function Update-java-CIConfig($pkgs, $ciRepo, $locationInDocRepo, $monikerId=$null){
180+
function Update-java-CIConfig($pkgs, $ciRepo, $locationInDocRepo, $monikerId=$null)
181+
{
179182
$pkgJsonLoc = (Join-Path -Path $ciRepo -ChildPath $locationInDocRepo)
180183

181184
if (-not (Test-Path $pkgJsonLoc)) {
@@ -217,7 +220,6 @@ function Update-java-CIConfig($pkgs, $ciRepo, $locationInDocRepo, $monikerId=$nu
217220
Set-Content -Path $pkgJsonLoc -Value $jsonContent
218221
}
219222

220-
221223
# function is used to filter packages to submit to API view tool
222224
function Find-java-Artifacts-For-Apireview($artifactDir, $pkgName = "")
223225
{
@@ -241,4 +243,16 @@ function Find-java-Artifacts-For-Apireview($artifactDir, $pkgName = "")
241243
}
242244

243245
return $packages
244-
}
246+
}
247+
248+
function SetPackageVersion ($PackageName, $Version, $ServiceDirectory, $ReleaseDate, $BuildType, $GroupId)
249+
{
250+
if($null -eq $ReleaseDate)
251+
{
252+
$ReleaseDate = Get-Date -Format "yyyy-MM-dd"
253+
}
254+
python "$EngDir/versioning/set_versions.py" --build-type $BuildType --new-version $Version --ai $PackageName --gi $GroupId
255+
python "$EngDir/versioning/update_versions.py" --update-type library --build-type $BuildType --sr
256+
& "$EngCommonScriptsDir/Update-ChangeLog.ps1" -Version $Version -ServiceDirectory $ServiceDirectory -PackageName $PackageName `
257+
-Unreleased $False -ReplaceLatestEntryTitle $True -ReleaseDate $ReleaseDate
258+
}

eng/versioning/set_versions.py

Lines changed: 51 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ def prep_version_file_for_source_testing(build_type):
249249

250250
# given a build type, artifact id and group id, set the dependency version to the
251251
# current version and increment the current version
252-
def increment_library_version(build_type, artifact_id, group_id):
252+
def increment_or_set_library_version(build_type, artifact_id, group_id, new_version=None):
253253

254254
version_file = os.path.normpath('eng/versioning/version_' + build_type.name + '.txt')
255255
print('version_file=' + version_file)
@@ -270,50 +270,51 @@ def increment_library_version(build_type, artifact_id, group_id):
270270
# https://github.com/Azure/azure-sdk/blob/master/docs/policies/releases.md#java
271271
if module.name == library_to_update and hasattr(module, 'current'):
272272
artifact_found = True
273-
vmatch = version_regex_named.match(module.current)
274-
if (vmatch.group('prerelease') is not None):
275-
prever = prerelease_regex_named.match(vmatch.group('prerelease'))
276-
# This is the case where, somehow, the versioning verification has failed and
277-
# the prerelease verification doesn't match "beta.X"
278-
if prever is None:
279-
# if the build_type isn't data then error
280-
if build_type.name.lower() != 'data':
281-
raise ValueError('library_to_update ({}:{}) has an invalid prerelease version ({}) which should be of the format beta.X'.format(library_to_update, module.current, vmatch.group('prerelease')))
273+
if new_version is None:
274+
vmatch = version_regex_named.match(module.current)
275+
if (vmatch.group('prerelease') is not None):
276+
prever = prerelease_regex_named.match(vmatch.group('prerelease'))
277+
# This is the case where, somehow, the versioning verification has failed and
278+
# the prerelease verification doesn't match "beta.X"
279+
if prever is None:
280+
# if the build_type isn't data then error
281+
if build_type.name.lower() != 'data':
282+
raise ValueError('library_to_update ({}:{}) has an invalid prerelease version ({}) which should be of the format beta.X'.format(library_to_update, module.current, vmatch.group('prerelease')))
283+
else:
284+
# verify that prerelease is "beta"
285+
if prerelease_data_regex.match(vmatch.group('prerelease')) is None:
286+
raise ValueError('library_to_update ({}:{}) has an invalid prerelease version ({}) which should be of the format (beta) or (beta.X)'.format(library_to_update, module.current, vmatch.group('prerelease')))
287+
# in the case there the prerelease version is just "beta", increment the minor and set the patch to 0
288+
minor = int(vmatch.group('minor'))
289+
minor += 1
290+
new_version = '{}.{}.{}-beta'.format(vmatch.group('major'), minor, 0)
282291
else:
283-
# verify that prerelease is "beta"
284-
if prerelease_data_regex.match(vmatch.group('prerelease')) is None:
285-
raise ValueError('library_to_update ({}:{}) has an invalid prerelease version ({}) which should be of the format (beta) or (beta.X)'.format(library_to_update, module.current, vmatch.group('prerelease')))
286-
# in the case there the prerelease version is just "beta", increment the minor and set the patch to 0
287-
minor = int(vmatch.group('minor'))
288-
minor += 1
289-
new_version = '{}.{}.{}-beta'.format(vmatch.group('major'), minor, 0)
290-
else:
291-
rev = int(prever.group('revision'))
292-
rev += 1
293-
new_version = '{}.{}.{}-beta.{}'.format(vmatch.group('major'), vmatch.group('minor'), vmatch.group('patch'), str(rev))
294-
else:
295-
minor = int(vmatch.group('minor'))
296-
minor += 1
297-
new_version = '{}.{}.{}-beta.1'.format(vmatch.group('major'), minor, 0)
298-
# The dependency version only needs to be updated it if is different from the current version.
299-
# This would be the case where a library hasn't been released yet and has been released (either GA or preview)
300-
if (module.dependency != module.current):
301-
vDepMatch = version_regex_named.match(module.dependency)
302-
# If the dependency version is a beta then just set it to whatever the current
303-
# version is
304-
if (vDepMatch.group('prerelease') is not None):
305-
print('library_to_update {}, previous dependency version={}, new dependency version={}'.format(library_to_update, module.dependency, module.current))
306-
module.dependency = module.current
307-
# else, the dependency version isn't a pre-release version
292+
rev = int(prever.group('revision'))
293+
rev += 1
294+
new_version = '{}.{}.{}-beta.{}'.format(vmatch.group('major'), vmatch.group('minor'), vmatch.group('patch'), str(rev))
308295
else:
309-
# if the dependency version isn't a beta and the current version is, don't
310-
# update the dependency version
311-
if (vmatch.group('prerelease') is not None):
312-
print('library_to_update {}, has a GA dependency version {} and a beta current version {}. The dependency version will be kept at the GA version. '.format(library_to_update, module.dependency, module.current))
313-
else:
314-
print('library_to_update {}, has both GA dependency {} and current {} versions. The dependency will be updated to {}. '.format(library_to_update, module.dependency, module.current, module.current))
296+
minor = int(vmatch.group('minor'))
297+
minor += 1
298+
new_version = '{}.{}.{}-beta.1'.format(vmatch.group('major'), minor, 0)
299+
# The dependency version only needs to be updated it if is different from the current version.
300+
# This would be the case where a library hasn't been released yet and has been released (either GA or preview)
301+
if (module.dependency != module.current):
302+
vDepMatch = version_regex_named.match(module.dependency)
303+
# If the dependency version is a beta then just set it to whatever the current
304+
# version is
305+
if (vDepMatch.group('prerelease') is not None):
306+
print('library_to_update {}, previous dependency version={}, new dependency version={}'.format(library_to_update, module.dependency, module.current))
315307
module.dependency = module.current
316-
print('library_to_update {}, previous current version={}, new current version={}'.format(library_to_update, module.current, new_version))
308+
# else, the dependency version isn't a pre-release version
309+
else:
310+
# if the dependency version isn't a beta and the current version is, don't
311+
# update the dependency version
312+
if (vmatch.group('prerelease') is not None):
313+
print('library_to_update {}, has a GA dependency version {} and a beta current version {}. The dependency version will be kept at the GA version. '.format(library_to_update, module.dependency, module.current))
314+
else:
315+
print('library_to_update {}, has both GA dependency {} and current {} versions. The dependency will be updated to {}. '.format(library_to_update, module.dependency, module.current, module.current))
316+
module.dependency = module.current
317+
print('library_to_update {}, previous current version={}, new current version={}'.format(library_to_update, module.current, new_version))
317318
module.current = new_version
318319
newlines.append(module.string_for_version_file())
319320

@@ -395,6 +396,7 @@ def main():
395396
optional.add_argument('--artifact-id', '--ai', help='artifactId of the target library')
396397
optional.add_argument('--group-id', '--gi', help='groupId of the target library')
397398
optional.add_argument('--prep-source-testing', '--pst', action='store_true', help='prep the version file for source testing')
399+
optional.add_argument('--new-version', '--nv', help='set an new version.')
398400
optional.add_argument('--increment-version', '--iv', action='store_true', help='increment the version for a given group/artifact')
399401
optional.add_argument('--verify-version', '--vv', action='store_true', help='verify the version for a given group/artifact')
400402
optional.add_argument('--set-dev-zero-version', '--sdzv', action='store_true', help='Set a zero dev build version for packages that do not already have dev versions set (should be run after setting dev versions for other packages)')
@@ -410,7 +412,13 @@ def main():
410412
elif (args.increment_version):
411413
if not args.artifact_id or not args.group_id:
412414
raise ValueError('increment-version requires both the artifact-id and group-id arguments. artifact-id={}, group-id={}'.format(args.artifact_id, args.group_id))
413-
increment_library_version(args.build_type, args.artifact_id, args.group_id)
415+
if args.new_version:
416+
raise ValueError('new-version should not be passed with increment-version')
417+
increment_or_set_library_version(args.build_type, args.artifact_id, args.group_id)
418+
elif (args.new_version):
419+
if not args.artifact_id or not args.group_id:
420+
raise ValueError('new-version requires both the artifact-id and group-id arguments. artifact-id={}, group-id={}'.format(args.artifact_id, args.group_id))
421+
increment_or_set_library_version(args.build_type, args.artifact_id, args.group_id, args.new_version)
414422
elif (args.verify_version):
415423
if not args.artifact_id or not args.group_id:
416424
raise ValueError('verify-version requires both the artifact-id and group-id arguments. artifact-id={}, group-id={}'.format(args.artifact_id, args.group_id))

0 commit comments

Comments
 (0)