Implement bump release
This commit is contained in:
parent
fa7e10d3ce
commit
c137344932
2 changed files with 15 additions and 8 deletions
|
@ -31,7 +31,7 @@ class InitReleaseService():
|
|||
raise Exception('VersionRepo was not created. Did you run create_lease_version()?')
|
||||
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())
|
||||
|
||||
|
||||
|
|
21
version.py
21
version.py
|
@ -3,7 +3,7 @@ from file_handlers import FileHandler
|
|||
|
||||
def init_project():
|
||||
# validate_values()
|
||||
version = Version.from_file('build.gradle')
|
||||
version = Version.from_file('build.gradle')
|
||||
version.increment(ReleaseType.SNAPSHOT)
|
||||
version.to_file()
|
||||
print(version.get())
|
||||
|
@ -19,6 +19,7 @@ class ReleaseType(Enum):
|
|||
MINOR = 1
|
||||
PATCH = 2
|
||||
SNAPSHOT = 3
|
||||
BUMP = None
|
||||
|
||||
class Version():
|
||||
|
||||
|
@ -30,6 +31,9 @@ class Version():
|
|||
def increment(self, release_type: ReleaseType):
|
||||
self.is_snapshot = False
|
||||
match release_type:
|
||||
case ReleaseType.BUMP:
|
||||
self.is_snapshot = True
|
||||
self.version_list[ReleaseType.PATCH.value] += 1
|
||||
case ReleaseType.SNAPSHOT:
|
||||
self.is_snapshot = True
|
||||
case ReleaseType.PATCH:
|
||||
|
@ -45,16 +49,19 @@ class Version():
|
|||
def get_version_string(self) -> str:
|
||||
self.version_string = ".".join([str(x) for x in self.version_list])
|
||||
if self.is_snapshot:
|
||||
self.version_string += "-SNAPSHOT"
|
||||
self.version_string += "-SNAPSHOT"
|
||||
|
||||
@classmethod
|
||||
def create_release_version(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
|
||||
|
||||
|
||||
@classmethod
|
||||
def create_bump_version(cls, version_list, release_type):
|
||||
pass
|
||||
def create_bump_version(cls, version_list):
|
||||
inst = cls(version_list, ReleaseType.BUMP)
|
||||
inst.increment(release_type)
|
||||
return inst
|
||||
|
|
Loading…
Reference in a new issue