The bump arrives as a pull request
Add one workflow file and Leanbump runs on a schedule. It moves your project's Mathlib pin to the newest release, one release at a time, and keeps a change only when lake build says it helped. When the build passes at the target, you get a pull request with one commit per release and every change labelled. When it gets part of the way, the pull request carries the releases that build and lists each error left at the next one, with its goal state. When no release builds, you get an issue with that list.
1. Add the workflow
Save this as .github/workflows/leanbump.yml on your default branch:
name: Mathlib bump
on:
schedule:
- cron: "0 6 * * 1" # Mondays 06:00 UTC
workflow_dispatch: # and a "Run workflow" button
permissions:
contents: write
pull-requests: write
issues: write
jobs:
bump:
runs-on: ubuntu-latest
timeout-minutes: 300
steps:
- uses: actions/checkout@v4
- uses: grain64-labs/leanbump@v2
with:
anthropic-api-key: ${{ secrets.ANTHROPIC_API_KEY }} # optional, see 3.
2. Let Actions open pull requests
In the repository's Settings → Actions → General, under Workflow permissions, tick Allow GitHub Actions to create and approve pull requests. Without it GitHub refuses the pull request. The branch is still pushed, and the workflow log says how to open the pull request from it by hand.
3. Optional: a model key
Without a key, Leanbump makes only the fixes that need no model: the renames the compiler's deprecation notices name, and the renames in its map of Mathlib's history. That is often enough for a one-release bump. With a key, a model repairs what is left: changed signatures and broken proofs. Every edit it makes is checked by lake build and dropped if it did not help. Add the key as a repository secret named ANTHROPIC_API_KEY (or OPENROUTER_API_KEY, passed as openrouter-api-key). Model calls are billed by your provider to your key; the action itself is free.
What you get
The pull request the action writes for a real run on a public project, moved from v4.35.0 to v4.36.0 with no model key. Title:
Bump Mathlib v4.35.0 → v4.36.0 (leanbump, lake build passes)
Body:
<!-- leanbump:bump-v4.36.0 --> **`lake build` passes at Mathlib v4.36.0.** This moves the project from v4.35.0 to v4.36.0 in one commit. changes without a model: 4 · errors at the new pin: 0 · errors left: 0 | Mathlib release | errors at the new pin | changes without a model | errors left | commit | |---|---|---|---|---| | v4.36.0 | 0 | 4 | 0 | `915f75c631` | ### What changed (4) #### Renames (4) _a name Mathlib renamed or deprecated, rewritten to the new name._ | file:line | release | by | why | |---|---|---|---| | `NeumannCosine/Basic.lean:97` | v4.36.0 | compiler notice | if_neg -> ite_eq_right (compiler deprecation notice) | | `NeumannCosine/Discrete/Laplacian.lean:132` | v4.36.0 | compiler notice | dif_neg -> dite_eq_right (compiler deprecation notice) | | `NeumannCosine/Discrete/Laplacian.lean:162` | v4.36.0 | compiler notice | dif_neg -> dite_eq_right (compiler deprecation notice) | | `NeumannCosine/Discrete/ModalMinimumLimit.lean:104` | v4.36.0 | compiler notice | dif_pos -> dite_eq_left (compiler deprecation notice) | --- No model key was set, so this run made only the fixes that need no model (compiler deprecations and the rename map). To let leanbump repair the rest, add an `ANTHROPIC_API_KEY` or `OPENROUTER_API_KEY` repository secret and pass it to the action. [Run page](https://leanbump.grain64.com/run/kngavlo4sf) · 9 min of leanbump work Opened by the [leanbump action](https://leanbump.grain64.com/docs/ci/) (leanbump 0.2.0). Every change was kept only because `lake build` said it helped; review the diff before merging. Re-runs update this pull request rather than opening another.
Re-runs update the same pull request instead of opening another. When a newer Mathlib release comes out, the next run opens a new pull request and closes the old one as superseded. When the build passes at some releases but not the target, the pull request carries the releases that build, its title says how many errors are left at the next one, and its body lists each of them with its goal state. When no release builds, there is no commit to propose, so you get an issue with that list instead. In both cases the unfinished attempt is kept on a leanbump/attempt-<release> branch.
Inputs
| input | default | what it does |
|---|---|---|
to | newest release | Target Mathlib release, like v4.36.0. |
anthropic-api-key | none | Model key (pass a secret). Without any key, only the fixes that need no model. |
openrouter-api-key | none | Used when no Anthropic key is given. |
model | leanbump default | Model id for the repair step. |
max-iters | 8 | Model calls per Mathlib release. |
time-budget | 240 | Minutes of bumping per run. The run stops before a release that would likely go past it, and opens the pull request with the releases that are green. Keep it under timeout-minutes. |
max-releases | 0 (no cap) | Mathlib releases per run at most. |
build-timeout | 0 (none) | Seconds before one lake build is stopped. |
upload | auto | Upload the report and link a run page from the pull request. auto: public repositories only. true: always. false: never. |
base | checked-out branch | Branch the pull request targets. |
working-directory | . | The Lean project inside the repository. |
github-token | github.token | Token that pushes the branch and opens the pull request. |
Outputs: url (the pull request or issue), kind (pull or issue), run-page, green.
Limits worth knowing
- Your CI does not run on the pull request by itself. GitHub does not start other workflows for pull requests opened with the built-in
GITHUB_TOKEN. Close and reopen the pull request to start them, or pass a fine-grained token or GitHub App token asgithub-token. - Time. On our test machine one release took 4 to 60 minutes, most of it
lake build. Hosted runners are slower. GitHub stops a hosted job after 6 hours;timeout-minutesabove stops it sooner. - A project many releases behind arrives over several runs. Each run stops at its
time-budget, opens the pull request with the releases that passlake build, and the next run continues that branch and updates the same pull request. - Projects that depend on other Mathlib-pinned packages stop with a message naming them: those packages have to reach the target release first.
What leaves your repository
Every run makes one request to Leanbump for each Mathlib release it steps through: it downloads the rename map between those two releases, and the request holds the two release numbers, nothing from your code. With upload: auto, a private repository sends nothing else. For a public repository, the action uploads the report it wrote (releases, counts, the labelled changes with their before and after lines, the errors left with their goal states, model token counts) to POST /api/runs. Nothing else is stored: not your environment, not your keys, not local paths, and a report holding anything shaped like a key is refused. The run page it links is kept for 12 months, then deleted. Your model key goes from the GitHub secret to your provider and never to Leanbump.
The action's code is open: github.com/grain64-labs/leanbump. Prefer to try it first? Scan a public repository to see what would break at the next release, no account needed.