Skip to content

Commit 6ca23a7

Browse files
kim-emclaude
andauthored
fix: nightly revision date logic and mathlib trigger auth (#12463)
This PR fixes two issues discovered during the first test of the revised nightly release workflow (#12461): **1. Date logic:** The `workflow_dispatch` path used `date -u +%F` (current UTC date) to find the base nightly to revise. If the most recent nightly was from yesterday (e.g. `nightly-2026-02-12`) but UTC has rolled over to Feb 13, the code would look for `nightly-2026-02-13`, not find it, and create a fresh nightly instead of a revision. Now finds the latest `nightly-*` tag via `sort -rV` and creates a revision of that. **2. Mathlib trigger:** The "Update toolchain on mathlib4's nightly-testing branch" step was broken in two ways: - Workflow renamed: `nightly_bump_toolchain.yml` → `nightly_bump_and_merge.yml` (leanprover-community/mathlib4#34827) - `MATHLIB4_BOT` PAT expired after mathlib migrated to GitHub Apps (leanprover-community/mathlib4#34751) - Replace with `actions/create-github-app-token` using the `mathlib-nightly-testing` app, matching the pattern used in mathlib4's own workflows. 🤖 Prepared with Claude Code Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent e760b8d commit 6ca23a7

File tree

1 file changed

+22
-14
lines changed

1 file changed

+22
-14
lines changed

.github/workflows/ci.yml

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -60,22 +60,20 @@ jobs:
6060
if [[ -n '${{ secrets.PUSH_NIGHTLY_TOKEN }}' ]]; then
6161
git remote add nightly https://foo:'${{ secrets.PUSH_NIGHTLY_TOKEN }}'@github.com/${{ github.repository_owner }}/lean4-nightly.git
6262
git fetch nightly --tags
63-
BASE_NIGHTLY="nightly-$(date -u +%F)"
6463
if [[ '${{ github.event_name }}' == 'workflow_dispatch' ]]; then
65-
# Manual re-release: find next available revision if base nightly exists
66-
if git rev-parse "refs/tags/$BASE_NIGHTLY" >/dev/null 2>&1; then
67-
REV=1
68-
while git rev-parse "refs/tags/${BASE_NIGHTLY}-rev${REV}" >/dev/null 2>&1; do
69-
REV=$((REV + 1))
70-
done
71-
LEAN_VERSION_STRING="${BASE_NIGHTLY}-rev${REV}"
72-
else
73-
LEAN_VERSION_STRING="$BASE_NIGHTLY"
74-
fi
64+
# Manual re-release: create a revision of the most recent nightly
65+
BASE_NIGHTLY=$(git tag -l 'nightly-*' | sort -rV | head -1)
66+
# Strip any existing -revK suffix to get the base date tag
67+
BASE_NIGHTLY="${BASE_NIGHTLY%%-rev*}"
68+
REV=1
69+
while git rev-parse "refs/tags/${BASE_NIGHTLY}-rev${REV}" >/dev/null 2>&1; do
70+
REV=$((REV + 1))
71+
done
72+
LEAN_VERSION_STRING="${BASE_NIGHTLY}-rev${REV}"
7573
echo "nightly=$LEAN_VERSION_STRING" >> "$GITHUB_OUTPUT"
7674
else
7775
# Scheduled: do nothing if commit already has a different tag
78-
LEAN_VERSION_STRING="$BASE_NIGHTLY"
76+
LEAN_VERSION_STRING="nightly-$(date -u +%F)"
7977
if [[ "$(git name-rev --name-only --tags --no-undefined HEAD 2> /dev/null || echo "$LEAN_VERSION_STRING")" == "$LEAN_VERSION_STRING" ]]; then
8078
echo "nightly=$LEAN_VERSION_STRING" >> "$GITHUB_OUTPUT"
8179
fi
@@ -513,8 +511,18 @@ jobs:
513511
gh workflow -R leanprover/release-index run update-index.yml
514512
env:
515513
GITHUB_TOKEN: ${{ secrets.RELEASE_INDEX_TOKEN }}
514+
- name: Generate mathlib nightly-testing app token
515+
id: mathlib-app-token
516+
uses: actions/create-github-app-token@29824e69f54612133e76f7eaac726eef6c875baf # v2.2.1
517+
continue-on-error: true
518+
with:
519+
app-id: ${{ secrets.MATHLIB_NIGHTLY_TESTING_APP_ID }}
520+
private-key: ${{ secrets.MATHLIB_NIGHTLY_TESTING_PRIVATE_KEY }}
521+
owner: leanprover-community
522+
repositories: mathlib4-nightly-testing
516523
- name: Update toolchain on mathlib4's nightly-testing branch
524+
if: steps.mathlib-app-token.outcome == 'success'
517525
run: |
518-
gh workflow -R leanprover-community/mathlib4-nightly-testing run nightly_bump_toolchain.yml
526+
gh workflow -R leanprover-community/mathlib4-nightly-testing run nightly_bump_and_merge.yml
519527
env:
520-
GITHUB_TOKEN: ${{ secrets.MATHLIB4_BOT }}
528+
GITHUB_TOKEN: ${{ steps.mathlib-app-token.outputs.token }}

0 commit comments

Comments
 (0)