A Python script that automates the creation of release pull requests across multiple Git repositories using GitHub CLI.
- ✅ Checks for differences between
developandmasterbranches - ✅ Creates release pull requests when changes are detected
- ✅ Logs pull request URLs to console
- ✅ Handles repositories with no changes gracefully
- ✅ Supports custom repository lists
- ✅ Comprehensive error handling and logging
- ✅ NEW: AI-powered commit summarization using Gemini API
- ✅ NEW: Automatic ticket detection (CHQ-XXXX format)
- ✅ NEW: Database migration file detection
- ✅ NEW: Enhanced PR descriptions with AI summaries
- Python 3.6+ installed on your system
- GitHub CLI installed and authenticated
- Git installed
# macOS
brew install gh
# Ubuntu/Debian
sudo apt install gh
# Windows
winget install GitHub.cligh auth loginThe release manager can use Google's Gemini API to automatically summarize commit changes and generate intelligent release descriptions.
-
Get a Gemini API Key:
- Visit Google AI Studio
- Create a new API key
-
Set the Environment Variable:
export GEMINI_API_KEY='your-api-key-here'
-
Install the Required Package:
pip install google-generativeai
-
Run the Setup Script (optional):
python setup_gemini.py
Edit config.py to customize AI behavior:
# Gemini API configuration
GEMINI_API_KEY = os.getenv("GEMINI_API_KEY", "") # Set via environment variable
GEMINI_MODEL = "gemini-1.5-flash" # Model to use for summarization
GEMINI_ENABLED = True # Set to False to disable AI summarization- Intelligent Commit Grouping: Groups related changes together
- Feature Highlights: Identifies major features, bug fixes, and improvements
- Professional Summaries: Generates release notes suitable for stakeholders
- Enhanced PR Descriptions: Includes AI summaries in pull request bodies
python release_manager.py 1.2.3This will process all repositories in the hard-coded list and create release pull requests for version 1.2.3.
python release_manager.py 1.2.3 --repos "org/repo1" "org/repo2" "org/repo3"chmod +x release_manager.py
./release_manager.py 1.2.3Edit the repositories list in the ReleaseManager class:
self.repositories = [
"your-org/repo1",
"your-org/repo2",
"your-org/repo3",
# Add more repositories as needed
]The script expects:
developbranch as the source branchmasterbranch as the target branch
If your repositories use different branch names, modify the check_diff_between_branches method.
-
Repository Processing: For each repository in the list:
- Clones the repository to a temporary directory
- Fetches the latest changes from both
developandmasterbranches
-
Diff Detection:
- Compares
developandmasterbranches - Checks if there are any file changes between the branches
- Compares
-
Pull Request Creation (if changes detected):
- Creates a new branch:
release/{version} - Creates a pull request from
developtomaster - Includes a detailed PR description with checklist
- Creates a new branch:
-
Cleanup:
- Removes temporary cloned repositories
- Provides a summary of results
🚀 Starting Release Manager for version 1.2.3
📅 2024-01-15 10:30:00
📦 Processing 3 repositories
Processing repository: your-org/repo1
Cloning your-org/repo1...
Found 5 changed files
✅ Created release PR: https://github.com/your-org/repo1/pull/123
📊 Summary:
================================================================================
✅ your-org/repo1: https://github.com/your-org/repo1/pull/123
ℹ️ your-org/repo2: No release needed
✅ your-org/repo3: https://github.com/your-org/repo3/pull/456
================================================================================
📈 Results:
✅ Successful releases: 2
ℹ️ No changes needed: 1
❌ Errors: 0
📦 Total repositories: 3
Processing repository: your-org/repo2
Cloning your-org/repo2...
ℹ️ No changes detected - no release needed
The script handles various error scenarios:
- GitHub CLI not installed: Prompts to install GitHub CLI
- Not authenticated: Prompts to run
gh auth login - Repository not found: Logs error and continues with next repo
- Branch doesn't exist: Skips repository and logs reason
- Network issues: Logs error and continues
Edit the create_release_pull_request method to customize the pull request template:
pr_body = f"""
# Release v{self.release_version}
Custom release description here...
## Changes
- Feature A
- Bug fix B
- Enhancement C
## Testing
- [ ] Unit tests pass
- [ ] Integration tests pass
- [ ] Manual testing completed
Generated on {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}
"""If your repositories use different branch names, modify the branch references:
# Instead of 'develop' and 'master'
source_branch = "main"
target_branch = "production"-
"GitHub CLI is not installed"
- Install GitHub CLI using the instructions above
-
"GitHub CLI is not authenticated"
- Run
gh auth loginand follow the prompts
- Run
-
"Failed to clone repository"
- Check if the repository exists and you have access
- Verify the repository name format:
owner/repo
-
"Develop branch does not exist"
- The repository doesn't have a
developbranch - Modify the script to use your actual branch names
- The repository doesn't have a
Add debug logging by modifying the script:
import logging
logging.basicConfig(level=logging.DEBUG)This script is provided as-is for educational and development purposes.