mirror of
https://github.com/frappe/bench.git
synced 2024-11-14 17:24:04 +00:00
fix(release): handle release for multiple branches
This commit is contained in:
parent
d88a327dee
commit
dd78011717
@ -15,13 +15,14 @@ import click
|
|||||||
|
|
||||||
branches_to_update = {
|
branches_to_update = {
|
||||||
'develop': [],
|
'develop': [],
|
||||||
'hotfix': ['develop']
|
'version-11-hotfix': [],
|
||||||
|
'version-12-hotfix': [],
|
||||||
}
|
}
|
||||||
|
|
||||||
github_username = None
|
github_username = None
|
||||||
github_password = None
|
github_password = None
|
||||||
|
|
||||||
def release(bench_path, app, bump_type, from_branch='develop', to_branch='master',
|
def release(bench_path, app, bump_type, from_branch, to_branch,
|
||||||
remote='upstream', owner='frappe', repo_name=None, frontport=True):
|
remote='upstream', owner='frappe', repo_name=None, frontport=True):
|
||||||
|
|
||||||
confirm_testing()
|
confirm_testing()
|
||||||
@ -91,7 +92,7 @@ def bump(bench_path, app, bump_type, from_branch, to_branch, remote, owner, repo
|
|||||||
create_github_release(repo_path, tag_name, message, remote=remote, owner=owner, repo_name=repo_name, prerelease=prerelease)
|
create_github_release(repo_path, tag_name, message, remote=remote, owner=owner, repo_name=repo_name, prerelease=prerelease)
|
||||||
print('Released {tag} for {repo_path}'.format(tag=tag_name, repo_path=repo_path))
|
print('Released {tag} for {repo_path}'.format(tag=tag_name, repo_path=repo_path))
|
||||||
|
|
||||||
def update_branches_and_check_for_changelog(repo_path, from_branch='develop', to_branch='master', remote='upstream'):
|
def update_branches_and_check_for_changelog(repo_path, from_branch, to_branch, remote='upstream'):
|
||||||
|
|
||||||
update_branch(repo_path, to_branch, remote=remote)
|
update_branch(repo_path, to_branch, remote=remote)
|
||||||
update_branch(repo_path, from_branch, remote=remote)
|
update_branch(repo_path, from_branch, remote=remote)
|
||||||
@ -116,7 +117,7 @@ def check_for_unmerged_changelog(repo_path):
|
|||||||
if os.path.exists(current) and [f for f in os.listdir(current) if f != "readme.md"]:
|
if os.path.exists(current) and [f for f in os.listdir(current) if f != "readme.md"]:
|
||||||
raise Exception("Unmerged change log! in " + repo_path)
|
raise Exception("Unmerged change log! in " + repo_path)
|
||||||
|
|
||||||
def get_release_message(repo_path, from_branch='develop', to_branch='master', remote='upstream'):
|
def get_release_message(repo_path, from_branch, to_branch, remote='upstream'):
|
||||||
print('getting release message for', repo_path, 'comparing', to_branch, '...', from_branch)
|
print('getting release message for', repo_path, 'comparing', to_branch, '...', from_branch)
|
||||||
|
|
||||||
repo = git.Repo(repo_path)
|
repo = git.Repo(repo_path)
|
||||||
@ -127,7 +128,7 @@ def get_release_message(repo_path, from_branch='develop', to_branch='master', re
|
|||||||
if log:
|
if log:
|
||||||
return "* " + log.replace('\n', '\n* ')
|
return "* " + log.replace('\n', '\n* ')
|
||||||
|
|
||||||
def bump_repo(repo_path, bump_type, from_branch='develop', to_branch='master'):
|
def bump_repo(repo_path, bump_type, from_branch, to_branch):
|
||||||
current_version = get_current_version(repo_path, to_branch)
|
current_version = get_current_version(repo_path, to_branch)
|
||||||
new_version = get_bumped_version(current_version, bump_type)
|
new_version = get_bumped_version(current_version, bump_type)
|
||||||
|
|
||||||
@ -140,7 +141,7 @@ def get_current_version(repo_path, to_branch):
|
|||||||
# TODO clean this up!
|
# TODO clean this up!
|
||||||
version_key = '__version__'
|
version_key = '__version__'
|
||||||
|
|
||||||
if to_branch.lower() == 'master':
|
if to_branch.lower() in ['version-11', 'version-12']:
|
||||||
filename = os.path.join(repo_path, os.path.basename(repo_path), '__init__.py')
|
filename = os.path.join(repo_path, os.path.basename(repo_path), '__init__.py')
|
||||||
else:
|
else:
|
||||||
filename = os.path.join(repo_path, os.path.basename(repo_path), 'hooks.py')
|
filename = os.path.join(repo_path, os.path.basename(repo_path), 'hooks.py')
|
||||||
@ -194,7 +195,7 @@ def get_bumped_version(version, bump_type):
|
|||||||
return str(v)
|
return str(v)
|
||||||
|
|
||||||
def set_version(repo_path, version, to_branch):
|
def set_version(repo_path, version, to_branch):
|
||||||
if to_branch.lower() == 'master':
|
if to_branch.lower() in ['version-11', 'version-12']:
|
||||||
set_filename_version(os.path.join(repo_path, os.path.basename(repo_path),'__init__.py'), version, '__version__')
|
set_filename_version(os.path.join(repo_path, os.path.basename(repo_path),'__init__.py'), version, '__version__')
|
||||||
else:
|
else:
|
||||||
set_filename_version(os.path.join(repo_path, os.path.basename(repo_path),'hooks.py'), version, 'staging_version')
|
set_filename_version(os.path.join(repo_path, os.path.basename(repo_path),'hooks.py'), version, 'staging_version')
|
||||||
@ -237,14 +238,14 @@ def commit_changes(repo_path, new_version, to_branch):
|
|||||||
repo = git.Repo(repo_path)
|
repo = git.Repo(repo_path)
|
||||||
app_name = os.path.basename(repo_path)
|
app_name = os.path.basename(repo_path)
|
||||||
|
|
||||||
if to_branch.lower() == 'master':
|
if to_branch.lower() in ['version-11', 'version-12']:
|
||||||
repo.index.add([os.path.join(app_name, '__init__.py')])
|
repo.index.add([os.path.join(app_name, '__init__.py')])
|
||||||
else:
|
else:
|
||||||
repo.index.add([os.path.join(app_name, 'hooks.py')])
|
repo.index.add([os.path.join(app_name, 'hooks.py')])
|
||||||
|
|
||||||
repo.index.commit('bumped to version {}'.format(new_version))
|
repo.index.commit('bumped to version {}'.format(new_version))
|
||||||
|
|
||||||
def create_release(repo_path, new_version, from_branch='develop', to_branch='master', frontport=True):
|
def create_release(repo_path, new_version, from_branch, to_branch, frontport=True):
|
||||||
print('creating release for version', new_version)
|
print('creating release for version', new_version)
|
||||||
repo = git.Repo(repo_path)
|
repo = git.Repo(repo_path)
|
||||||
g = repo.git
|
g = repo.git
|
||||||
@ -283,7 +284,7 @@ def handle_merge_error(e, source, target):
|
|||||||
print('-'*80)
|
print('-'*80)
|
||||||
click.confirm('Have you manually resolved the error?', abort=True)
|
click.confirm('Have you manually resolved the error?', abort=True)
|
||||||
|
|
||||||
def push_release(repo_path, from_branch='develop', to_branch='master', remote='upstream'):
|
def push_release(repo_path, from_branch, to_branch, remote='upstream'):
|
||||||
print('pushing branches', to_branch, from_branch, 'of', repo_path)
|
print('pushing branches', to_branch, from_branch, 'of', repo_path)
|
||||||
repo = git.Repo(repo_path)
|
repo = git.Repo(repo_path)
|
||||||
g = repo.git
|
g = repo.git
|
||||||
|
Loading…
Reference in New Issue
Block a user