Skip to content

Commit

Permalink
chore: make tui nicer
Browse files Browse the repository at this point in the history
Signed-off-by: Mark Phelps <[email protected]>
  • Loading branch information
markphelps committed Oct 21, 2024
1 parent 62dbd44 commit 66138e9
Showing 1 changed file with 38 additions and 21 deletions.
59 changes: 38 additions & 21 deletions release/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,14 @@ def bump_version(version: str, bump_type: str) -> str:

def update_sdk_versions(bump_type='patch', sdks_to_update=None):
all_sdk_dirs = [
'flipt-client-go', 'flipt-client-java', 'flipt-client-node',
'flipt-client-browser', 'flipt-client-react', 'flipt-client-dart',
'flipt-client-python', 'flipt-client-ruby'
'flipt-client-go',
'flipt-client-java',
'flipt-client-node',
'flipt-client-browser',
'flipt-client-react',
'flipt-client-dart',
'flipt-client-python',
'flipt-client-ruby'
]

sdk_dirs = sdks_to_update if sdks_to_update else all_sdk_dirs
Expand Down Expand Up @@ -75,28 +80,27 @@ def tag_and_push_versions(versions):
sdk.tag_and_push(new_version)

def get_sdk_selection(all_sdk_dirs):
sdk_display_names = {
'flipt-client-go': 'Go',
'flipt-client-java': 'Java',
'flipt-client-node': 'Node.js',
'flipt-client-browser': 'Browser',
'flipt-client-react': 'React',
'flipt-client-dart': 'Dart',
'flipt-client-python': 'Python',
'flipt-client-ruby': 'Ruby'
}

selected_sdks = checkboxlist_dialog(
title="Select SDKs to release",
text="Choose the SDKs you want to release (Space to select, Enter to confirm):",
values=[(sdk, sdk) for sdk in all_sdk_dirs] + [('all', 'All SDKs')],
values=[(sdk, sdk_display_names.get(sdk, sdk)) for sdk in all_sdk_dirs] + [('all', 'All SDKs')],
).run()

if 'all' in selected_sdks:
return all_sdk_dirs
return selected_sdks

def get_bump_type():
bump_type = radiolist_dialog(
title="Select version bump type",
text="Choose the type of version bump:",
values=[
("patch", "Patch (0.0.X)"),
("minor", "Minor (0.X.0)"),
("major", "Major (X.0.0)"),
],
).run()
return bump_type

def get_action():
action = radiolist_dialog(
title="Select action",
Expand All @@ -109,6 +113,18 @@ def get_action():
).run()
return action

def get_bump_type():
bump_type = radiolist_dialog(
title="Select version bump type",
text="Choose the type of version bump:",
values=[
("patch", "Patch (0.0.X)"),
("minor", "Minor (0.X.0)"),
("major", "Major (X.0.0)"),
],
).run()
return bump_type

def main():
all_sdk_dirs = [
'flipt-client-go', 'flipt-client-java', 'flipt-client-node',
Expand All @@ -121,11 +137,6 @@ def main():
print("No SDKs selected. Exiting.")
return

bump_type = get_bump_type()
if not bump_type:
print("No bump type selected. Exiting.")
return

action = get_action()
if not action:
print("No action selected. Exiting.")
Expand All @@ -134,6 +145,10 @@ def main():
updated_versions = {}

if action in ['update', 'both']:
bump_type = get_bump_type()
if not bump_type:
print("No bump type selected. Exiting.")
return
updated_versions = update_sdk_versions(bump_type, selected_sdks)

if action in ['push', 'both']:
Expand All @@ -143,6 +158,8 @@ def main():
sdk_path = os.path.join('..', sdk_dir)
sdk = get_sdk(sdk_dir, sdk_path)
updated_versions[sdk_dir] = sdk.get_current_version()
if isinstance(sdk, MuslSupportSDK):
updated_versions[f"{sdk_dir}-musl"] = sdk.get_current_musl_version()
tag_and_push_versions(updated_versions)

print(f"{Fore.GREEN}Action '{action}' completed successfully.{Style.RESET_ALL}")
Expand Down

0 comments on commit 66138e9

Please sign in to comment.