Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 4 additions & 14 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,12 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install python-semantic-release==7.34.6
pip install python-semantic-release==8.7.0

- name: Check if release is needed
id: check
run: |
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
# Check if there are changes that warrant a new version
NEW_VERSION=$(semantic-release version --noop)
if [ -z "$NEW_VERSION" ]; then
echo "No version bump needed"
echo "should_release=false" >> $GITHUB_OUTPUT
else
echo "Version bump needed: $NEW_VERSION"
echo "should_release=true" >> $GITHUB_OUTPUT
fi
elif [[ "${{ github.event_name }}" == "push" ]]; then
if [[ "${{ github.event_name }}" == "workflow_dispatch" || "${{ github.event_name }}" == "push" ]]; then
# Check if there are changes that warrant a new version
NEW_VERSION=$(semantic-release version --noop)
if [ -z "$NEW_VERSION" ]; then
Expand Down Expand Up @@ -83,7 +73,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install python-semantic-release==7.34.6
pip install python-semantic-release==8.7.0

- name: Configure Git
run: |
Expand Down Expand Up @@ -169,7 +159,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install python-semantic-release==7.34.6
pip install python-semantic-release==8.7.0

- name: Configure Git
run: |
Expand Down
15 changes: 6 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,13 @@ RUN apt-get update && \
# Set working directory
WORKDIR /app

# Copy requirements first for better caching
COPY pr-diff-bot/requirements.txt .
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir -r requirements.txt

# Create directories
RUN mkdir -p /app/examples
# Copy source code
COPY . /app/

# Copy application code
COPY pr-diff-bot/ .
# Install package and dependencies
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir -r pr_diff_bot/requirements.txt && \
pip install -e .
COPY entrypoint.sh .

# Make entrypoint executable
Expand Down
177 changes: 123 additions & 54 deletions docs/release-workflow.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,55 @@

This document outlines the process for releasing new versions of PR Genius.

## Pre-release Testing
## Automated Release Process

PR Genius uses python-semantic-release and GitHub Actions to automate the release process. The workflow is configured to:

1. Monitor commits for version-worthy changes using conventional commit messages
2. Create release PRs automatically when changes warrant a new version
3. Generate changelogs and update version numbers
4. Create GitHub releases and Docker images

### Release Types

The system supports three types of releases:

1. **Regular Releases** (from main branch)

- Created when changes are pushed to main
- Version format: v1.2.3
- Full production releases

2. **Alpha Releases** (from feature branches)

- Created when changes are pushed to feature/\* branches
- Version format: v1.2.3-alpha.1
- Used for testing new features
- Created automatically from feature branches

3. **Beta Releases** (from fix branches)
- Created when changes are pushed to fix/\* branches
- Version format: v1.2.3-beta.1
- Used for testing bug fixes
- Created automatically from fix branches

### Commit Message Format

The release process relies on conventional commit messages to determine version bumps:

- `feat:` - New feature (minor version bump)
- `fix:` or `perf:` - Bug fix or performance improvement (patch version bump)
- `BREAKING CHANGE:` - Breaking API change (major version bump)

Example commit messages:

```
feat: add new analysis feature
fix: resolve memory leak in processor
feat!: redesign API (includes BREAKING CHANGE)
```

## Manual Testing

1. Run the test suite:

Expand Down Expand Up @@ -39,102 +87,123 @@ export PR_REVIEW_SYSTEM_CONTENT="Focus on security"

## Release Process

1. Update version in pyproject.toml:
### Automated Release Flow

```toml
[tool.poetry]
name = "pr-genius"
version = "1.2.3" # New version here
```
1. **Triggering a Release**

2. Update CHANGELOG.md with the new version and changes:
- Push changes to main, feature/_, or fix/_ branches
- Or manually trigger the Release workflow in GitHub Actions

```markdown
## [1.2.3] - YYYY-MM-DD
2. **Version Check**

### Added
- The system analyzes commit messages since the last release
- Determines if a version bump is needed and what type
- Creates a release PR if changes warrant a new version

- New feature X
- New feature Y
3. **Release PR**

### Changed
- Contains version updates and changelog
- For main branch: targets main
- For feature branches: targets the feature branch with alpha version
- For fix branches: targets the fix branch with beta version

- Improvement to Z
- Update to A
4. **After PR Merge**
- Creates GitHub release
- Pushes Docker images
- Regular releases go to main
- Prereleases stay on their respective branches

### Fixed
### Manual Release (if needed)

- Bug fix for B
- Issue with C
```
You can still create releases manually if needed:

3. Create a new release branch:
1. Create a release branch:

```bash
git checkout -b release/v1.2.3
```

4. Commit changes:
2. Update version and changelog:

