Skip to content

Commit 24dfff6

Browse files
committed
Add developer tool to update versions
1 parent eff43d5 commit 24dfff6

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

tools/update-version.sh

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Small utility to run update crate versions
2+
# Used by godot-rust developers
3+
4+
# No args specified: do everything
5+
if [ "$#" -eq 0 ]; then
6+
echo "Usage: update-version.sh <newVersion>"
7+
exit 1
8+
fi
9+
10+
# --help menu
11+
args=("$@")
12+
for arg in "${args[@]}"; do
13+
if [ "$arg" == "--help" ]; then
14+
echo "Usage: update-version.sh <newVersion>"
15+
echo ""
16+
echo "Replaces currently published version with <newVersion>".
17+
echo "Does not git commit."
18+
exit 0
19+
fi
20+
done
21+
22+
# Uncommitted changes, see https://stackoverflow.com/a/3879077
23+
#if git diff --quiet --exit-code; then
24+
git diff-index --quiet HEAD -- || {
25+
echo "Repo contains uncommitted changes; make sure working tree is clean."
26+
exit 1
27+
}
28+
29+
# https://stackoverflow.com/a/11114547
30+
scriptFile=$(realpath "$0")
31+
scriptPath=$(dirname "$scriptFile")
32+
33+
newVersion="${args[0]}"
34+
oldVersion=$(grep -Po '^version = "\K[^"]*' "$scriptPath/../gdnative/Cargo.toml")
35+
36+
publishedCrates=(
37+
"impl/proc-macros"
38+
"gdnative-sys"
39+
"gdnative-derive"
40+
"gdnative-core"
41+
"bindings-generator"
42+
"gdnative-bindings"
43+
"gdnative-async"
44+
"gdnative"
45+
)
46+
47+
for crate in "${publishedCrates[@]}"; do
48+
# Don't just replace version string itself -- the following only replaces the crate's own version
49+
# (with 'version = "1.2.3"') and dependencies with "=1.2.3", which makes false positives unlikely
50+
sed -i "s!version = \"${oldVersion}\"!version = \"${newVersion}\"!g" "$scriptPath/../$crate/Cargo.toml" || exit 2
51+
sed -i "s!\"=${oldVersion}\"!\"=${newVersion}\"!g" "$scriptPath/../$crate/Cargo.toml" || exit 2
52+
done
53+
54+
git commit -am "Update godot-rust version: $oldVersion -> $newVersion" || exit 2
55+
git tag "$newVersion" || exit 2
56+
57+
echo "Updated version $oldVersion -> $newVersion"

0 commit comments

Comments
 (0)