-
Notifications
You must be signed in to change notification settings - Fork 57
131 lines (112 loc) · 5.55 KB
/
update-nightly.yml
File metadata and controls
131 lines (112 loc) · 5.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
name: Update nightly-testing
on:
schedule:
- cron: "0 10/6 * * *"
# Run every six hours, starting at 11AM CET/2AM PT.
# This should be 3 hours after lean4 starts building its nightly
workflow_dispatch: # Allow manual triggering
env:
TARGET_BRANCH: nightly-testing
jobs:
# This job checks whether there's been a new nightly since the last
# successful automatic update
check-update:
runs-on: nscloud-ubuntu-22.04-amd64-8x16
if: github.repository == 'leanprover/reference-manual'
outputs:
update-needed: ${{ steps.check-update.outputs.update-needed }}
latest-version: ${{ steps.latest-available.outputs.version }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ env.TARGET_BRANCH }}
token: ${{ secrets.GITHUB_TOKEN }}
- name: Configure Git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Verify target branch exists
run: |
if ! git show-ref --verify --quiet refs/heads/${{ env.TARGET_BRANCH }}; then
echo "Error: Target branch '${{ env.TARGET_BRANCH }}' does not exist"
exit 1
fi
echo "Target branch '${{ env.TARGET_BRANCH }}' exists"
- name: Get current nightly version
id: last-working
run: |
TOOLCHAIN="$(cut -f2 -d: ./lean-toolchain)"
echo "version=$TOOLCHAIN" >> $GITHUB_OUTPUT
- name: Get latest release tag from leanprover/lean4-nightly
id: latest-available
run: |
RELEASE_TAG="$(curl -s "https://api.github.com/repos/leanprover/lean4-nightly/releases" | jq -r '.[0].tag_name')"
echo "RELEASE_TAG=$RELEASE_TAG" >> "${GITHUB_ENV}"
echo "version=$RELEASE_TAG" >> $GITHUB_OUTPUT
- name: Check if update needed
id: check-update
run: |
if [ "${{ steps.last-working.outputs.version }}" = "${{ steps.latest-available.outputs.version }}" ]; then
echo "No update needed - versions match"
echo "✅ Nightly version ${{ steps.last-working.outputs.version }} is already up to date"
echo "✅ Nightly version \`${{ steps.last-working.outputs.version }}\` is already up to date" >> $GITHUB_STEP_SUMMARY
echo "update-needed=false" >> $GITHUB_OUTPUT
else
echo "Update needed: ${{ steps.last-working.outputs.version }} -> ${{ steps.latest-available.outputs.version }}"
echo "Update needed: \`${{ steps.last-working.outputs.version }}\` -> \`${{ steps.latest-available.outputs.version }}\`" >> $GITHUB_STEP_SUMMARY
echo "update-needed=true" >> $GITHUB_OUTPUT
fi
# This job tries to update nightly-testing, and pushes if successful
test-and-update:
runs-on: ubuntu-latest
needs: check-update
if: needs.check-update.outputs.update-needed == 'true'
permissions:
contents: write
outputs:
changes-pushed: ${{ steps.commit.outputs.changes-pushed }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ env.TARGET_BRANCH }}
token: ${{ secrets.GITHUB_TOKEN }}
- name: Configure Git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
- name: Update toolchain file to ${{ needs.check-update.outputs.latest-version }}
run: |
echo "leanprover/lean4:${{ needs.check-update.outputs.latest-version }}" > lean-toolchain
- name: Install elan
run: |
set -o pipefail
curl -sSfL https://github.com/leanprover/elan/releases/download/v4.1.2/elan-x86_64-unknown-linux-gnu.tar.gz | tar xz
./elan-init -y --default-toolchain none
echo "$HOME/.elan/bin" >> "$GITHUB_PATH"
- name: Build
run: |
lake build
- name: Generate HTML
if: steps.check-update.outputs.update-needed == 'true'
run: |
./generate-html.sh --mode preview
- name: Commit and push changes
id: commit
run: |
git add lean-toolchain
git commit -m "chore: bump to nightly ${{ needs.check-update.outputs.latest-version }}"
git push origin ${{ env.TARGET_BRANCH }}
if [[ -f "lean-toolchain" && $(cat "lean-toolchain") == leanprover/lean4:nightly-* ]]; then
toolchain=$(cat "lean-toolchain")
version=${toolchain#leanprover/lean4:nightly-}
git tag "nightly-testing-$version"
git push origin "nightly-testing-$version"
echo "changes-pushed=true" >> $GITHUB_OUTPUT
fi
trigger-nightly-with-manual:
needs: test-and-update
if: needs.test-and-update.outputs.changes-pushed == 'true'
uses: ./.github/workflows/nightly-with-manual.yml
secrets: inherit