Skip to content
Open
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
80 changes: 80 additions & 0 deletions .github/workflows/update-lean-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: Update Lean Version

on:
schedule:
# Runs every night at 2 AM UTC
- cron: "0 2 * * *"
workflow_dispatch: # for manual trigger

jobs:
update-lean:
runs-on: ubuntu-latest
permissions:
contents: read

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Get current Lean version
id: current
run: |
CURRENT_VERSION=$(cat lean-toolchain | tr -d '[:space:]')
echo "version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
echo "Current version: $CURRENT_VERSION"

- name: Get latest Lean 4 stable version
id: latest
run: |
LATEST=$(curl -s https://api.github.com/repos/leanprover/lean4/releases | \
jq -r '[.[] | select(.prerelease == false and (.tag_name | test("^v[0-9]+\\.[0-9]+\\.[0-9]+$")))][0].tag_name')
echo "version=leanprover/lean4:$LATEST" >> $GITHUB_OUTPUT
echo "Latest stable version: leanprover/lean4:$LATEST"

- name: Check if update needed
id: check
run: |
if [ "${{ steps.current.outputs.version }}" != "${{ steps.latest.outputs.version }}" ]; then
echo "update_needed=true" >> $GITHUB_OUTPUT
echo "Update needed: ${{ steps.current.outputs.version }} -> ${{ steps.latest.outputs.version }}"
else
echo "update_needed=false" >> $GITHUB_OUTPUT
echo "Already on latest version"
fi

- name: Update lean-toolchain
if: steps.check.outputs.update_needed == 'true'
run: |
echo "${{ steps.latest.outputs.version }}" > lean-toolchain
cat lean-toolchain

- name: Install elan
if: steps.check.outputs.update_needed == 'true'
run: |
curl https://raw.githubusercontent.com/leanprover/elan/master/elan-init.sh -sSf | sh -s -- -y --default-toolchain none
echo "$HOME/.elan/bin" >> $GITHUB_PATH

- name: Update dependencies
if: steps.check.outputs.update_needed == 'true'
id: deps
run: |
export PATH="$HOME/.elan/bin:$PATH"
# Update all dependencies to latest compatible versions
lake update 2>&1 | tee update.log
echo "deps_updated=true" >> $GITHUB_OUTPUT

- name: Test build
if: steps.check.outputs.update_needed == 'true'
id: build
continue-on-error: true
run: |
export PATH="$HOME/.elan/bin:$PATH"
lake build 2>&1 | tee build.log
build_exit_code=${PIPESTATUS[0]}
if [ "$build_exit_code" -eq 0 ]; then
echo "build_status=success" >> $GITHUB_OUTPUT
else
echo "build_status=failed" >> $GITHUB_OUTPUT
fi