Kaydet (Commit) 2e4a4535 authored tarafından Joffrey F's avatar Joffrey F

Update version detection script for CI

Signed-off-by: 's avatarJoffrey F <joffrey@docker.com>
üst 26daa619
...@@ -11,23 +11,24 @@ categories = [ ...@@ -11,23 +11,24 @@ categories = [
'test' 'test'
] ]
STAGES = ['tp', 'beta', 'rc']
class Version(namedtuple('_Version', 'major minor patch rc edition')):
class Version(namedtuple('_Version', 'major minor patch stage edition')):
@classmethod @classmethod
def parse(cls, version): def parse(cls, version):
edition = None edition = None
version = version.lstrip('v') version = version.lstrip('v')
version, _, rc = version.partition('-') version, _, stage = version.partition('-')
if rc: if stage:
if 'rc' not in rc: if not any(marker in stage for marker in STAGES):
edition = rc edition = stage
rc = None stage = None
elif '-' in rc: elif '-' in stage:
edition, rc = rc.split('-') edition, stage = stage.split('-')
major, minor, patch = version.split('.', 3) major, minor, patch = version.split('.', 3)
return cls(major, minor, patch, rc, edition) return cls(major, minor, patch, stage, edition)
@property @property
def major_minor(self): def major_minor(self):
...@@ -38,14 +39,22 @@ class Version(namedtuple('_Version', 'major minor patch rc edition')): ...@@ -38,14 +39,22 @@ class Version(namedtuple('_Version', 'major minor patch rc edition')):
"""Return a representation that allows this object to be sorted """Return a representation that allows this object to be sorted
correctly with the default comparator. correctly with the default comparator.
""" """
# rc releases should appear before official releases # non-GA releases should appear before GA releases
rc = (0, self.rc) if self.rc else (1, ) # Order: tp -> beta -> rc -> GA
return (int(self.major), int(self.minor), int(self.patch)) + rc if self.stage:
for st in STAGES:
if st in self.stage:
stage = (STAGES.index(st), self.stage)
break
else:
stage = (len(STAGES),)
return (int(self.major), int(self.minor), int(self.patch)) + stage
def __str__(self): def __str__(self):
rc = '-{}'.format(self.rc) if self.rc else '' stage = '-{}'.format(self.stage) if self.stage else ''
edition = '-{}'.format(self.edition) if self.edition else '' edition = '-{}'.format(self.edition) if self.edition else ''
return '.'.join(map(str, self[:3])) + edition + rc return '.'.join(map(str, self[:3])) + edition + stage
def main(): def main():
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment