Skip to content

CHEQROOM/release-manager

Repository files navigation

Release Manager Script

A Python script that automates the creation of release pull requests across multiple Git repositories using GitHub CLI.

Features

  • ✅ Checks for differences between develop and master branches
  • ✅ 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

Prerequisites

  1. Python 3.6+ installed on your system
  2. GitHub CLI installed and authenticated
  3. Git installed

Installing GitHub CLI

# macOS
brew install gh

# Ubuntu/Debian
sudo apt install gh

# Windows
winget install GitHub.cli

Authenticating with GitHub

gh auth login

AI Summarization Setup (Optional)

The release manager can use Google's Gemini API to automatically summarize commit changes and generate intelligent release descriptions.

Setup Instructions

  1. Get a Gemini API Key:

  2. Set the Environment Variable:

    export GEMINI_API_KEY='your-api-key-here'
  3. Install the Required Package:

    pip install google-generativeai
  4. Run the Setup Script (optional):

    python setup_gemini.py

Configuration Options

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

What AI Summarization Provides

  • 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

Usage

Basic Usage

python release_manager.py 1.2.3

This will process all repositories in the hard-coded list and create release pull requests for version 1.2.3.

Custom Repository List

python release_manager.py 1.2.3 --repos "org/repo1" "org/repo2" "org/repo3"

Making the Script Executable

chmod +x release_manager.py
./release_manager.py 1.2.3

Configuration

Setting Up Repository List

Edit the repositories list in the ReleaseManager class:

self.repositories = [
    "your-org/repo1",
    "your-org/repo2", 
    "your-org/repo3",
    # Add more repositories as needed
]

Branch Configuration

The script expects:

  • develop branch as the source branch
  • master branch as the target branch

If your repositories use different branch names, modify the check_diff_between_branches method.

How It Works

  1. Repository Processing: For each repository in the list:

    • Clones the repository to a temporary directory
    • Fetches the latest changes from both develop and master branches
  2. Diff Detection:

    • Compares develop and master branches
    • Checks if there are any file changes between the branches
  3. Pull Request Creation (if changes detected):

    • Creates a new branch: release/{version}
    • Creates a pull request from develop to master
    • Includes a detailed PR description with checklist
  4. Cleanup:

    • Removes temporary cloned repositories
    • Provides a summary of results

Output Examples

Successful Release Creation

🚀 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

No Changes Detected

Processing repository: your-org/repo2
Cloning your-org/repo2...
  ℹ️  No changes detected - no release needed

Error Handling

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

Customization

Modify PR Template

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')}
"""

Change Branch Names

If your repositories use different branch names, modify the branch references:

# Instead of 'develop' and 'master'
source_branch = "main"
target_branch = "production"

Troubleshooting

Common Issues

  1. "GitHub CLI is not installed"

    • Install GitHub CLI using the instructions above
  2. "GitHub CLI is not authenticated"

    • Run gh auth login and follow the prompts
  3. "Failed to clone repository"

    • Check if the repository exists and you have access
    • Verify the repository name format: owner/repo
  4. "Develop branch does not exist"

    • The repository doesn't have a develop branch
    • Modify the script to use your actual branch names

Debug Mode

Add debug logging by modifying the script:

import logging
logging.basicConfig(level=logging.DEBUG)

License

This script is provided as-is for educational and development purposes.

About

Manager for create release PRs

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published