update-rust-version.yml 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. name: Update Rust Version
  2. on:
  3. schedule:
  4. # Run weekly on Monday at 9 AM UTC
  5. - cron: '0 9 * * 1'
  6. workflow_dispatch: # Allow manual triggering
  7. permissions: {}
  8. jobs:
  9. check-rust-version:
  10. name: Check and update Rust version
  11. runs-on: ubuntu-latest
  12. permissions:
  13. issues: write
  14. steps:
  15. - name: Checkout repository
  16. uses: actions/checkout@v4
  17. - name: Get latest stable Rust version
  18. id: latest-rust
  19. run: |
  20. # Fetch the latest stable Rust version from GitHub releases API
  21. LATEST_VERSION=$(curl -s https://api.github.com/repos/rust-lang/rust/releases | jq -r '[.[] | select(.prerelease == false and .draft == false)][0].tag_name')
  22. echo "version=$LATEST_VERSION" >> $GITHUB_OUTPUT
  23. echo "Latest stable Rust version: $LATEST_VERSION"
  24. - name: Get current Rust version
  25. id: current-rust
  26. run: |
  27. # Extract current version from rust-toolchain.toml
  28. CURRENT_VERSION=$(grep '^channel=' rust-toolchain.toml | sed 's/channel="\(.*\)"/\1/')
  29. echo "version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
  30. echo "Current Rust version: $CURRENT_VERSION"
  31. - name: Compare versions
  32. id: compare
  33. run: |
  34. if [ "${{ steps.latest-rust.outputs.version }}" != "${{ steps.current-rust.outputs.version }}" ]; then
  35. echo "needs_update=true" >> $GITHUB_OUTPUT
  36. echo "Rust version needs update: ${{ steps.current-rust.outputs.version }} -> ${{ steps.latest-rust.outputs.version }}"
  37. else
  38. echo "needs_update=false" >> $GITHUB_OUTPUT
  39. echo "Rust version is up to date"
  40. fi
  41. - name: Create Issue
  42. if: steps.compare.outputs.needs_update == 'true'
  43. env:
  44. GH_TOKEN: ${{ github.token }}
  45. run: |
  46. gh issue create \
  47. --title "Update Rust to ${{ steps.latest-rust.outputs.version }}" \
  48. --label "rust-version" \
  49. --assignee thesimplekid \
  50. --body "$(cat <<'EOF'
  51. New Rust version **${{ steps.latest-rust.outputs.version }}** is available (currently on **${{ steps.current-rust.outputs.version }}**).
  52. ## Files to update
  53. - \`rust-toolchain.toml\` - Update channel to \`${{ steps.latest-rust.outputs.version }}\`
  54. - \`flake.nix\` - Update stable_toolchain to \`pkgs.rust-bin.stable."${{ steps.latest-rust.outputs.version }}".default\`
  55. - Run \`nix flake update rust-overlay\` to update \`flake.lock\`
  56. ## Release Notes
  57. Check the [Rust release notes](https://github.com/rust-lang/rust/blob/master/RELEASES.md) for details on what's new in this version.
  58. ---
  59. 🤖 Automated issue created by update-rust-version workflow
  60. EOF
  61. )"
  62. - name: No update needed
  63. if: steps.compare.outputs.needs_update == 'false'
  64. run: |
  65. echo "✓ Rust version is already up to date (${{ steps.current-rust.outputs.version }})"