dda-devops-build/release_mixin.py

44 lines
1.8 KiB
Python
Raw Normal View History

import copy
2023-02-16 13:21:27 +00:00
from ddadevops import DevopsBuild
from ddadevops import execute
from ddadevops import gopass_field_from_path, gopass_password_from_path
2023-02-28 13:55:51 +00:00
from infrastructure import GitApi, ReleaseRepository, ReleaseTypeRepository, VersionRepository
from services import PrepareReleaseService, TagAndPushReleaseService
2023-02-24 09:14:26 +00:00
from domain import ReleaseType, Version
2023-02-16 13:21:27 +00:00
2023-02-22 13:11:39 +00:00
def create_release_mixin_config(config_file, main_branch) -> dict:
config = {}
config.update(
{'ReleaseMixin':
{'main_branch': main_branch,
2023-02-23 13:23:32 +00:00
'config_file': config_file}})
2023-02-16 13:21:27 +00:00
return config
2023-02-22 13:11:39 +00:00
def add_versions(config, release_version, bump_version) -> dict:
config['ReleaseMixin'].update(
{'release_version': release_version,
'bump_version': bump_version})
return config
2023-02-16 13:21:27 +00:00
class ReleaseMixin(DevopsBuild):
def __init__(self, project, config):
super().__init__(project, config)
release_mixin_config = config['ReleaseMixin']
2023-02-23 13:23:32 +00:00
self.config_file = release_mixin_config['config_file']
2023-02-22 11:05:34 +00:00
self.main_branch = release_mixin_config['main_branch']
2023-02-28 12:25:47 +00:00
self.git_api = GitApi()
2023-02-28 13:55:51 +00:00
self.release_type_repo = ReleaseTypeRepository(self.git_api)
self.version_repo = VersionRepository(self.config_file)
self.release_repo = ReleaseRepository(self.version_repo, self.release_type_repo, self.main_branch)
2023-02-16 13:21:27 +00:00
def prepare_release(self):
2023-02-28 13:55:51 +00:00
prepare_release_service = PrepareReleaseService(self.release_repo)
# prepare_release_service.run_tests() # not implemented
2023-02-28 13:55:51 +00:00
prepare_release_service.write_and_commit_release()
prepare_release_service.write_and_commit_bump()
2023-02-22 13:11:39 +00:00
def tag_and_push_release(self):
2023-02-28 12:25:47 +00:00
tag_and_push_release_service = TagAndPushReleaseService(self.git_api)
2023-03-02 14:04:30 +00:00
tag_and_push_release_service.tag_and_push_release(self.release_repo.get_release())