terraformDummyRepo/release_mixin.py
bom 28344667db Remove unused fields from ReleaseMixin
These are handled through repos and services instead
2023-03-02 15:03:11 +01:00

43 lines
1.8 KiB
Python

import copy
from ddadevops import DevopsBuild
from ddadevops import execute
from ddadevops import gopass_field_from_path, gopass_password_from_path
from infrastructure import GitApi, ReleaseRepository, ReleaseTypeRepository, VersionRepository
from services import PrepareReleaseService, TagAndPushReleaseService
from domain import ReleaseType, Version
def create_release_mixin_config(config_file, main_branch) -> dict:
config = {}
config.update(
{'ReleaseMixin':
{'main_branch': main_branch,
'config_file': config_file}})
return config
def add_versions(config, release_version, bump_version) -> dict:
config['ReleaseMixin'].update(
{'release_version': release_version,
'bump_version': bump_version})
return config
class ReleaseMixin(DevopsBuild):
def __init__(self, project, config):
super().__init__(project, config)
release_mixin_config = config['ReleaseMixin']
self.config_file = release_mixin_config['config_file']
self.main_branch = release_mixin_config['main_branch']
self.git_api = GitApi()
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)
def prepare_release(self):
prepare_release_service = PrepareReleaseService(self.release_repo)
# prepare_release_service.run_tests() # not implemented
prepare_release_service.write_and_commit_release()
prepare_release_service.write_and_commit_bump()
def tag_and_push_release(self):
tag_and_push_release_service = TagAndPushReleaseService(self.git_api)
tag_and_push_release_service.tag_and_push_release(self.release_version)