Skip to content

Commit

Permalink
ci: Update Rust version biweekly
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelburnham committed Jul 18, 2024
1 parent 5c77d7a commit 48d94bd
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions .github/workflows/rust-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Opens a PR to update the nightly Rust version every two weeks
name: Rust Version Check

on:
push:
branches:
- "ci-rust-version"
workflow_dispatch:
schedule:
- cron: '0 0 1,15 * *'

jobs:
rust-version-check:
runs-on: ubuntu-latest
matrix:
strategy:
package: ["aptos", "ethereum"]
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
- name: Parse rust-toolchain.toml
run: echo "TOOLCHAIN_VERSION=$(rustup show | grep rustc | awk -F'[()]| ' '{ print $(NF-1) }')" | tee -a $GITHUB_ENV
working-directory: ${{ github.workspace }}/${{ matrix.package }}
- name: Get latest nightly Rust version
run: |
echo "RUST_VERSION=$(rustup check | grep nightly | awk -F'[()]| ' '{print $(NF-1)}')" | tee -a $GITHUB_ENV
- name: Compare Rust versions
id: compare-versions
run: |
if [[ $(printf '%s\n' "$TOOLCHAIN_VERSION" "$RUST_VERSION" | sort -V | head -n 1) != "$RUST_VERSION" ]]; then
echo "outdated=true" | tee -a $GITHUB_OUTPUT
fi
working-directory: ${{ github.workspace }}/${{ matrix.package }}
- name: Update Cargo.toml
if: steps.compare-versions.outputs.outdated == 'true'
run: |
sed -i 's/channel = .*/channel = "nightly-${{ env.RUST_VERSION }}"/' rust-toolchain.toml
working-directory: ${{ github.workspace }}/${{ matrix.package }}
# Open PR if Rust version is out of date with latest nightly
- name: Create Pull Request
if: steps.compare-versions.outputs.outdated == 'true'
uses: peter-evans/create-pull-request@v6
with:
branch: "ci-update-rust-version-${{ matrix.package }}"
title: "chore: Update `${{ matrix.package }}` Rust version to nightly-${{ env.RUST_VERSION }}"
commit-message: "chore: Update `${{ matrix.package }}` Rust version to nightly-${{ env.RUST_VERSION }}"
labels: "automated-issue"
#reviewers: "tchataigner, wwared, storojs72, huitseeker, samuelburnham"
body: |
This is an automated PR updating the `${{ matrix.package }}` Rust version from `nightly-${{ env.TOOLCHAIN_VERSION }}` to `nightly-${{ env.RUST_VERSION }}`
Workflow run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}

0 comments on commit 48d94bd

Please sign in to comment.