Skip to content

Commit fa28b5f

Browse files
kesmit13claude
andcommitted
Add interactive commit/push functionality to bump_version script
Enhances the bump_version.py script with interactive user prompts for committing and pushing changes automatically after version bumping. Changes include: - Add webbrowser import for opening GitHub Actions - Add prompt_yes_no() function for user confirmation dialogs - Add execute_commit_and_push() function to handle git operations - Add open_actions_page() function to open GitHub Actions in browser - Update main() to prompt user after staging files with option to commit/push This streamlines the release workflow by allowing users to commit and push directly from the script while still maintaining the option to do it manually. πŸ€– Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 68b41bc commit fa28b5f

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
# Try to import tomllib (Python 3.11+) or fall back to tomli
@@ -246,6 +247,92 @@ def edit_content(content: str, description: str = 'content') -> str | None:
246247
pass
247248

248249

250+
def prompt_yes_no(question: str, default: bool = True) -> bool:
251+
"""Prompt user for yes/no input with a default value.
252+
253+
Args:
254+
question: The question to ask the user
255+
default: Default value (True for yes, False for no)
256+
257+
Returns:
258+
True for yes, False for no
259+
"""
260+
prompt_suffix = '[Y/n]' if default else '[y/N]'
261+
prompt = f'{question} {prompt_suffix}: '
262+
263+
while True:
264+
response = input(prompt).strip().lower()
265+
266+
if not response:
267+
return default
268+
269+
if response in ('y', 'yes'):
270+
return True
271+
elif response in ('n', 'no'):
272+
return False
273+
else:
274+
print('Please answer y or n')
275+
276+
277+
def execute_commit_and_push(new_version: str) -> bool:
278+
"""Execute git commit and push commands.
279+
280+
Args:
281+
new_version: The new version being released
282+
283+
Returns:
284+
True if successful, False otherwise
285+
"""
286+
commit_msg = f'Prepare for v{new_version} release'
287+
288+
try:
289+
# Execute git commit
290+
status(f'πŸ“ Committing changes: {commit_msg}')
291+
result = subprocess.run(
292+
['git', 'commit', '-m', commit_msg],
293+
capture_output=True,
294+
text=True,
295+
)
296+
297+
if result.returncode != 0:
298+
print(f'❌ Error committing changes: {result.stderr}', file=sys.stderr)
299+
return False
300+
301+
status('βœ… Changes committed successfully')
302+
303+
# Execute git push
304+
status('πŸš€ Pushing to remote repository...')
305+
result = subprocess.run(
306+
['git', 'push'],
307+
capture_output=True,
308+
text=True,
309+
)
310+
311+
if result.returncode != 0:
312+
print(f'❌ Error pushing changes: {result.stderr}', file=sys.stderr)
313+
return False
314+
315+
status('βœ… Changes pushed successfully')
316+
return True
317+
318+
except Exception as e:
319+
print(f'❌ Unexpected error: {e}', file=sys.stderr)
320+
return False
321+
322+
323+
def open_actions_page() -> None:
324+
"""Open the GitHub Actions page in the default web browser."""
325+
actions_url = 'https://github.com/singlestore-labs/sqlalchemy-singlestoredb/actions'
326+
status(f'🌐 Opening GitHub Actions page: {actions_url}')
327+
328+
try:
329+
webbrowser.open(actions_url)
330+
status('βœ… Browser opened successfully')
331+
except Exception as e:
332+
print(f'⚠️ Could not open browser: {e}', file=sys.stderr)
333+
print(f' Please visit: {actions_url}', file=sys.stderr)
334+
335+
249336
def prepare_whatsnew_content(new_version: str, summary: str) -> str:
250337
"""Prepare the content for the new release section."""
251338
today = datetime.date.today()
@@ -428,11 +515,30 @@ def main() -> None:
428515
print('=' * 50, file=sys.stderr)
429516
print(f'πŸŽ‰ Version bump completed successfully in {total_elapsed:.1f}s!', file=sys.stderr)
430517
print(f'πŸ“ Version: {current_version} β†’ {new_version}', file=sys.stderr)
431-
print('πŸš€ Next steps:', file=sys.stderr)
432-
print(' πŸ“„ git commit -m "Prepare for v{} release" && git push'.format(new_version), file=sys.stderr)
433-
print(' πŸ“„ Run Smoke test <https://github.com/singlestore-labs/sqlalchemy-singlestoredb/actions/workflows/smoke-test.yml>', file=sys.stderr)
434-
print(' πŸ“„ Run Coverage tests <https://github.com/singlestore-labs/sqlalchemy-singlestoredb/actions/workflows/coverage.yml>', file=sys.stderr)
435-
print(' πŸ“„ Run resources/create_release.py', file=sys.stderr)
518+
print('', file=sys.stderr)
519+
520+
# Prompt user to commit and push
521+
if prompt_yes_no('Do you want to commit and push now?', default=True):
522+
print('', file=sys.stderr)
523+
if execute_commit_and_push(new_version):
524+
print('', file=sys.stderr)
525+
open_actions_page()
526+
print('', file=sys.stderr)
527+
print('πŸš€ Next steps:', file=sys.stderr)
528+
print(' πŸ“„ Run Coverage tests <https://github.com/singlestore-labs/sqlalchemy-singlestoredb/actions/workflows/coverage.yml>', file=sys.stderr)
529+
print(' πŸ“„ Run Smoke test <https://github.com/singlestore-labs/sqlalchemy-singlestoredb/actions/workflows/smoke-test.yml>', file=sys.stderr)
530+
print(' πŸ“„ Run resources/create_release.py', file=sys.stderr)
531+
else:
532+
print('', file=sys.stderr)
533+
print('⚠️ Commit/push failed. Please manually run:', file=sys.stderr)
534+
print(' πŸ“„ git commit -m "Prepare for v{} release" && git push'.format(new_version), file=sys.stderr)
535+
else:
536+
print('', file=sys.stderr)
537+
print('πŸš€ Next steps:', file=sys.stderr)
538+
print(' πŸ“„ git commit -m "Prepare for v{} release" && git push'.format(new_version), file=sys.stderr)
539+
print(' πŸ“„ Run Coverage tests <https://github.com/singlestore-labs/sqlalchemy-singlestoredb/actions/workflows/coverage.yml>', file=sys.stderr)
540+
print(' πŸ“„ Run Smoke test <https://github.com/singlestore-labs/sqlalchemy-singlestoredb/actions/workflows/smoke-test.yml>', file=sys.stderr)
541+
print(' πŸ“„ Run resources/create_release.py', file=sys.stderr)
436542

437543

438544
if __name__ == '__main__':

0 commit comments

Comments
Β (0)