Skip to content
This repository was archived by the owner on Apr 5, 2024. It is now read-only.

Commit c2db54e

Browse files
committed
Add script to update toolchain version everywhere
This should keep toolchain versions consistent, and prevent forgetting to update it in one of the places.
1 parent e638bd3 commit c2db54e

File tree

2 files changed

+50
-1
lines changed

2 files changed

+50
-1
lines changed

.github/workflows/style.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
- name: Shellcheck
2222
run: |
2323
shellcheck --version
24-
shellcheck ci/*.sh
24+
shellcheck ci/*.sh scripts/toolchain-version
2525
2626
- name: Update nightly
2727
run: |

scripts/toolchain-version

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/bin/bash
2+
3+
set -eu
4+
5+
6+
NIGHTLY_RE="nightly-[0-9]{4}-[0-9]{2}-[0-9]{2}"
7+
8+
nightly_mentions() {
9+
grep -Eo "$NIGHTLY_RE" "$1" | sort --unique
10+
}
11+
12+
check_versions_match() {
13+
readarray -t versions_readme < <(nightly_mentions README.md)
14+
if [[ "${#versions_readme[@]}" -gt 1 ]]; then
15+
echo "Multiple different nightly versions mentioned in README.md: ${versions_readme[*]}"
16+
exit 1
17+
fi
18+
19+
version_toolchain=$(nightly_mentions rust-toolchain)
20+
if [[ "${versions_readme[0]}" != "${version_toolchain}" ]]; then
21+
echo "Toolchain nightly version does not match README.md: ${version_toolchain} vs. ${versions_readme[0]}"
22+
exit 1
23+
fi
24+
}
25+
26+
update_version_everywhere() {
27+
if ! echo "$1" | grep -Eq "$NIGHTLY_RE"; then
28+
echo "That doesn't look like a nightly version to me: '$1'"
29+
exit 1
30+
fi
31+
32+
sed -i -E -e "s#${NIGHTLY_RE}#$1#g" README.md rust-toolchain
33+
}
34+
35+
36+
while getopts "cu:" opt; do
37+
case $opt in
38+
c)
39+
check_versions_match
40+
;;
41+
u)
42+
update_version_everywhere "$OPTARG"
43+
;;
44+
*)
45+
echo "Usage: $0 [-c | -u <nightly version> ]"
46+
exit 1
47+
;;
48+
esac
49+
done

0 commit comments

Comments
 (0)