Skip to content

Commit 73b56c4

Browse files
authored
[CI] Auto-update versions in localized content files (#9460)
Signed-off-by: Vitor Vasconcellos <vvasconcellos1@gmail.com>
1 parent 2b99811 commit 73b56c4

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

scripts/auto-update/version-in-file.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,40 @@ function process_file() {
6464
fi
6565
}
6666

67+
function update_locale_files() {
68+
# Only expand files under content/en/
69+
if [[ ! "$file_name" =~ ^content/en/ ]]; then
70+
return
71+
fi
72+
73+
local relative_path="${file_name#content/en/}"
74+
75+
for locale_dir in content/*/; do
76+
local locale="${locale_dir#content/}"
77+
locale="${locale%/}"
78+
[[ "$locale" == "en" ]] && continue
79+
80+
local locale_file="content/${locale}/${relative_path}"
81+
[[ ! -f "$locale_file" ]] && continue
82+
83+
local match_regex="^ *$variable_name:"
84+
local ver="$latest_semver"
85+
86+
if ! grep -q "$match_regex" "$locale_file"; then
87+
continue
88+
fi
89+
90+
echo "UPDATING locale: $locale_file"
91+
sed -i.bak -e "s/\($match_regex\) .*/\1 $ver/" "$locale_file"
92+
rm -f "$locale_file".bak
93+
done
94+
}
95+
6796
while [[ $# -gt 0 ]]; do
6897
variable_name=$1; shift;
6998
file_name=$1; shift;
7099
process_file $variable_name $file_name
100+
update_locale_files
71101
done
72102

73103
if git diff --quiet "${file_names[@]}"; then

0 commit comments

Comments
 (0)