Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
73ad965
Initial check-in of breaking-change doc script
ericstj Oct 22, 2025
b72e312
Adjust breaking change script for runtime repo
ericstj Oct 22, 2025
af539cf
Remove label checking
ericstj Oct 22, 2025
cdde40f
Add a workflow triggered on breaking change docs needed.
ericstj Oct 22, 2025
1100977
Remove issue write permission
ericstj Oct 22, 2025
8af1bca
Simplify breaking change doc step
ericstj Oct 22, 2025
2afb344
Use pull_request_target
ericstj Oct 22, 2025
f20e2cc
Only run workflow on dotnet repo.
ericstj Oct 22, 2025
85affad
Use GitHub REST API for fetching from dotnet/docs
ericstj Oct 22, 2025
465fa5b
Fix log messages
ericstj Oct 22, 2025
6b37cfd
Try models: read permission
ericstj Oct 22, 2025
448102f
Add support for Copilot CLI
ericstj Oct 24, 2025
1498523
Address feedback
ericstj Oct 24, 2025
3d50c46
Fix yml indenting
ericstj Oct 24, 2025
d57ace3
Allow external API key for Github Models and Copilot CLI
ericstj Oct 24, 2025
61c3e30
Use optional token when invoking gh models / copilot
ericstj Oct 24, 2025
730d99a
Use GH_TOKEN instead of GITHUB_TOKEN
ericstj Oct 24, 2025
916bd2d
Merge branch 'main' into breakingChangeDocTool
ericstj Oct 24, 2025
37aea61
Address feedback
ericstj Nov 7, 2025
d946c03
Only run the breaking change doc workflow on merged PRs
ericstj Nov 7, 2025
076970f
Add workflow dispatch to breaking change workflow
ericstj Nov 8, 2025
34ac620
Add docs to breaking change workflow.
ericstj Nov 8, 2025
62ebd7f
Fix workflow condition
ericstj Nov 8, 2025
c797328
Fix calling gh CLI and use prompt file
ericstj Nov 8, 2025
5ae118e
Use powershell-yaml
ericstj Nov 8, 2025
10d1e6f
Fix Clean to work correctly
ericstj Nov 8, 2025
9179883
Update readme
ericstj Nov 8, 2025
d27e210
Fetch PR commits, and remove some redundant CLI calls.
ericstj Nov 24, 2025
0f88e94
Remove repo from queries
ericstj Nov 26, 2025
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
52 changes: 52 additions & 0 deletions .github/workflows/breaking-change-doc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Breaking Change Documentation

on:
pull_request_target:
types: [labeled]

permissions:
contents: read
pull-requests: write

jobs:
generate-breaking-change-doc:
if: contains(github.event.label.name, 'needs-breaking-change-doc-created') && github.repository_owner == 'dotnet'
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Need full history for version detection

- name: Verify PowerShell
run: |
pwsh --version

- name: Verify GitHub CLI
run: |
gh --version

- name: Install GitHub Models extension
run: |
gh extension install github/gh-models --force
env:
GH_TOKEN: ${{ github.token }}

- name: Fetch latest tags
run: |
git fetch --tags --force

- name: Run breaking change documentation script
shell: pwsh
working-directory: eng/breakingChanges
run: ./breaking-change-doc.ps1 -PrNumber ${{ github.event.pull_request.number }} -Comment
env:
GH_TOKEN: ${{ github.token }}

- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: breaking-change-doc-artifacts-${{ github.event.pull_request.number }}
path: artifacts/docs/breakingChanges/
retention-days: 7
149 changes: 149 additions & 0 deletions eng/breakingChanges/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
# Breaking Change Documentation Automation

This script automates the creation of high-quality breaking change documentation for .NET runtime PRs using AI-powered analysis.

## Key Features

- **GitHub Models Integration**: Uses GitHub's AI models (no API keys required) with fallback to other providers
- **Dynamic Template Fetching**: Automatically fetches the latest breaking change issue template from dotnet/docs
- **Example-Based Learning**: Analyzes recent breaking change issues to improve content quality
- **Version Detection**: Analyzes GitHub tags to determine accurate .NET version information for proper milestone assignment
- **Flexible Workflow**: Multiple execution modes (CollectOnly, Comment, CreateIssues) with DryRun overlay
- **Comprehensive Data Collection**: Gathers PR details, related issues, merge commits, review comments, and closing issues
- **Area Label Detection**: Automatically detects feature areas from GitHub labels (area-*) with file path fallback
- **Individual File Output**: Creates separate JSON files per PR for easy examination

