/ .github / workflows / rust-latest-version-check.yml
rust-latest-version-check.yml
 1  name: Check for a new Rust version
 2  
 3  on:
 4    schedule:
 5      - cron: "0 3 * * *"
 6  
 7  jobs:
 8    check-latest-version:
 9      name: Fetch and compare latest Rust release
10      runs-on: ubuntu-latest
11      steps:
12        - name: Checkout repository
13          uses: actions/checkout@85e6279cec87321a52edac9c87bce653a07cf6c2  # Version 4.2.2
14        - name: Fetch latest Rust release
15          id: latest-version
16          run: |
17            LATEST=$(curl -s https://api.github.com/repos/rust-lang/rust/releases/latest | jq -r .tag_name)
18            echo "Latest Rust version: $LATEST"
19            echo "VERSION=$LATEST" >> $GITHUB_OUTPUT
20        - name: Retrieve local Rust version
21          id: installed-version
22          run: |
23            INSTALLED=$(cargo --version | awk '{print $2}')
24            echo "Installed Rust version: $INSTALLED"
25            echo "VERSION=$INSTALLED" >> $GITHUB_OUTPUT
26        - name: Compare latest and local Rust versions
27          id: compare-versions
28          run: |
29            if [ "${{ steps.latest-version.outputs.VERSION }}" != "${{ steps.installed-version.outputs.VERSION }}" ]; then
30              NEW_VERSION_AVAILABLE=true
31            else
32              NEW_VERSION_AVAILABLE=false
33            fi
34            echo "NEW_VERSION_AVAILABLE=$NEW_VERSION_AVAILABLE" >> $GITHUB_OUTPUT
35      outputs:
36        new-version-available: ${{ steps.compare-versions.outputs.NEW_VERSION_AVAILABLE }}
37        new-version: ${{ steps.latest-version.outputs.VERSION }}
38    notify-new-version:
39      name: Notify of new Rust version
40      runs-on: ubuntu-latest
41      needs: check-latest-version
42      if: ${{ needs.check-latest-version.outputs.new-version-available == 'true' }}
43      steps:
44        - name: Checkout repository
45          uses: actions/checkout@85e6279cec87321a52edac9c87bce653a07cf6c2  # Version 4.2.2
46        - name: Create a GH issue (if it does not exist)
47          uses: JasonEtco/create-an-issue@1b14a70e4d8dc185e5cc76d3bec9eab20257b2c5 # Version 2.9.2
48          env:
49            GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
50            RUST_VERSION: ${{ needs.check-latest-version.outputs.new-version }}
51          with:
52            assignees: danielSanchezQ, ntn-x2
53            filename: ./.github/rust_update_issue_template.md
54            update_existing: false
55            search_existing: all