-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
57 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,57 @@ | ||
name: Update nightly Rust | ||
on: | ||
schedule: | ||
- cron: "29 17 1 * *" # At 17:29 on day-of-month 1. | ||
workflow_dispatch: # allows manual triggering | ||
env: | ||
CARGO_TERM_COLOR: always | ||
jobs: | ||
format: | ||
name: Update nightly Rustc | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
persist-credentials: false | ||
- uses: dtolnay/rust-toolchain@nightly | ||
- name: Update rust-toolchain.toml to use latest nightly | ||
run: | | ||
set -x | ||
# Get the latest nightly date. | ||
# If the latest nightly date is not the same as the current nightly date, | ||
# rustup will default to the latest nightly up to TODAY. | ||
# | ||
# Example: If the latest nightly is 2023-07-01, and the TODAY is 2023-07-02, | ||
# then rustup will default to nightly-2023-07-01. | ||
TODAY="$(date +%Y-%m-%d)" | ||
# Update the nightly version in the rust-toolchain.toml file. | ||
echo "Updating rust-toolchain.toml to use nightly-$TODAY" | ||
sed -i "s/^channel = \"nightly-.*\"/channel = \"nightly-$TODAY\"/" rust-toolchain.toml | ||
# Update the nightly date in the environment. | ||
echo "nightly_date=${TODAY}" >> "$GITHUB_ENV" | ||
# Maybe there is no new nightly. | ||
# In this case don't make an empty PR. | ||
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@v7 | ||
env: | ||
NIGHTLY_DATE: ${{ env.nightly_date }} | ||
with: | ||
author: Update Nightly Rustc Bot <[email protected]> | ||
committer: Update Nightly Rustc Bot <[email protected]> | ||
title: Automated update to rustc (to nightly-$NIGHTLY_DATE) | ||
body: | | ||
Automated update to Rust nightly by [create-pull-request](https://github.com/peter-evans/create-pull-request) GitHub action | ||
commit-message: Automated update to Rust nightly-$NIGHTLY_DATE | ||
branch: create-pull-request/automated-nightly-update |