## Quick Setup

1. **Install Prerequisites:**
- GitHub CLI: `gh auth login`
- Choose LLM provider:
- **GitHub Models** (recommended): `gh extension install github/gh-models`
- **OpenAI**: Set `$env:OPENAI_API_KEY = "your-key"`
- **Others**: See configuration section below

2. **Configure:**
```powershell
# Edit config.ps1 to set:
# - LlmProvider = "github-models" (or other provider)
```

3. **Run the workflow:**
```powershell
.\breaking-change-doc.ps1 -DryRun
```

4. **Choose your workflow:**
```powershell
# Default: Add comments with create issue links (recommended)
.\breaking-change-doc.ps1

# Create issues directly
.\breaking-change-doc.ps1 -CreateIssues

# Just collect data
.\breaking-change-doc.ps1 -CollectOnly
```

## Commands

```powershell
# Dry run (inspect commands)
.\breaking-change-doc.ps1 -DryRun

# Default workflow (add comments with links)
.\breaking-change-doc.ps1

# Create issues directly
.\breaking-change-doc.ps1 -CreateIssues

# Data collection only
.\breaking-change-doc.ps1 -CollectOnly

# Single PR mode
.\breaking-change-doc.ps1 -PRNumber 123456

# Clean start
.\breaking-change-doc.ps1 -CleanStart

# Help
.\breaking-change-doc.ps1 -Help
```

## Configuration

Edit `config.ps1` to customize:
- **LLM provider**: GitHub Models, OpenAI, Anthropic, Azure OpenAI
- **Search parameters**: Date ranges, labels, excluded milestones
- **Output settings**: Labels, assignees, notification emails

## LLM Providers

**GitHub Models** (recommended - no API key needed):
```powershell
gh extension install github/gh-models
# Set provider in config.ps1: LlmProvider = "github-models"
```

**OpenAI**:
```powershell
$env:OPENAI_API_KEY = "your-key"
# Set provider in config.ps1: LlmProvider = "openai"
```

**Anthropic Claude**:
```powershell
$env:ANTHROPIC_API_KEY = "your-key"
# Set provider in config.ps1: LlmProvider = "anthropic"
```

**Azure OpenAI**:
```powershell
$env:AZURE_OPENAI_API_KEY = "your-key"
# Configure endpoint in config.ps1: LlmProvider = "azure-openai"
```

## Output

- **Data Collection**: `(repoRoot)\artifacts\docs\breakingChanges\data\summary_report.md`, `(repoRoot)\artifacts\docs\breakingChanges\data\pr_*.json`
- **Issue Drafts**: `(repoRoot)\artifacts\docs\breakingChanges\issue-drafts\*.md`
- **Comment Drafts**: `(repoRoot)\artifacts\docs\breakingChanges\comment-drafts\*.md`
- **GitHub Issues**: Created automatically (unless -DryRun)

## Workflow Steps

1. **Fetch PRs** - Downloads PR data from dotnet/runtime with comprehensive details
2. **Version Detection** - Analyzes GitHub tags to determine accurate .NET version information
3. **Template & Examples** - Fetches latest issue template and analyzes recent breaking change issues
4. **AI Analysis** - Generates high-quality breaking change documentation using AI
5. **Create Issues/Comments** - Adds comments with issue creation links or creates issues directly

## Version Detection

The script automatically determines accurate .NET version information using the local git repository:
- **Fast and reliable**: Uses `git describe` commands on the repository
- **No API rate limits**: Avoids GitHub API calls for version detection
- **Accurate timing**: Analyzes actual commit ancestry and tag relationships
- **Merge commit analysis**: For merged PRs, finds the exact merge commit and determines version context
- **Branch-aware**: For unmerged PRs, uses target branch information

## Manual Review

AI generates 90%+ ready documentation, but review for:
- Technical accuracy
- API completeness
- Edge cases

## Cleanup

Between runs:
```powershell
.\breaking-change-doc.ps1 -CleanStart
```

## Troubleshooting

**GitHub CLI**: `gh auth status` and `gh auth login`
**API Keys**: Verify environment variables are set for non-GitHub Models providers
**Rate Limits**: Use -DryRun for testing, script includes delays
**Git Operations**: Ensure git is in PATH and repository is up to date (`git fetch --tags`)
Loading
Loading