# GitHub Dependency Version Bumper

> Bump dependency versions across GitHub repos. Read package files, update versions, and open PRs automatically.

Source: https://cotera.co/solutions/ops/github-dependency-version-bumper

---

- **Team:** Operations
- **Tools:** GitHub
- **Difficulty:** medium
- **Setup time:** 10 min
- **Time saved:** 1-2 hrs/week

## How it works
1. **Read Dependencies** — Fetches package files from each repo and parses current dependency versions
2. **Plan Updates** — Shows you exactly what will change with before/after versions and flags breaking changes
3. **Bump Versions** — Updates the dependency files across all target repos with the new version numbers
4. **Open PRs** — Creates a branch and PR per repo with a detailed changelog of every version change

## Example requests
- Bump react and react-dom to 19.0.0 across acme/web-app and acme/dashboard
- Update all TypeScript-related dependencies to their latest versions in acme/api
- Sync the Node version across package.json engines in all our repos

## Prompt

```markdown
## Task

Use @GitHub/Read File to read package.json, requirements.txt, or other dependency files across one or more repos. Identify outdated or mismatched dependencies, update version numbers based on user instructions, then use @GitHub/Get Branch SHA, @GitHub/Create Branch, @GitHub/Update File, and @GitHub/Create Pull Request to commit the changes and open PRs.

## Input

The user provides:
1. The repository or repositories to update (e.g., "acme/web-app" or "acme/web-app, acme/api, acme/worker")
2. The dependencies to bump (e.g., "react to 19.0.0", "all TypeScript-related deps to latest", "match versions across all repos")
3. The dependency file to update (optional, defaults to package.json)
4. Whether to bump in a single PR per repo or batch all changes

**Example:** "Bump react and react-dom to 19.0.0 across acme/web-app and acme/dashboard"

## Context

### Read Dependency Files

1. Use @GitHub/Read File to fetch the dependency file (package.json, requirements.txt, go.mod, etc.) from each repo
2. Parse the current dependency versions
3. Identify which dependencies match the user's criteria for updating
4. For multi-repo updates, compare versions across repos to find inconsistencies

### Plan the Updates

1. List all dependencies that will be changed with their current and target versions
2. Check for peer dependency conflicts (e.g., bumping react without react-dom)
3. Flag any major version bumps that might include breaking changes
4. Show the user the full update plan before proceeding

### Apply Version Bumps

For each repository:
1. Use @GitHub/Get Branch SHA to get the current SHA of the default branch
2. Use @GitHub/Create Branch to create a new branch (e.g., "deps/bump-react-19")
3. Modify the dependency file with the new version numbers
4. Use @GitHub/Update File to commit the updated file
5. Use @GitHub/Create Pull Request to open a PR with a detailed changelog

### PR Description

1. List every dependency changed with before/after versions
2. Flag any major version bumps with a warning
3. Note related dependencies that were bumped together
4. Include links to release notes where possible

## Output

**Dependency Version Bump Summary:**

**Repositories Updated:** [count]

**Per-Repo Changes:**

### [owner/repo1]
| Dependency | Current | Target | Type |
|-----------|---------|--------|------|
| [dep1] | [v1] | [v2] | [dependencies] |
| [dep2] | [v1] | [v2] | [devDependencies] |

**PR:** [PR URL]

### [owner/repo2]
| Dependency | Current | Target | Type |
|-----------|---------|--------|------|
| [dep1] | [v1] | [v2] | [dependencies] |

**PR:** [PR URL]

**Warnings:**
- [Major version bump] [dep] from [v1] to [v2] may include breaking changes
- [Peer dependency] [dep1] updated but [dep2] may also need updating

**Status:** All PRs opened and ready for review
```

## Related reading
- [GitHub API: We Built a Bot. Then We Replaced It with an Agent.](https://cotera.co/articles/github-api-integration-guide.md)
- [GitHub vs Bitbucket: We Used Both for Three Years. One Fell Behind.](https://cotera.co/articles/github-vs-bitbucket-comparison.md)

