mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-10-14 16:57:41 -04:00
Add do-not-push flag in the release script (#673)
This flag enables a user to only make local commits for various steps and not push them to the remote. Signed-off-by: Gaurav Aggarwal <aggarg@amazon.com>
This commit is contained in:
parent
9f426a4a54
commit
455793a295
2 changed files with 70 additions and 48 deletions
40
.github/scripts/release.py
vendored
40
.github/scripts/release.py
vendored
|
@ -61,7 +61,7 @@ def printDot(op_code, cur_count, max_count=None, message=''):
|
|||
print('.', end='')
|
||||
|
||||
class BaseRelease:
|
||||
def __init__(self, mGit, version, commit='HEAD', git_ssh=False, git_org='FreeRTOS', repo_path=None, branch='main'):
|
||||
def __init__(self, mGit, version, commit='HEAD', git_ssh=False, git_org='FreeRTOS', repo_path=None, branch='main', do_not_push=False):
|
||||
self.version = version
|
||||
self.tag_msg = 'Autocreated by FreeRTOS Git Tools.'
|
||||
self.commit = commit
|
||||
|
@ -73,6 +73,7 @@ class BaseRelease:
|
|||
self.commit_msg_prefix = '[AUTO][RELEASE]: '
|
||||
self.description = ''
|
||||
self.mGit = mGit # Save a handle to the authed git session
|
||||
self.do_not_push = do_not_push
|
||||
|
||||
if self.repo_path:
|
||||
info('Sourcing "%s" to make local commits' % self.repo_path)
|
||||
|
@ -112,6 +113,9 @@ class BaseRelease:
|
|||
print(r)
|
||||
|
||||
def pushLocalCommits(self, force=False):
|
||||
if self.do_not_push:
|
||||
info('Skipping to push local commits...')
|
||||
else:
|
||||
info('Pushing local commits...')
|
||||
push_infos = self.local_repo.remote('origin').push(force=force)
|
||||
|
||||
|
@ -120,6 +124,9 @@ class BaseRelease:
|
|||
assert 0 == push_info.flags & PushInfo.ERROR, 'Failed to push changes to ' + str(push_info)
|
||||
|
||||
def pushTag(self):
|
||||
if self.do_not_push:
|
||||
info('Skipping to push tag "%s"' % self.tag)
|
||||
else:
|
||||
# Overwrite existing tags
|
||||
info('Pushing tag "%s"' % self.tag)
|
||||
tag_info = self.local_repo.create_tag(self.tag, message=self.tag_msg, force=True)
|
||||
|
@ -209,8 +216,8 @@ class BaseRelease:
|
|||
|
||||
|
||||
class KernelRelease(BaseRelease):
|
||||
def __init__(self, mGit, version, commit='HEAD', git_ssh=False, git_org='FreeRTOS', repo_path=None, branch='main', main_br_version=''):
|
||||
super().__init__(mGit, version, commit=commit, git_ssh=git_ssh, git_org=git_org, repo_path=repo_path, branch=branch)
|
||||
def __init__(self, mGit, version, commit='HEAD', git_ssh=False, git_org='FreeRTOS', repo_path=None, branch='main', main_br_version='',do_not_push=False):
|
||||
super().__init__(mGit, version, commit=commit, git_ssh=git_ssh, git_org=git_org, repo_path=repo_path, branch=branch, do_not_push=do_not_push)
|
||||
|
||||
self.repo_name = '%s/FreeRTOS-Kernel' % self.git_org
|
||||
self.repo = mGit.get_repo(self.repo_name)
|
||||
|
@ -246,6 +253,9 @@ class KernelRelease(BaseRelease):
|
|||
'''
|
||||
Creates/Overwrites release identified by target tag
|
||||
'''
|
||||
if self.do_not_push:
|
||||
info('Skipping creating git release endpoint for "%s"...' % self.tag)
|
||||
else:
|
||||
# If this release already exists, delete it
|
||||
try:
|
||||
release_queried = self.repo.get_release(self.tag)
|
||||
|
@ -299,8 +309,8 @@ class KernelRelease(BaseRelease):
|
|||
|
||||
|
||||
class FreertosRelease(BaseRelease):
|
||||
def __init__(self, mGit, version, commit, git_ssh=False, git_org='FreeRTOS', repo_path=None, branch='main'):
|
||||
super().__init__(mGit, version, commit, git_ssh=git_ssh, git_org=git_org, repo_path=repo_path, branch=branch)
|
||||
def __init__(self, mGit, version, commit, git_ssh=False, git_org='FreeRTOS', repo_path=None, branch='main',do_not_push=False):
|
||||
super().__init__(mGit, version, commit, git_ssh=git_ssh, git_org=git_org, repo_path=repo_path, branch=branch, do_not_push=do_not_push)
|
||||
|
||||
self.repo_name = '%s/FreeRTOS' % self.git_org
|
||||
self.repo = mGit.get_repo(self.repo_name)
|
||||
|
@ -406,6 +416,9 @@ class FreertosRelease(BaseRelease):
|
|||
'''
|
||||
Creates/Overwrites release identified by target tag
|
||||
'''
|
||||
if self.do_not_push:
|
||||
info('Skipping creating git release endpoint for "%s"...' % self.tag)
|
||||
else:
|
||||
# If this release already exists, delete it
|
||||
try:
|
||||
release_queried = self.repo.get_release(self.tag)
|
||||
|
@ -521,6 +534,11 @@ def configure_argparser():
|
|||
default=False,
|
||||
help='Run unit tests.')
|
||||
|
||||
parser.add_argument('--do-not-push',
|
||||
action='store_true',
|
||||
default=False,
|
||||
help='Do not push the changes but only make local commits.')
|
||||
|
||||
return parser
|
||||
|
||||
def main():
|
||||
|
@ -528,6 +546,7 @@ def main():
|
|||
args = cmd.parse_args()
|
||||
|
||||
# Auth
|
||||
if not args.do_not_push:
|
||||
assert 'GITHUB_TOKEN' in os.environ, 'Set env{GITHUB_TOKEN} to an authorized git PAT'
|
||||
mGit = Github(os.environ.get('GITHUB_TOKEN'))
|
||||
|
||||
|
@ -541,7 +560,7 @@ def main():
|
|||
logIndentPush()
|
||||
rel_kernel = KernelRelease(mGit, args.new_kernel_version, args.kernel_commit, git_ssh=args.use_git_ssh,
|
||||
git_org=args.git_org, repo_path=args.kernel_repo_path, branch=args.kernel_repo_branch,
|
||||
main_br_version=args.new_kernel_main_br_version)
|
||||
main_br_version=args.new_kernel_main_br_version, do_not_push=args.do_not_push)
|
||||
rel_kernel.autoRelease()
|
||||
logIndentPop()
|
||||
|
||||
|
@ -549,7 +568,8 @@ def main():
|
|||
info('Starting core release...')
|
||||
logIndentPush()
|
||||
rel_freertos = FreertosRelease(mGit, args.new_core_version, args.core_commit, git_ssh=args.use_git_ssh,
|
||||
git_org=args.git_org, repo_path=args.core_repo_path, branch=args.core_repo_branch)
|
||||
git_org=args.git_org, repo_path=args.core_repo_path, branch=args.core_repo_branch,
|
||||
do_not_push=args.do_not_push)
|
||||
rel_freertos.autoRelease()
|
||||
logIndentPop()
|
||||
|
||||
|
@ -557,7 +577,8 @@ def main():
|
|||
if args.rollback_kernel_version:
|
||||
info('Starting kernel rollback...')
|
||||
rel_kernel = KernelRelease(mGit, args.rollback_kernel_version, args.kernel_commit, git_ssh=args.use_git_ssh,
|
||||
git_org=args.git_org, repo_path=args.kernel_repo_path, branch=args.kernel_repo_branch)
|
||||
git_org=args.git_org, repo_path=args.kernel_repo_path, branch=args.kernel_repo_branch,
|
||||
do_not_push=args.do_not_push)
|
||||
logIndentPush()
|
||||
rel_kernel.restorePriorToRelease()
|
||||
logIndentPop()
|
||||
|
@ -566,7 +587,8 @@ def main():
|
|||
info('Starting core rollback...')
|
||||
logIndentPush()
|
||||
rel_freertos = FreertosRelease(mGit, args.rollback_core_version, args.core_commit, git_ssh=args.use_git_ssh,
|
||||
git_org=args.git_org, repo_path=args.core_repo_path, branch=args.core_repo_branch)
|
||||
git_org=args.git_org, repo_path=args.core_repo_path, branch=args.core_repo_branch,
|
||||
do_not_push=args.do_not_push)
|
||||
rel_freertos.restorePriorToRelease()
|
||||
logIndentPop()
|
||||
|
||||
|
|
2
.github/scripts/versioning.py
vendored
2
.github/scripts/versioning.py
vendored
|
@ -199,7 +199,7 @@ def process_components(root_dir, components, exclude_dirs=[]):
|
|||
def update_freertos_version_macros(path_macrofile, version_str, major, minor, build):
|
||||
with open(path_macrofile, encoding='utf-8', errors='ignore', newline='') as macro_file:
|
||||
macro_file_content = macro_file.read()
|
||||
match_version = re.search(r'(^.*#define *tskKERNEL_VERSION_NUMBER *(".*")$)', macro_file_content, re.MULTILINE)
|
||||
match_version = re.search(r'(^.*#define *tskKERNEL_VERSION_NUMBER *(.*)$)', macro_file_content, re.MULTILINE)
|
||||
match_major = re.search(r'(^.*#define *tskKERNEL_VERSION_MAJOR *(.*)$)', macro_file_content, re.MULTILINE)
|
||||
match_minor = re.search(r'(^.*#define *tskKERNEL_VERSION_MINOR *(.*)$)', macro_file_content, re.MULTILINE)
|
||||
match_build = re.search(r'(^.*#define *tskKERNEL_VERSION_BUILD *(.*)$)', macro_file_content, re.MULTILINE)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue