Skip to content

Commit 5d681ef

Browse files
kesmit13claude
andcommitted
Add interactive commit/push prompt to bump_version script
- Add prompt_yes_no() helper for Y/n prompts with defaults - Add execute_commit_and_push() to automate git commit and push - Add open_actions_page() to open GitHub Actions in browser - Update main() to prompt user after version bump completion - Default to Yes for committing and pushing changes - Automatically open Actions page after successful push 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 3a28111 commit 5d681ef

File tree

1 file changed

+111
-5
lines changed

1 file changed

+111
-5
lines changed

resources/bump_version.py

Lines changed: 111 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import sys
2323
import tempfile
2424
import time
25+
import webbrowser
2526
from pathlib import Path
2627

2728

@@ -234,6 +235,92 @@ def edit_content(content: str, description: str = 'content') -> str | None:
234235
pass
235236

236237

238+
def prompt_yes_no(question: str, default: bool = True) -> bool:
239+
"""Prompt user for yes/no input with a default value.
240+
241+
Args:
242+
question: The question to ask the user
243+
default: Default value (True for yes, False for no)
244+
245+
Returns:
246+
True for yes, False for no
247+
"""
248+
prompt_suffix = '[Y/n]' if default else '[y/N]'
249+
prompt = f'{question} {prompt_suffix}: '
250+
251+
while True:
252+
response = input(prompt).strip().lower()
253+
254+
if not response:
255+
return default
256+
257+
if response in ('y', 'yes'):
258+
return True
259+
elif response in ('n', 'no'):
260+
return False
261+
else:
262+
print('Please answer y or n')
263+
264+
265+
def execute_commit_and_push(new_version: str) -> bool:
266+
"""Execute git commit and push commands.
267+
268+
Args:
269+
new_version: The new version being released
270+
271+
Returns:
272+
True if successful, False otherwise
273+
"""
274+
commit_msg = f'Prepare for v{new_version} release'
275+
276+
try:
277+
# Execute git commit
278+
status(f'📝 Committing changes: {commit_msg}')
279+
result = subprocess.run(
280+
['git', 'commit', '-m', commit_msg],
281+
capture_output=True,
282+
text=True,
283+
)
284+
285+
if result.returncode != 0:
286+
print(f'❌ Error committing changes: {result.stderr}', file=sys.stderr)
287+
return False
288+
289+
status('✅ Changes committed successfully')
290+
291+
# Execute git push
292+
status('🚀 Pushing to remote repository...')
293+
result = subprocess.run(
294+
['git', 'push'],
295+
capture_output=True,
296+
text=True,
297+
)
298+
299+
if result.returncode != 0:
300+
print(f'❌ Error pushing changes: {result.stderr}', file=sys.stderr)
301+
return False
302+
303+
status('✅ Changes pushed successfully')
304+
return True
305+
306+
except Exception as e:
307+
print(f'❌ Unexpected error: {e}', file=sys.stderr)
308+
return False
309+
310+
311+
def open_actions_page() -> None:
312+
"""Open the GitHub Actions page in the default web browser."""
313+
actions_url = 'https://github.com/singlestore-labs/singlestoredb-python/actions'
314+
status(f'🌐 Opening GitHub Actions page: {actions_url}')
315+
316+
try:
317+
webbrowser.open(actions_url)
318+
status('✅ Browser opened successfully')
319+
except Exception as e:
320+
print(f'⚠️ Could not open browser: {e}', file=sys.stderr)
321+
print(f' Please visit: {actions_url}', file=sys.stderr)
322+
323+
237324
def prepare_whatsnew_content(new_version: str, summary: str) -> str:
238325
"""Prepare the content for the new release section."""
239326
today = datetime.date.today()
@@ -424,11 +511,30 @@ def main() -> None:
424511
print('=' * 50, file=sys.stderr)
425512
print(f'🎉 Version bump completed successfully in {total_elapsed:.1f}s!', file=sys.stderr)
426513
print(f'📝 Version: {current_version}{new_version}', file=sys.stderr)
427-
print('🚀 Next steps:', file=sys.stderr)
428-
print(' 📄 git commit -m "Prepare for v{} release" && git push'.format(new_version), file=sys.stderr)
429-
print(' 📄 Run Coverage tests <https://github.com/singlestore-labs/singlestoredb-python/actions/workflows/coverage.yml>', file=sys.stderr)
430-
print(' 📄 Run Smoke test <https://github.com/singlestore-labs/singlestoredb-python/actions/workflows/smoke-test.yml>', file=sys.stderr)
431-
print(' 📄 Run resources/create_release.py', file=sys.stderr)
514+
print('', file=sys.stderr)
515+
516+
# Prompt user to commit and push
517+
if prompt_yes_no('Do you want to commit and push now?', default=True):
518+
print('', file=sys.stderr)
519+
if execute_commit_and_push(new_version):
520+
print('', file=sys.stderr)
521+
open_actions_page()
522+
print('', file=sys.stderr)
523+
print('🚀 Next steps:', file=sys.stderr)
524+
print(' 📄 Run Coverage tests <https://github.com/singlestore-labs/singlestoredb-python/actions/workflows/coverage.yml>', file=sys.stderr)
525+
print(' 📄 Run Smoke test <https://github.com/singlestore-labs/singlestoredb-python/actions/workflows/smoke-test.yml>', file=sys.stderr)
526+
print(' 📄 Run resources/create_release.py', file=sys.stderr)
527+
else:
528+
print('', file=sys.stderr)
529+
print('⚠️ Commit/push failed. Please manually run:', file=sys.stderr)
530+
print(' 📄 git commit -m "Prepare for v{} release" && git push'.format(new_version), file=sys.stderr)
531+
else:
532+
print('', file=sys.stderr)
533+
print('🚀 Next steps:', file=sys.stderr)
534+
print(' 📄 git commit -m "Prepare for v{} release" && git push'.format(new_version), file=sys.stderr)
535+
print(' 📄 Run Coverage tests <https://github.com/singlestore-labs/singlestoredb-python/actions/workflows/coverage.yml>', file=sys.stderr)
536+
print(' 📄 Run Smoke test <https://github.com/singlestore-labs/singlestoredb-python/actions/workflows/smoke-test.yml>', file=sys.stderr)
537+
print(' 📄 Run resources/create_release.py', file=sys.stderr)
432538

433539

434540
if __name__ == '__main__':

0 commit comments

Comments
 (0)