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] remove surplus code #24349

Merged
merged 3 commits into from
May 23, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 8 additions & 27 deletions scripts/auto_release/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ def __init__(self):
self.pr_number = 0
self.container_name = ''
self.private_package_link = [] # List[str]
self.tag_is_stable = False

@return_origin_path
def get_latest_commit_in_swagger_repo(self) -> str:
Expand Down Expand Up @@ -183,9 +184,14 @@ def generate_code(self):
with open(self.autorest_result, 'w') as file:
json.dump(input_data, file)

# generate code
# generate code(be careful about the order)
print_exec('python scripts/dev_setup.py -p azure-core')
print_check(f'python -m packaging_tools.auto_codegen {self.autorest_result} {self.autorest_result}')

generate_result = self.get_autorest_result()
self.tag_is_stable = list(generate_result.values())[0]['tagIsStable']
log(f"tag_is_stable is {self.tag_is_stable}")

print_check(f'python -m packaging_tools.auto_package {self.autorest_result} {self.autorest_result}')

def get_package_name_with_autorest_result(self):
Expand Down Expand Up @@ -282,33 +288,8 @@ def get_all_files_under_package_folder(self) -> List[str]:
all_files(self.sdk_code_path(), files)
return files

def judge_tag(self) -> bool:
files = self.get_all_files_under_package_folder()
default_api_version = '' # for multi-api
api_version = '' # for single-api
for file in files:
if '.py' not in file or '.pyc' in file:
continue
try:
with open(file, 'r') as file_in:
list_in = file_in.readlines()
except:
_LOG.info(f'can not open {file}')
continue

for line in list_in:
if line.find('DEFAULT_API_VERSION = ') > -1:
default_api_version += line.split('=')[-1].strip('\n') # collect all default api version
if default_api_version == '' and line.find('api_version = ') > -1:
api_version += line.split('=')[-1].strip('\n') # collect all single api version
if default_api_version != '':
log(f'find default api version:{default_api_version}')
return 'preview' in default_api_version
log(f'find single api version:{api_version}')
return 'preview' in api_version

def calculate_next_version_proc(self, last_version: str):
preview_tag = self.judge_tag()
preview_tag = not self.tag_is_stable
changelog = self.get_changelog()
if changelog == '':
return '0.0.0'
Expand Down