-
Notifications
You must be signed in to change notification settings - Fork 6
49 lines (46 loc) · 2.28 KB
/
rust-version.yml
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
# Opens a PR to update the nightly Rust version every two weeks
name: Rust Version Check
on:
workflow_dispatch:
schedule:
- cron: '0 0 1,15 * *'
jobs:
rust-version-check:
runs-on: ubuntu-latest
strategy:
matrix:
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 }}