Skip to content

Commit

Permalink
Merge pull request #195 from artichoke/b-n/automate-rust-bump
Browse files Browse the repository at this point in the history
Automate the gathering and publishing of new toolchain versions
  • Loading branch information
b-n authored Jan 23, 2024
2 parents 7898a39 + 4a14738 commit 708e8d8
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 0 deletions.
82 changes: 82 additions & 0 deletions .github/workflows/toolchain-version-check.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
---
name: Toolchain Version Check
"on":
schedule:
- cron: "0 5 * * 5" # 5am UTC Fridays. Rust toolchain versions merge Thursday afternoons.

jobs:
check-toolchain-version:
name: Check toolchain version
runs-on: ubuntu-latest

steps:
- uses: actions/[email protected]

- name: Install Ruby toolchain
uses: ruby/setup-ruby@8575951200e472d5f2d95c625da0c7bec8217c42 # v1.161.0
with:
ruby-version: ".ruby-version"
bundler-cache: true

- name: Read existing rustc version
id: rust_version
run: |
echo "version=$(bundle exec rake toolchain:version)" >> "$GITHUB_OUTPUT"
- name: Check the latest rustc version
id: latest_rust_release
uses: octokit/request-action@89697eb6635e52c6e1e5559f15b5c91ba5100cb0 # v2.1.9
with:
route: GET /repos/{owner}/{repo}/releases/latest
owner: rust-lang
repo: rust
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Extract rust version info
id: version_info
env:
CURRENT: ${{ steps.rust_version.outputs.version }}
NEXT: ${{ fromJson(steps.latest_rust_release.outputs.data).tag_name }}
run: |
echo "current=$CURRENT" >> "$GITHUB_OUTPUT"
echo "next=$NEXT" >> "$GITHUB_OUTPUT"
if [[ "$CURRENT" == "$NEXT" ]]; then
echo "matches=true" >> "$GITHUB_OUTPUT"
else
echo "matches=false" >> "$GITHUB_OUTPUT"
fi
- name: Update the toolchain version and run sync
if: ${{ steps.version_info.outputs.matches != 'true' }}
env:
CURRENT: ${{ steps.version_info.outputs.current }}
NEXT: ${{ steps.version_info.outputs.next }}
run: |
# Matches `RUST_VERSION = '$CURRENT'` and replaces with `RUST_VERSION = '$NEXT'`
sed -iE "s/^RUST_VERSION = '$CURRENT'$/RUST_VERSION = '$NEXT'/g" Rakefile
bundle exec rake toolchain:sync
- name: Create Pull Request
uses: peter-evans/create-pull-request@153407881ec5c347639a548ade7d8ad1d6740e38 # v5.0.2
if: ${{ steps.version_info.outputs.matches != 'true' }}
with:
title: Update Rust toolchain from ${{ steps.version_info.outputs.current }} to ${{ steps.version_info.outputs.next }}
body: |
> [!WARNING]
> This PR is automatically created via a Github Action. Ensure all changes are valid before merging.
Update the toolchain and sync to the latest available in rust-lang/rust.
Current toolchain version: ${{ steps.version_info.outputs.current }}
Latest toolchain version: ${{ steps.version_info.outputs.next }}
[Changelog](https://github.com/rust-lang/rust/blob/master/RELEASES.md)
[Commits](https://github.com/rust-lang/rust/compare/${{ steps.version_info.outputs.current}}...${{ steps.version_info.outputs.next }})
commit-message: Sync the toolchain to the latest Rust upstream
base: trunk
branch: actions/update-toolchain-version
labels: |
A-deps
assignees: |
@artichoke/contributors
5 changes: 5 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,9 @@ namespace :toolchain do
raise 'Failed to update some RUST_VERSION args' if failures.any?
end
end

desc 'Output the current toolchain version'
task :version do
puts RUST_VERSION
end
end

0 comments on commit 708e8d8

Please sign in to comment.