Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions eng/versioning/scan_for_unreleased_dependencies.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Get-ChildItem -Path $serviceDirectory -Filter pom*.xml -Recurse -File | ForEach-
$script:FoundPomFile = $true
Write-Host "Found pom file with matching groupId($($inputGroupId))/artifactId($($inputArtifactId)), pomFile=$($pomFile)"
$version = $xmlPomFile.project.version
if ($version -like '*-beta.*')
if ($version -match '.*-beta(\.\d*)?')
{
$libraryIsBeta = $true
Write-Host "Library is releasing as Beta, version=$($version)"
Expand Down Expand Up @@ -99,7 +99,7 @@ Get-ChildItem -Path $serviceDirectory -Filter pom*.xml -Recurse -File | ForEach-
}
# If this isn't an external dependency then ensure that if the dependency
# version is beta, that we're releasing a beta, otherwise fail
if ($versionNode.InnerText -like '*-beta.*')
if ($versionNode.InnerText -match '.*-beta(\.\d*)?')
{
if (!$libraryIsBeta)
{
Expand Down
40 changes: 31 additions & 9 deletions eng/versioning/set_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
from utils import CodeModule
from utils import UpdateType
from utils import version_regex_str_with_names_anchored
from utils import prerelease_data_version_regex
from utils import prerelease_version_regex_with_name

# some things that should not be updated for devops builds, in the case where everything is being updated in one call
Expand All @@ -50,6 +51,7 @@
# The regex string we want should be the anchored one since the entire string is what's being matched
version_regex_named = re.compile(version_regex_str_with_names_anchored)
prerelease_regex_named = re.compile(prerelease_version_regex_with_name)
prerelease_data_regex = re.compile(prerelease_data_version_regex)

# Update packages (excluding unreleased dependencies and packages which already
# have a dev version set) to use a "zero dev version" (e.g. dev.20201225.0).
Expand Down Expand Up @@ -249,10 +251,21 @@ def increment_library_version(build_type, artifact_id, group_id):
# This is the case where, somehow, the versioning verification has failed and
# the prerelease verification doesn't match "beta.X"
if prever is None:
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')))
rev = int(prever.group('revision'))
rev += 1
new_version = '{}.{}.{}-beta.{}'.format(vmatch.group('major'), vmatch.group('minor'), vmatch.group('patch'), str(rev))
# if the build_type isn't data then error
if build_type.name.lower() != 'data':
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')))
else:
# verify that prerelease is "beta"
if prerelease_data_regex.match(vmatch.group('prerelease')) is None:
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')))
# in the case there the prerelease version is just "beta", increment the minor and set the patch to 0
minor = int(vmatch.group('minor'))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we even know if this is the pattern then want for track 1? I kind of feel like if they don't want to follow the full guidance then we should simply not have support for incrementing their versions. Maybe we should just ignore version increments for those.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1.0.0-beta turning into 1.1.0-beta at least follows the same GA increment pattern. For the most part I'm expecting the version to be changed before the next release anyways. What matters for the auto increment is that we produce something that won't clash with what's on Maven and is a higher version. I don't want to ignore the auto-increment for track 1 because a couple of libraries were allowed to be exceptions when most of the others are following the version scheme.

minor += 1
new_version = '{}.{}.{}-beta'.format(vmatch.group('major'), minor, 0)
else:
rev = int(prever.group('revision'))
rev += 1
new_version = '{}.{}.{}-beta.{}'.format(vmatch.group('major'), vmatch.group('minor'), vmatch.group('patch'), str(rev))
else:
minor = int(vmatch.group('minor'))
minor += 1
Expand Down Expand Up @@ -308,12 +321,21 @@ def verify_current_version_of_artifact(build_type, artifact_id, group_id):
if vmatch.group('prerelease') is not None:
prerel = vmatch.group('prerelease')

# this regex is looking for beta.X
if prerelease_regex_named.match(prerel) is None:
raise ValueError('library ({}) version ({}) in version file ({}) is not a correct version to release. The accepted prerelease tag is (beta.X) and the current prerelease tag is ({})'.format(library_to_update, module.current, version_file, prerel))

prever = prerelease_regex_named.match(prerel)
rev = int(prever.group('revision'))
temp_ver = '{}-beta.{}'.format(temp_ver, str(rev))
# if the build_type isn't data then error
if build_type.name.lower() != 'data':
raise ValueError('library ({}) version ({}) in version file ({}) is not a correct version to release. The accepted prerelease tag is (beta.X) and the current prerelease tag is ({})'.format(library_to_update, module.current, version_file, prerel))
else:
# verify that the prerelease tag is "beta" which is the only allowable thing for data track aside from beta.X
if prerelease_data_regex.match(prerel) is None:
raise ValueError('library ({}) version ({}) in version file ({}) is not a correct version to release. The accepted prerelease tags for data track are (beta) or (beta.X) and the current prerelease tag is ({})'.format(library_to_update, module.current, version_file, prerel))
# at this point the version is <major>.<minor>.<patch>-beta
temp_ver = '{}-{}'.format(temp_ver, str(prerel))
else:
prever = prerelease_regex_named.match(prerel)
rev = int(prever.group('revision'))
temp_ver = '{}-beta.{}'.format(temp_ver, str(rev))

# last but not least, for sanity verify that the version constructed from the
# semver pieces matches module's current version
Expand Down
2 changes: 2 additions & 0 deletions eng/versioning/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@

# This is specific to our revision which, if there is one, needs to have the format of beta.X
prerelease_version_regex_with_name = r'^beta\.(?P<revision>0|[1-9]\d*)$'
# This is special for track 1, data track, which can be <major>.<minor>.<version>-beta with no ".X"
prerelease_data_version_regex = r'^beta$'

class UpdateType(Enum):
external_dependency = 'external_dependency'
Expand Down