Skip to content

Release v5.5.0

Release v5.5.0 #73

Workflow file for this run

name: Sync Documentation
on:
release:
types: [published, edited, created]
workflow_dispatch:
inputs:
tag_name:
description: "Tag name to analyze (leave empty for latest)"
required: false
type: string
env:
DOCS_REPO: xmtp/docs-xmtp-org
BRANCH_PREFIX: auto-update-react-native-docs
jobs:
sync-docs:
name: Sync React Native Documentation
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- name: Checkout React Native SDK
uses: actions/checkout@v6
with:
fetch-depth: 0
path: react-native-sdk
- name: Checkout Documentation Repository
uses: actions/checkout@v6
with:
repository: ${{ env.DOCS_REPO }}
token: ${{ secrets.DOCS_SYNC_TOKEN }}
path: docs-repo
- name: Determine tag to analyze
id: tag
run: |
cd react-native-sdk
if [ -n "${{ github.event.inputs.tag_name }}" ]; then
TAG="${{ github.event.inputs.tag_name }}"
elif [ "${{ github.event_name }}" = "release" ]; then
TAG="${{ github.event.release.tag_name }}"
else
# Use the latest tag by creation date (any type)
TAG=$(git tag --sort=-creatordate | head -n 1)
fi
echo "tag=$TAG" >> $GITHUB_OUTPUT
echo "Analyzing tag: $TAG"
- name: Skip if tag is dev or rc
run: |
if echo "${{ steps.tag.outputs.tag }}" | grep -E 'dev|rc'; then
echo "Skipping documentation PR for dev or rc release: ${{ steps.tag.outputs.tag }}"
exit 0
fi
- name: Get previous tag for diff
id: prev_tag
run: |
cd react-native-sdk
CURRENT_TAG="${{ steps.tag.outputs.tag }}"
PREV_TAG=$(git tag --sort=-version:refname | grep -A 1 "^$CURRENT_TAG$" | tail -n 1)
if [ "$PREV_TAG" = "$CURRENT_TAG" ] || [ -z "$PREV_TAG" ]; then
PREV_TAG=$(git tag --sort=-version:refname | head -n 2 | tail -n 1)
fi
echo "prev_tag=$PREV_TAG" >> $GITHUB_OUTPUT
echo "Previous tag: $PREV_TAG"
- name: Create documentation analysis prompt
run: |
cat > docs-repo/analysis_prompt.md << 'EOF'
# Documentation Sync Analysis
You are tasked with analyzing changes in the XMTP React Native SDK and updating documentation accordingly.
## Context
- Current release tag: ${{ steps.tag.outputs.tag }}
- Previous tag: ${{ steps.prev_tag.outputs.prev_tag }}
- React Native SDK repo: `react-native-sdk/`
- Documentation repo: `docs-repo/`
## Task
1. Analyze the diff between the previous tag and current tag in the React Native SDK (entire `src/` directory)
2. Identify API changes, new features, new exported functions, new types, new options in existing APIs, deprecated methods, and breaking changes
3. For every new or changed API, function, or feature in the diff, update or create all relevant documentation files in `docs-repo/` to reflect the changes. If a doc does not exist, create a new one. List all files you update or create.
4. Review documentation in `docs-repo/` for React Native-related content
5. Focus on code samples, API references, and integration guides
6. Ensure all React Native code samples are accurate and use current APIs
## Key areas to check
- Client initialization and configuration
- Message sending and receiving
- Group and DM management
- Codec usage (attachments, reactions, etc.)
- Context providers and hooks usage
- Push notification setup for React Native
- Error handling patterns
- Authentication flows
- Expo integration
- **New exported functions, types, and options in all APIs**
## Requirements
- All code samples must be valid TypeScript/JavaScript with the current SDK version (${{ steps.tag.outputs.tag }})
- Update version numbers in installation instructions
- Flag any breaking changes that need migration guides
- Maintain consistency with existing documentation style
- Create clear, actionable updates
- Use comprehensive analysis tools to ensure thorough coverage
- Verify documentation accuracy by cross-referencing with source code
- Search for related documentation files that may need updates
- Pay special attention to React Native specific patterns and examples
- **Document all new features, exported functions, types, and options**
- **If a relevant doc does not exist, create it.**
## Available Tools
You have access to comprehensive tools including:
- File operations (Read, Write, Edit, MultiEdit)
- Search tools (Glob, Grep, Task)
- Web tools (WebFetch, WebSearch) for additional context
- Organization tools (TodoRead, TodoWrite) for systematic updates
- Command execution (Bash) for git operations and analysis
Use these tools systematically to ensure comprehensive documentation updates.
## Output Requirements
If you want to customize the pull request title and description, create these files in the docs-repo directory:
- claude_pr_title.txt: Contains the custom PR title (single line)
- claude_pr_body.txt: Contains the custom PR body (markdown format)
These files will be used for the pull request creation if provided. If not provided, default title and body will be used.
## Release Changes Summary
EOF
# Append the release diff to the prompt
cd react-native-sdk
echo "### Changed Files (src/):" >> ../docs-repo/analysis_prompt.md
git diff ${{ steps.prev_tag.outputs.prev_tag }}..${{ steps.tag.outputs.tag }} --name-only | grep '^src/' >> ../docs-repo/analysis_prompt.md
echo "" >> ../docs-repo/analysis_prompt.md
echo "### Key API and Feature Changes (entire src/):" >> ../docs-repo/analysis_prompt.md
git diff ${{ steps.prev_tag.outputs.prev_tag }}..${{ steps.tag.outputs.tag }} -- src/ | head -1000 >> ../docs-repo/analysis_prompt.md
echo "" >> ../docs-repo/analysis_prompt.md
echo "Please analyze these changes and update the documentation files in the docs-repo/ directory accordingly." >> ../docs-repo/analysis_prompt.md
- name: Run Claude Code Documentation Analysis
id: claude_analysis
uses: anthropics/claude-code-base-action@beta
with:
prompt_file: docs-repo/analysis_prompt.md
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
allowed_tools: "Bash,Read,Write,Edit,MultiEdit,Glob,Grep,LS,Task,WebFetch,WebSearch,TodoRead,TodoWrite,NotebookRead,NotebookEdit"
max_turns: 40
timeout_minutes: 20
- name: Create branch and commit changes
id: commit
run: |
cd docs-repo
BRANCH_NAME="${{ env.BRANCH_PREFIX }}-${{ steps.tag.outputs.tag }}"
# Configure git
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
# Always work with the latest main
git fetch origin main
git checkout main
git pull origin main
# Create or reset the update branch from latest main
git checkout -B "$BRANCH_NAME" main
# Remove the analysis prompt and any Claude-generated PR files (internal workflow files)
rm -f analysis_prompt.md claude_pr_title.txt claude_pr_body.txt
# Check if there are any changes
if git diff --quiet && git diff --cached --quiet; then
echo "No documentation changes needed"
echo "has_changes=false" >> $GITHUB_OUTPUT
else
echo "Documentation changes detected"
echo "has_changes=true" >> $GITHUB_OUTPUT
echo "branch_name=$BRANCH_NAME" >> $GITHUB_OUTPUT
# Add all changes (excluding the removed prompt and PR files)
git add .
# Commit changes (single-line message to avoid YAML syntax issues)
git commit -m "Update React Native SDK documentation for release ${{ steps.tag.outputs.tag }}. Automated update based on changes in xmtp-react-native ${{ steps.tag.outputs.tag }}. Changes analyzed: API modifications and new features, code sample accuracy, version compatibility, breaking changes documentation. Generated by Claude Code Actions."
# Force push branch to overwrite remote
git push --force origin "$BRANCH_NAME"
fi
- name: Create Pull Request
if: steps.commit.outputs.has_changes == 'true'
env:
GH_TOKEN: ${{ secrets.DOCS_SYNC_TOKEN }}
run: |
cd docs-repo
# Check for Claude Code generated PR content in files
PR_TITLE="📱 Update React Native SDK docs for ${{ steps.tag.outputs.tag }}"
if [ -f "claude_pr_title.txt" ]; then
PR_TITLE=$(cat claude_pr_title.txt)
rm claude_pr_title.txt
fi
# Use Claude Code generated PR body if available, otherwise use default
if [ -f "claude_pr_body.txt" ]; then
cp claude_pr_body.txt pr_body.md
rm claude_pr_body.txt
else
echo '## 🤖 Automated React Native SDK Documentation Update' > pr_body.md
echo '' >> pr_body.md
echo "This PR updates the documentation to align with React Native SDK release [\`${{ steps.tag.outputs.tag }}\`](https://github.com/xmtp/xmtp-react-native/releases/tag/${{ steps.tag.outputs.tag }})." >> pr_body.md
echo '' >> pr_body.md
echo '### Changes Made' >> pr_body.md
echo '- Updated code samples to match current SDK APIs' >> pr_body.md
echo '- Verified React Native integration examples' >> pr_body.md
echo '- Updated version references and installation instructions' >> pr_body.md
echo '- Addressed any breaking changes or deprecations' >> pr_body.md
echo '- Updated TypeScript/JavaScript examples for accuracy' >> pr_body.md
echo '- Verified Expo integration patterns' >> pr_body.md
echo '' >> pr_body.md
echo '### Analysis Summary' >> pr_body.md
echo 'Documentation analysis and updates completed using Claude Code Actions.' >> pr_body.md
echo '' >> pr_body.md
echo '### Verification Needed' >> pr_body.md
echo '- [ ] Review all React Native code samples for accuracy' >> pr_body.md
echo '- [ ] Test integration examples with current SDK version' >> pr_body.md
echo '- [ ] Verify version compatibility information' >> pr_body.md
echo '- [ ] Check TypeScript definitions and examples' >> pr_body.md
echo '- [ ] Validate Expo configuration steps' >> pr_body.md
echo '- [ ] Check for any missed documentation updates' >> pr_body.md
echo '' >> pr_body.md
echo '*This PR was automatically generated by Claude Code Actions*' >> pr_body.md
fi
# Check if a PR already exists for this branch
EXISTING_PR_URL=$(gh pr list --head "${{ steps.commit.outputs.branch_name }}" --base main --json url --jq '.[0].url')
if [ -n "$EXISTING_PR_URL" ]; then
echo "ℹ️ Existing PR found: $EXISTING_PR_URL"
echo "✅ Existing PR was updated with new commits."
else
gh pr create \
--title "$PR_TITLE" \
--body-file pr_body.md \
--head "${{ steps.commit.outputs.branch_name }}" \
--base main
fi
- name: Output results
run: |
if [ "${{ steps.commit.outputs.has_changes }}" = "true" ]; then
echo "✅ Documentation sync completed successfully"
echo "📝 Pull request created in ${{ env.DOCS_REPO }}"
echo "🔗 Check: https://github.com/${{ env.DOCS_REPO }}/pulls"
else
echo "ℹ️ No documentation changes required for this release"
fi