mirror of
https://github.com/rust-lang/mdBook.git
synced 2025-12-27 10:16:09 -05:00
Add job to automatically update dependencies
This adds a job to automatically update cargo dependencies once a month. I've added this script instead of using Renovate because I couldn't get Renovate to update versions in `Cargo.toml`. I also wanted to batch transitive dependency updates all in one PR.
This commit is contained in:
20
.github/workflows/update-dependencies.yml
vendored
Normal file
20
.github/workflows/update-dependencies.yml
vendored
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
name: Update dependencies
|
||||||
|
on:
|
||||||
|
schedule:
|
||||||
|
- cron: '0 0 1 * *'
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
update:
|
||||||
|
name: Update dependencies
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v5
|
||||||
|
- name: Install Rust
|
||||||
|
run: bash ci/install-rust.sh stable x86_64-unknown-linux-gnu
|
||||||
|
- name: Install cargo-edit
|
||||||
|
run: cargo install cargo-edit --locked
|
||||||
|
- name: Update dependencies
|
||||||
|
run: ci/update-dependencies.sh
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ github.token }}
|
||||||
44
ci/update-dependencies.sh
Executable file
44
ci/update-dependencies.sh
Executable file
@@ -0,0 +1,44 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Updates all compatible Cargo dependencies.
|
||||||
|
#
|
||||||
|
# I wasn't able to get Renovate to update compatible dependencies in a way
|
||||||
|
# that I like, so this script takes care of it. This uses `cargo upgrade` to
|
||||||
|
# ensure that `Cargo.toml` also gets updated. This also makes sure that all
|
||||||
|
# transitive dependencies are updated.
|
||||||
|
|
||||||
|
set -ex
|
||||||
|
|
||||||
|
git fetch origin update-dependencies
|
||||||
|
if git checkout update-dependencies
|
||||||
|
then
|
||||||
|
git reset --hard origin/master
|
||||||
|
else
|
||||||
|
git checkout -b update-dependencies
|
||||||
|
fi
|
||||||
|
|
||||||
|
cat > commit-message << 'EOF'
|
||||||
|
Update cargo dependencies
|
||||||
|
|
||||||
|
```
|
||||||
|
EOF
|
||||||
|
cargo upgrade >> commit-message
|
||||||
|
echo '```' >> commit-message
|
||||||
|
if git diff --quiet
|
||||||
|
then
|
||||||
|
echo "No changes detected, exiting."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
# Also update any transitive dependencies.
|
||||||
|
cargo update
|
||||||
|
|
||||||
|
git config user.name "github-actions[bot]"
|
||||||
|
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||||
|
|
||||||
|
git add Cargo.toml Cargo.lock
|
||||||
|
git commit -F commit-message
|
||||||
|
|
||||||
|
git push --force origin update-dependencies
|
||||||
|
|
||||||
|
gh pr create --fill \
|
||||||
|
--head update-dependencies \
|
||||||
|
--base master
|
||||||
@@ -4,6 +4,9 @@
|
|||||||
# Allows @rustbot ready, review, author, or blocked
|
# Allows @rustbot ready, review, author, or blocked
|
||||||
[shortcut]
|
[shortcut]
|
||||||
|
|
||||||
|
# Closes/reopens PRs created by the GitHub Actions bot so that checks will run.
|
||||||
|
[bot-pull-requests]
|
||||||
|
|
||||||
[relabel]
|
[relabel]
|
||||||
allow-unauthenticated = [
|
allow-unauthenticated = [
|
||||||
# For Issue areas
|
# For Issue areas
|
||||||
|
|||||||
Reference in New Issue
Block a user