Skip to content

Commit

Permalink
[auto_release] remove surplus code (#24349)
Browse files Browse the repository at this point in the history
* remove surplus code

* Update main.py

Co-authored-by: Jiefeng Chen <51037443+BigCat20196@users.noreply.github.com>
  • Loading branch information
msyyc and BigCat20196 authored May 23, 2022
1 parent c76e5f0 commit eca061c
Showing 1 changed file with 8 additions and 27 deletions.
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

0 comments on commit eca061c

Please sign in to comment.