A GitHub Action that attempts to update Lean and dependencies of a Lean project. This is basically a fork of oliver-butterley/lean-update but more feature-rich.
Create a file named update.yml in the .github/workflows directory.
To keep dependencies always up-to-date, you might want to configure as follows:
name: Update Lean Projecton:
schedule:
- cron: "0 0 * * *"# every dayworkflow_dispatch: # allows workflow to be triggered manuallyjobs:
update_lean:
# The default GITHUB_TOKEN is read-only, so the write scopes have to be asked for.# Opening the pull request also needs `Allow GitHub Actions to create and approve pull# requests` under Settings > Actions > General > Workflow permissions.permissions:
contents: writepull-requests: writeissues: writeruns-on: ubuntu-lateststeps:
- name: Checkout codeuses: actions/checkout@v6
- name: Update Lean projectuses: leanprover-community/lean-update@mainIf you want to skip updates unless there is a change to the lean-toolchain file, you might want to configure as follows:
name: Update Lean Projecton:
schedule:
- cron: "0 0 * * *"# every dayworkflow_dispatch: # allows workflow to be triggered manuallyjobs:
update_lean:
# The default GITHUB_TOKEN is read-only, so the write scopes have to be asked for.# Opening the pull request also needs `Allow GitHub Actions to create and approve pull# requests` under Settings > Actions > General > Workflow permissions.permissions:
contents: writepull-requests: writeissues: writeruns-on: ubuntu-lateststeps:
- name: Checkout codeuses: actions/checkout@v6
- name: Update Lean projectuses: leanprover-community/lean-update@mainwith:
update_if_modified: lean-toolchain- First, create a bot in Zulip and note its API key. Be careful not to create a new account - Zulip has a dedicated feature for "creating a bot".
- Next, register the bot's API key as a secret named
ZULIP_API_KEYin your repository. You can set up secrets from the repository's "Settings". - Prepare a workflow file like the following:
name: Update Lean Projecton:
schedule:
- cron: "0 0 * * *"# every dayworkflow_dispatch: # allows workflow to be triggered manuallyjobs:
update_lean:
# The default GITHUB_TOKEN is read-only, so the write scopes have to be asked for.# Opening the pull request also needs `Allow GitHub Actions to create and approve pull# requests` under Settings > Actions > General > Workflow permissions.permissions:
contents: writepull-requests: writeissues: writeruns-on: ubuntu-lateststeps:
- name: Checkout codeuses: actions/checkout@v6
- name: Update Lean projectid: lean-updateuses: leanprover-community/lean-update@mainwith:
on_update_fails: "silent"
- name: Notificationif: steps.lean-update.outputs.result == 'update-fail' # only send a message when the update failsuses: zulip/github-actions-zulip/send-message@v1with:
api-key: ${{ secrets.ZULIP_API_KEY }} # Zulip API key of your botemail: "***-bot@leanprover.zulipchat.com"# your Zulip bot's emailorganization-url: 'https://leanprover.zulipchat.com'to: "123456"# user_idtype: "private"# private messagecontent: | ❌ The update of ${{ github.repository }} has failed - [See Action Run](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}) - [See Commit](https://github.com/${{ github.repository }}/commit/${{ github.sha }})This Action first installs elan and runs
lake update. This fetches the latest Lean release and updates all dependent packages to their latest versions.If
lake updatedetermines that all dependencies are already up to date, this Action does nothing further.Subsequently, this GitHub Action validates the updated code. This performs the build process, runs tests if a test driver is configured, and executes lint checks if a lint driver is set up. You can configure what build arguments are passed to
lake buildusing thebuild_argsoption.This Action classifies the post-update validation results into two categories: success or failure.
- If successful, it behaves according to the setting specified in the
on_update_succeedsoption. By default, this is set topr, which submits the updated code as a pull request. However, if theupdate_if_modifiedoption is set tolean-toolchain, the Action does nothing unless the Lean version has been updated. - If it fails, it behaves according to the setting specified in the
on_update_failsoption. By default, this is set toissue, which submits an issue indicating that the update failed.
- If successful, it behaves according to the setting specified in the
See action.yml for details.