Implement bump release

This commit is contained in:
erik 2023-02-20 16:21:02 +01:00
parent fa7e10d3ce
commit c137344932
2 changed files with 15 additions and 8 deletions

View file

@ -31,7 +31,7 @@ class InitReleaseService():
raise Exception('VersionRepo was not created. Did you run create_lease_version()?') raise Exception('VersionRepo was not created. Did you run create_lease_version()?')
version_list = self.get_version_list() version_list = self.get_version_list()
bump_version = Version.create_bump_version(version_list, ReleaseType.SNAPSHOT) bump_version = Version.create_bump_version(version_list)
self.version_repo.write_file(bump_version.get_version_string()) self.version_repo.write_file(bump_version.get_version_string())

View file

@ -3,7 +3,7 @@ from file_handlers import FileHandler
def init_project(): def init_project():
# validate_values() # validate_values()
version = Version.from_file('build.gradle') version = Version.from_file('build.gradle')
version.increment(ReleaseType.SNAPSHOT) version.increment(ReleaseType.SNAPSHOT)
version.to_file() version.to_file()
print(version.get()) print(version.get())
@ -19,6 +19,7 @@ class ReleaseType(Enum):
MINOR = 1 MINOR = 1
PATCH = 2 PATCH = 2
SNAPSHOT = 3 SNAPSHOT = 3
BUMP = None
class Version(): class Version():
@ -30,6 +31,9 @@ class Version():
def increment(self, release_type: ReleaseType): def increment(self, release_type: ReleaseType):
self.is_snapshot = False self.is_snapshot = False
match release_type: match release_type:
case ReleaseType.BUMP:
self.is_snapshot = True
self.version_list[ReleaseType.PATCH.value] += 1
case ReleaseType.SNAPSHOT: case ReleaseType.SNAPSHOT:
self.is_snapshot = True self.is_snapshot = True
case ReleaseType.PATCH: case ReleaseType.PATCH:
@ -45,16 +49,19 @@ class Version():
def get_version_string(self) -> str: def get_version_string(self) -> str:
self.version_string = ".".join([str(x) for x in self.version_list]) self.version_string = ".".join([str(x) for x in self.version_list])
if self.is_snapshot: if self.is_snapshot:
self.version_string += "-SNAPSHOT" self.version_string += "-SNAPSHOT"
@classmethod @classmethod
def create_release_version(cls, version_list, release_type): def create_release_version(cls, version_list, release_type):
inst = cls(version_list, release_type) inst = cls(version_list, release_type)
inst.increment(release_type) if release_type == ReleaseType.PATCH:
inst.is_snapshot = False
else:
inst.increment(release_type)
return inst return inst
@classmethod @classmethod
def create_bump_version(cls, version_list, release_type): def create_bump_version(cls, version_list):
pass inst = cls(version_list, ReleaseType.BUMP)
inst.increment(release_type)
return inst