Skip to content
Draft
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
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,7 @@ lint/tmp/
# OSX
.DS_Store

.kotlin
.kotlin

# Release notes generator output
gen-rn/output/
142 changes: 142 additions & 0 deletions gen-rn/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
# gen-rn: XMTP SDK release notes generator

AI-powered release notes generation for XMTP SDK releases using git history analysis and Claude AI.

> [!IMPORTANT]
> Generated release notes must be reviewed by humans before publication. The AI provides a starting point, not a final product.

## Purpose

1. **Engineering sanity check**: Help engineers understand exactly what's included in a release
2. **Technical writing support**: Help technical writers with structured, well-organized release content
3. **Cross-SDK consistency**: Run in each XMTP SDK repo and compare structured outputs to gauge consistency of feature and fix implementations across SDKs

## Prerequisites

- Node.js 18 or later (required for native fetch API support)
- Anthropic API key: Get a key at: [https://console.anthropic.com/](https://console.anthropic.com/)

## Configuration

The script supports the following environment variables:

- `ANTHROPIC_API_KEY` (required): Your Anthropic API key for Claude AI
- `MAX_TOKENS` (optional): Maximum tokens for AI response (default: 4000, range: 1000-8000)

### API key handling

- Never commit your `ANTHROPIC_API_KEY` to version control
- Store your API key in your shell profile as described in Setup
- Rotate your API key immediately if it's accidentally exposed or committed
- The temporary `ai-script.js` file is automatically deleted after execution for security

## Setup

```bash
# Set your API key
export ANTHROPIC_API_KEY="sk-ant-your-key-here"
echo 'export ANTHROPIC_API_KEY="your-key"' >> ~/.zshrc
source ~/.zshrc

# Fetch latest tags
git fetch --tags

# Make script executable
chmod +x gen-rn.sh

# Optionally, set custom token limit for current terminal session
export MAX_TOKENS=6000
```

## Usage

### Basic usage

```bash
# Auto-detect previous tag and generate delta
./gen-rn.sh 4.6.4

# Specify both tags to compare (what's new in 4.6.4 vs 4.6.3)
./gen-rn.sh 4.6.4 4.6.3

# Interactive mode - prompts for tag selection
# Detects previous tag and generate delta
./gen-rn.sh

# Help
./gen-rn.sh --help
```

### Custom base comparison with `--from-base`

Use the `--from-base` flag to compare a release against any git reference (branch, tag, or commit):

```bash
# Show everything in 4.6.4 that's not in main
./gen-rn.sh 4.6.4 --from-base main

# Show full content of a release candidate
./gen-rn.sh 4.6.4-rc.1 --from-base main

# Show all changes since a specific older tag
./gen-rn.sh 4.6.4 --from-base 4.5.0

# Compare against a branch
./gen-rn.sh 4.6.4 --from-base release/4.6
```

### Supported release types

The script automatically detects release types based on tag naming:

```bash
# Stable release (production-ready)
./gen-rn.sh 4.6.7 # β†’ Release type: stable

# Release candidate (pre-release testing)
./gen-rn.sh 4.6.7-rc.1 4.6.6 # β†’ Release type: release-candidate

# Development release (experimental)
./gen-rn.sh 4.6.7-dev.abc123 4.6.7 # β†’ Release type: development
```

### Tag name validation

The script validates all tag names to prevent command injection attacks. Tag names must contain only:
- Letters (a-z, A-Z)
- Numbers (0-9)
- Dots (.)
- Hyphens (-)
- Underscores (_)
- Forward slashes (/)

## Output files

After running, check the `output/` directory:

```text
output/
β”œβ”€β”€ release-notes.md # Main AI-generated release notes
β”œβ”€β”€ release-data.txt # Raw git analysis data (for debugging)
└── pr-refs.txt # PR numbers found in commits
```

> [!NOTE]
> - The `gen-rn/output/` directory is automatically excluded from version control via `.gitignore`
> - The temporary `ai-script.js` file is automatically deleted after execution for security

## Troubleshooting

### "Not in a git repository"

- Run from the root of your XMTP SDK repository

### "ANTHROPIC_API_KEY not set"

- Set your API key: `export ANTHROPIC_API_KEY="your-key"`
- Get a key at: https://console.anthropic.com/

### "Could not compare tags"

- Verify both tags exist: `git tag | grep 4.6.4`
- Use explicit tag names: `./gen-rn.sh 4.6.4 4.6.3`
Loading
Loading