Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Auto release] fix changelog format for new service #23118

Merged
merged 13 commits into from
Feb 19, 2022
15 changes: 12 additions & 3 deletions scripts/auto_release/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,9 @@ def edit_file_for_pprint_name(content: List[str]):
content[i] = content[i].replace('MyService', pprint_name)

for file in os.listdir(self.sdk_code_path()):
if os.path.isfile(file):
modify_file(file, edit_file_for_pprint_name)
file_path = str(Path(self.sdk_code_path()) / file)
if os.path.isfile(file_path):
modify_file(file_path, edit_file_for_pprint_name)
log(f' replace \"MyService\" with \"{pprint_name}\" successfully ')

def get_all_files_under_package_folder(self) -> List[str]:
Expand Down Expand Up @@ -367,7 +368,7 @@ def edit_changelog_for_new_service(self):
def edit_changelog_for_new_service_proc(content: List[str]):
for i in range(0, len(content)):
if '##' in content[i]:
content[i] = f'## {self.next_version}({current_time()})'
content[i] = f'## {self.next_version}({current_time()})\n'
break

modify_file(str(Path(self.sdk_code_path()) / 'CHANGELOG.md'), edit_changelog_for_new_service_proc)
Expand Down Expand Up @@ -410,6 +411,12 @@ def check_file(self):
def sdk_code_path(self) -> str:
return str(Path(f'sdk/{self.sdk_folder}/azure-mgmt-{self.package_name}'))

@property
def is_single_path(self) -> bool:
path = str(Path(f'sdk/{self.sdk_folder}'))
num = sum([os.path.isdir(str(Path(f'{path}/{listx}'))) for listx in os.listdir(path)])
return num == 1

@return_origin_path
def install_package_locally(self):
os.chdir(self.sdk_code_path())
Expand Down Expand Up @@ -454,6 +461,8 @@ def create_pr_proc(self):
pr_head = "{}:{}".format(os.getenv('USR_NAME'), self.new_branch)
pr_base = 'main'
pr_body = "{} \n{} \n{}".format(self.issue_link, self.test_result, self.pipeline_link)
if not self.is_single_path:
pr_body += f'\nBuildTargetingString\n azure-mgmt-{self.package_name}\nSkip.CreateApiReview\ntrue'
res_create = api.pulls.create(pr_title, pr_head, pr_base, pr_body)

# Add issue link on PR
Expand Down