forked from rust-bitcoin/rust-bitcoin
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: add weekly job to update nightly rustc
- Loading branch information
Showing
1 changed file
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
name: Update Nightly rustc | ||
on: | ||
schedule: | ||
- cron: "0 0 * * 0" # runs weekly on Sunday at 00:00 | ||
workflow_dispatch: # allows manual triggering | ||
jobs: | ||
format: | ||
name: Update nightly rustc | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: dtolnay/rust-toolchain@nightly | ||
- name: Update rust.yml to use latest nightly | ||
run: | | ||
set -x | ||
# Not every night has a nightly, so extract the date from whatever | ||
# version of the compiler dtolnay/rust-toolchain gives us. | ||
NIGHTLY_DATE=$(rustc +nightly --verbose --version | sed -ne 's/^commit-date: //p') | ||
# Edit in-place the main CI job for PRs. The only other dependencies | ||
# on Nightly in CI are other cronjobs which are fine to use an unpinned | ||
# nightly. | ||
sed -i "s/toolchain: nightly-.*/toolchain: nightly-${NIGHTLY_DATE}/" .github/workflows/rust.yml || exit 1 | ||
echo "nightly_date=${NIGHTLY_DATE}" >> $GITHUB_ENV | ||
# Plausibly there was no update to nightly over the course of a week, | ||
# or dtolnay's script is broken, or something. In this case don't make | ||
# an empty PR. Can also trigger if we manually run this action right | ||
# before the automated one. | ||
if git diff --exit-code > /dev/null; then | ||
echo "Updated nightly. Opening PR." | ||
echo "changes_made=true" >> $GITHUB_ENV | ||
else | ||
echo "Attempted to update nightly but the latest-nightly date did not change. Not opening any PR." | ||
echo "changes_made=false" >> $GITHUB_ENV | ||
fi | ||
- name: Create Pull Request | ||
if: env.changes_made == 'true' | ||
uses: peter-evans/create-pull-request@v6 | ||
with: | ||
author: Update Nightly Rustc Bot <bot@example.com> | ||
title: Automated weekly update to rustc (to nightly-${{ env.nightly_date }}) | ||
body: | | ||
Automated update to Github CI workflow `rust.yml` by [create-pull-request](https://github.com/peter-evans/create-pull-request) GitHub action | ||
commit-message: Automated update to Github CI to rustc nightly-${{ env.nightly_date }} |