```bash
git add pyproject.toml CHANGELOG.md
semantic-release version --no-commit
git add .
git commit -m "chore(release): prepare v1.2.3"
```

5. Create a pull request and wait for CI checks
3. Create and merge a PR to main

6. After merging, tag the release:
4. The workflow will handle the rest automatically

```bash
git tag -a v1.2.3 -m "Release v1.2.3"
git push origin v1.2.3
```
## Post-release

7. Create a GitHub release:
1. Verify the release:

- Go to Releases > Draft a new release
- Choose the tag
- Copy changelog entries
- Publish release
- Check GitHub releases page
- Verify Docker images are published
- Test the new version in a clean environment

## Post-release
2. Update documentation if needed:

- README.md
- docs/usage-guide.md
- Example workflows

1. Verify the GitHub Action works with the new release:
3. Verify the GitHub Action works with the new release:

```yaml
- uses: sudo-whodo/pr-genius@v1.2.3
```

2. Update documentation if needed:

- README.md
- docs/usage-guide.md
- Example workflows

## Hotfix Process

For urgent fixes to a released version:

1. Create a hotfix branch from the tag:
1. Create a fix branch:

```bash
git checkout -b hotfix/v1.2.4 v1.2.3
git checkout -b fix/urgent-issue main
```

2. Make the fix and update version/changelog
2. Make your changes and commit with appropriate message:

3. Follow steps 4-7 from the release process
```bash
git commit -m "fix: resolve critical issue"
```

3. Push the branch:

```bash
git push origin fix/urgent-issue
```

4. The workflow will automatically:
- Create a beta release for testing
- Create a release PR when ready

## Version Numbering

We follow semantic versioning:
We follow semantic versioning with prerelease support:

### Regular Releases (main branch)

- Format: MAJOR.MINOR.PATCH
- Example: 1.2.3
- MAJOR: Incompatible API changes
- MINOR: New features (backwards compatible)
- PATCH: Bug fixes (backwards compatible)

### Prerelease Versions

- Alpha (feature branches)

- MAJOR version for incompatible API changes
- MINOR version for new features in a backwards compatible manner
- PATCH version for backwards compatible bug fixes
- Format: MAJOR.MINOR.PATCH-alpha.N
- Example: 1.2.3-alpha.1
- Used for new feature testing

Example: 1.2.3
- Beta (fix branches)
- Format: MAJOR.MINOR.PATCH-beta.N
- Example: 1.2.3-beta.1
- Used for bug fix testing

- 1 = Major version
- 2 = Minor version
- 3 = Patch version
Version bumps are determined automatically from commit messages using conventional commit format.
4 changes: 2 additions & 2 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ esac
# Run the PR diff analyzer
echo "Running analysis for repository: $REPO, PR: $PR, Provider: $PROVIDER${MODEL:+, Model: $MODEL}"
if [ -n "$MODEL" ]; then
python /app/pr_diff_analyzer.py --repo "$REPO" --pr "$PR" --provider "$PROVIDER" --model "$MODEL"
python /app/pr_diff_bot/pr_diff_analyzer.py --repo "$REPO" --pr "$PR" --provider "$PROVIDER" --model "$MODEL"
else
python /app/pr_diff_analyzer.py --repo "$REPO" --pr "$PR" --provider "$PROVIDER"
python /app/pr_diff_bot/pr_diff_analyzer.py --repo "$REPO" --pr "$PR" --provider "$PROVIDER"
fi
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
import git
import sys
import os
# Add the root directory to Python path
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
from llm_clients import get_llm_client
from pr_diff_bot.llm_clients import get_llm_client

# Configure logging
logging.basicConfig(
Expand Down
File renamed without changes.
File renamed without changes.
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[tool.semantic_release]
version_variable = ["pr-diff-bot/__init__.py:__version__"]
version_variable = ["pr_diff_bot/__init__.py:__version__"]
version_pattern = "__version__ = '{version}'"
branch = "main"
upload_to_pypi = false
upload_to_release = true
Expand Down
4 changes: 2 additions & 2 deletions test-local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ echo "- OpenRouter Key: ${OPENROUTER_API_KEY:0:4}...${OPENROUTER_API_KEY: -4}"

# Build the container
echo -e "\nBuilding container..."
docker build -t pr-diff-analyzer:local .
docker build -t pr_diff_bot:local .

# Run the container
echo -e "\nRunning analysis..."
docker run \
-e GITHUB_TOKEN=$GITHUB_TOKEN \
-e OPENROUTER_API_KEY=$OPENROUTER_API_KEY \
pr-diff-analyzer:local \
pr_diff_bot:local \
"$REPO" "$PR_NUMBER" "--model" "$MODEL"