60 lines
No EOL
1.7 KiB
Python
60 lines
No EOL
1.7 KiB
Python
from enum import Enum
|
|
from file_handlers import FileHandler
|
|
|
|
def init_project():
|
|
# validate_values()
|
|
version = Version.from_file('build.gradle')
|
|
version.increment(ReleaseType.SNAPSHOT)
|
|
version.to_file()
|
|
print(version.get())
|
|
|
|
def prepare_release():
|
|
pass
|
|
|
|
def release_in_git():
|
|
pass
|
|
|
|
class ReleaseType(Enum):
|
|
MAJOR = 0
|
|
MINOR = 1
|
|
PATCH = 2
|
|
SNAPSHOT = 3
|
|
|
|
class Version():
|
|
|
|
def __init__(self, version_list, release_type):
|
|
self.version_list = None
|
|
self.is_snapshot = None
|
|
self.version_string = None
|
|
|
|
def increment(self, release_type: ReleaseType):
|
|
self.is_snapshot = False
|
|
match release_type:
|
|
case ReleaseType.SNAPSHOT:
|
|
self.is_snapshot = True
|
|
case ReleaseType.PATCH:
|
|
self.version_list[ReleaseType.PATCH.value] += 1
|
|
case ReleaseType.MINOR:
|
|
self.version_list[ReleaseType.PATCH.value] = 0
|
|
self.version_list[ReleaseType.MINOR.value] += 1
|
|
case ReleaseType.MAJOR:
|
|
self.version_list[ReleaseType.PATCH.value] = 0
|
|
self.version_list[ReleaseType.MINOR.value] = 0
|
|
self.version_list[ReleaseType.MAJOR.value] += 1
|
|
|
|
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"
|
|
|
|
@classmethod
|
|
def create_release_version(cls, version_list, release_type):
|
|
inst = cls(version_list, release_type)
|
|
inst.increment(release_type)
|
|
|
|
return inst
|
|
|
|
|
|
@classmethod
|
|
def create_bump_version(cls, version_list, release_type):
|
|
pass |