@@ -86,35 +86,46 @@ runs:
86
86
- name : " Patch prebuilt version ({{ inputs.godot-prebuilt-patch }})"
87
87
if : inputs.godot-prebuilt-patch != ''
88
88
env :
89
- VERSION : ${{ inputs.godot-prebuilt-patch }}
89
+ PATCHED_VERSION : ${{ inputs.godot-prebuilt-patch }}
90
90
# sed -i'' needed for macOS compatibility, see https://stackoverflow.com/q/4247068
91
91
run : |
92
- echo "Patch prebuilt version to $VERSION..."
92
+ # Find the godot4-prebuilt version that gdext currently depends on.
93
+ defaultVersion=$(grep 'godot4-prebuilt = {' godot-bindings/Cargo.toml | sed -n 's/.*branch = "\([^"]*\)".*/\1/p')
94
+ if [ -z "$defaultVersion" ]; then
95
+ echo "::error::prebuilt version not found or format is incorrect."
96
+ exit 1
97
+ else
98
+ echo "Default prebuilt version: $defaultVersion"
99
+ fi
100
+
101
+ # Apply [patch] for godot4-prebuilt crate if needed.
102
+ if [[ "$PATCHED_VERSION" != $defaultVersion ]]; then
103
+ .github/other/patch-prebuilt.sh "$PATCHED_VERSION"
104
+ fi
93
105
94
- # Reduce version to "major.minor" format
95
- apiVersion=$(echo $VERSION | sed -E 's/([0-9]+\.[0-9]+)\.[0-9]+/\1/')
106
+ # Reduce versions to "major.minor" format.
107
+ apiVersion=$(echo "$PATCHED_VERSION" | sed -E 's/([0-9]+\.[0-9]+)\.[0-9]+/\1/')
108
+ apiDefaultVersion=$(echo "$defaultVersion" | sed -E 's/([0-9]+\.[0-9]+)\.[0-9]+/\1/')
96
109
97
- # For newer versions, update the compatibility_minimum in .gdextension files to the respective version.
98
- # Nothing needs to be done for 4.0.x, as compatibility_minimum didn't exist back then.
99
- if [[ "$apiVersion" == "4.2" ]]; then
110
+ # For newer versions, update 'compatibility_minimum' in .gdextension files to the respective version.
111
+ # Nothing needs to be done for 4.0.x, as compatibility_minimum didn't exist back then (we do it due to easier code, anyway).
112
+ if [[ "$apiVersion" == "$apiDefaultVersion" ]]; then
113
+ echo "Already has version $version; no need to change compatibility_minimum."
114
+
115
+ else
100
116
echo "Update compatibility_minimum in .gdextension files to '$apiVersion'..."
101
117
dirs=("itest" "examples")
118
+
119
+ # Note that this is still hardcoded to 4.1, the start of GDExtension's compatibility promise. This makes it easier for users
120
+ # to use gdext with older Godot versions. There is anyway a runtime check in gdext that checks compatibility again.
102
121
for dir in "${dirs[@]}"; do
103
- find "$dir" -type f -name "*.gdextension" -exec sed -i'.bak' ' s/compatibility_minimum = 4\.1/compatibility_minimum = $apiVersion/' {} +
122
+ find "$dir" -type f -name "*.gdextension" -exec sed -i'.bak' " s/compatibility_minimum = 4\.1/compatibility_minimum = $apiVersion/" {} +
104
123
done
105
124
106
- # Apply Cargo.toml patch for godot4-prebuilt crate
107
- else
108
- # Patch only needed if version is not already set
109
- if grep -E 'godot4-prebuilt = { .+ branch = "$VERSION" }' godot-bindings/Cargo.toml; then
110
- echo "Already has version $version; no need for patch."
111
- else
112
- cat << HEREDOC >> Cargo.toml
113
- [patch."https://github.com/godot-rust/godot4-prebuilt"]
114
- godot4-prebuilt = { git = "https://github.com//godot-rust/godot4-prebuilt", branch = "$VERSION" }
115
- HEREDOC
116
- echo "Patched Cargo.toml for version $version."
117
- fi
125
+ echo "Example output: itest/godot/itest.gdextension"
126
+ echo "----------------------------------------------------"
127
+ cat itest/godot/itest.gdextension
128
+ echo "----------------------------------------------------"
118
129
fi
119
130
120
131
shell : bash
0 commit comments