-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathupdate-version.sh
executable file
·52 lines (42 loc) · 1.21 KB
/
update-version.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env bash
if [ -n "$DEBUG" ]; then
set -x;
fi
set -e;
# Make the workspace version in Cargo.toml matches the last git tag
last=$(git describe --tags --abbrev=0)
last="${last:1}"
if [ -n "$1" ]; then
last=$1
fi
if [ -z "$last" ]; then
echo "No tags found"
exit 1
fi
current=$(grep -oP '^version = "\K[^"]+' Cargo.toml)
if [ -z "$current" ]; then
echo "No workspace version found"
exit 1
fi
if [ "$last" == "$current" ]; then
echo "Workspace version up-to-date"
exit 0
fi
echo "Updating version from $current to $last"
echo "Updating Cargo.toml"
sed -i "s|^version = \"$current\"|version = \"$last\"|g" Cargo.toml
crates=(prost-validate prost-reflect-validate prost-validate-build prost-validate-derive prost-validate-types prost-validate-derive-core)
for c in "${crates[@]}"; do
if grep -q "$c = { version = \"$current\"" Cargo.toml; then
echo "Updating $c in Cargo.toml"
sed -i "s|$c = { version = \"$current\"|$c = { version = \"$last\"|g" Cargo.toml
fi
done
cargo update
# Update README.md files to reference the latest version
for f in $(find . -name "README.md"); do
if grep -q "$current" $f; then
echo "Updating $f"
sed -i "s|$current|$last|g" $f
fi
done