Compare commits

..

No commits in common. "0cdf4b4c9c8e19264509b01c93f9de4b175cf3a0" and "4a23b0b800c61ec764f1fa9492e5b5b9879a0bef" have entirely different histories.

5 changed files with 30 additions and 43 deletions

View file

@ -1,29 +1,10 @@
import sys
import os
from pathlib import Path
from ddadevops import *
# getting the name of the directory
# where the this file is present.
current = os.path.dirname(os.path.realpath(__file__))
# adding the current directory to
# the sys.path.
sys.path.append(current)
# now we can import the module in the current
# directory.
from pybuilder.core import task, init
from ddadevops import *
from release_mixin import ReleaseMixin, create_release_mixin_config
from version import *
from release_mixin import *
CONFIG_FILE = Path('config.json')
CONFIG_FILE = ''
MAIN_BRANCH = 'main'
STAGE = 'test'
PROJECT_ROOT_PATH = '.'
MODULE = 'test'
BUILD_DIR_NAME = "build_dir"
class MyBuild(ReleaseMixin):
pass
@ -32,17 +13,33 @@ class MyBuild(ReleaseMixin):
def initialize(project):
project.build_depends_on('ddadevops>=3.1.2')
config = create_release_mixin_config(CONFIG_FILE, MAIN_BRANCH)
config.update({'stage': STAGE,
'module': MODULE,
'project_root_path': PROJECT_ROOT_PATH,
'build_dir_name': BUILD_DIR_NAME})
build = MyBuild(project, config)
build.initialize_build_dir()
build.init()
@task
def release(project):
build = get_devops_build(project)
build.init_release()
build.prepare_release()
build.tag_and_push_release()
prepare_release(build)
tag_and_push_release(build)
prepare_version_bump(build)
tag_and_push_version_bump(build)
def prepare_release(build):
release_version = build.release_version
build.prepare(release_version)
def tag_and_push_release(build):
release_version = build.release_version
build.tag_and_push(release_version)
def prepare_version_bump(build):
bump_version = build.bump_version
build.prepare(bump_version)
def tag_and_push_version_bump(build):
bump_version = build.bump_version
build.tag_and_push(bump_version)

View file

@ -1,3 +0,0 @@
{
"version": "123.125.1-SNAPSHOT"
}

View file

@ -42,28 +42,21 @@ class GitRepository():
def tag_annotated(self, annotation: str, message: str):
self.system_repository.run_checked('git', 'tag', '-a', annotation, '-m', message)
return self.system_repository.stdout
def tag_annotated(self, annotation: str, message: str, count: int):
self.system_repository.run_checked('git', 'tag', '-a', annotation, '-m', message, f'HEAD~{count}')
return self.system_repository.stdout
def get_current_branch(self):
self.system_repository.run_checked('git', 'branch', '--show-current')
return ''.join(self.system_repository.stdout).rstrip()
def add_file(self, file_path: Path):
self.system_repository.run_checked('git', 'add', file_path)
return self.system_repository.stdout
def commit(self, commit_message: str):
self.system_repository.run_checked('git', 'commit', '-m', commit_message)
return self.system_repository.stdout
def push(self):
self.system_repository.run_checked('git', 'push')
return self.system_repository.stdout
def checkout(self, branch: str):
self.system_repository.run_checked('git', 'checkout', branch)
return self.system_repository.stdout

View file

@ -41,7 +41,7 @@ class ReleaseMixin(DevopsBuild):
self.bump_version = self.release_version.create_bump_version()
def prepare_release(self):
prepare_release_service = PrepareReleaseService(self.version_repo, self.git_repo, self.config_file, self.main_branch)
prepare_release_service = PrepareReleaseService(self.version_repo, self.config_file, self.main_branch)
if self.release_version is None or self.bump_version is None:
raise Exception('prepare_release was called before init_release')
@ -49,6 +49,6 @@ class ReleaseMixin(DevopsBuild):
prepare_release_service.write_and_commit_release(self.release_version)
prepare_release_service.write_and_commit_bump(self.bump_version)
def tag_and_push_release(self):
def tag_and_push(self):
tag_and_push_release_service = TagAndPushReleaseService(self.git_repo)
tag_and_push_release_service.tag_and_push_release(self.release_version)

View file

@ -64,6 +64,6 @@ class TagAndPushReleaseService():
annotation = 'v' + release_version.get_version_string()
message = 'Release ' + annotation
self.git_repository.tag_annotated(annotation, message, 1)
# self.git_repository.push()
self.git_repository.push()