Only clone renpy/etc. if there is a need to build

This commit is contained in:
HackerNCoder 2023-08-17 19:31:11 +02:00
parent b61d42b675
commit 3d8c199eca
2 changed files with 48 additions and 21 deletions

View file

@ -4,7 +4,40 @@
declare -A langnames=( ["es_419"]="spanish" ["pt_BR"]="brazilian_portuguese" ["ru"]="russian" ["pl"]="polish" )
declare -a filesToDo
for file in ./translations-*.po; do
stats=$(msgfmt --statistics ${file} 2>&1)
numdone=$(echo ${stats%* translated*})
if [[ $numdone -le 5400 ]]; then
echo -e "\x1B[36mSKIPPING ${file#\.\/} since it has less than 5400 strings translated\x1B[0m"
continue
fi
if (( $(date -d $(awk '/PO-Revision-Date/{ sub(/\+.*/,""); print $2"T"$3}' ${file}) +%s) < $CI_PREV_BUILD_STARTED )); then
echo -e "\x1B[36mSKIPPING ${file#\.\/} since it hasn't been changed since last CI\x1B[0m"
continue
fi
echo -e "\x1B[36mAdding ${file#\.\/} to list of files to build\x1B[0m"
filesToDo+=(file)
done
if ${#filesToDo[@]} > 0; then
echo
echo "\x1B[36m---------------------"
echo "| CLONING |"
echo "---------------------\x1B[0m"
echo
git clone https://lab.encryptionin.space/Queerscriptors/rttk-queerscriptors.git
git clone https://lab.encryptionin.space/Queerscriptors/renpy.git
git clone -b game ${CI_REPO_REMOTE} ./game-source
echo
echo "\x1B[36m--------------------"
echo "| BUILDING |"
echo "--------------------\x1B[0m"
echo
for file in filesToDo; do
file2=${file%.po}
langcc=${file2#\.\/translations\-}
if [[ -n ${langnames[$langcc]} ]]; then
@ -16,21 +49,18 @@ for file in ./translations-*.po; do
lang=$langcc
fi
stats=$(msgfmt --statistics ${file} 2>&1)
numdone=$(echo ${stats%* translated*})
if [[ $numdone -le 5400 ]]; then
echo -e "\x1B[36mSKIPPING $file since it has less than 5680 strings translated\x1B[0m"
continue
fi
if (( $(date -d $(awk '/PO-Revision-Date/{ sub(/\+.*/,""); print $2"T"$3}' ${file}) +%s) < $CI_PREV_BUILD_STARTED )); then
echo -e "\x1B[36mSKIPPING $file since it hasn't been changed since last CI\x1B[0m"
continue
fi
echo -e "\x1B[36mBUILDING $file \x1B[0m"
echo -e "\x1B[36mBUILDING ${file#\.\/} \x1B[0m"
msgfmt "$file" -o game.mo
PATH=$(pwd)/renpy:${PATH} RENPY_DIR=$(pwd)/renpy python3 rttk-queerscriptors/mo2tl.py $(pwd)/game-source game.mo ${lang}
(cd game-source/game/tl/${lang} && zip -r "${lang}.zip" . && mv "${lang}.zip" "/var/www/queer/build/${CI_REPO_NAME}/${lang}.zip" )
echo -e "\e[32mFINISHED $file\e[0m"
done
echo
done
echo
echo "\x1B[36m--------------------"
echo "| DONE |"
echo "--------------------\x1B[0m"
echo
else
echo -e "\x1B[36mNothing to do\x1B[0m"
fi

View file

@ -4,9 +4,6 @@ pipeline:
commands:
- apt-get update
- apt-get install -y git gettext python3 libgl1 zip
- git clone https://lab.encryptionin.space/Queerscriptors/rttk-queerscriptors.git
- git clone https://lab.encryptionin.space/Queerscriptors/renpy.git
- git clone -b game ${CI_REPO_REMOTE} ./game-source
- bash .po2tl.sh
volumes:
- /var/www/queer/build/${CI_REPO_NAME}:/var/www/queer/build/${CI_REPO_NAME}