addon/release.sh
2024-08-22 16:12:40 +02:00

117 lines
No EOL
2.7 KiB
Bash
Executable file

#!/usr/bin/env zsh
output_directory="CzechQuests"
wow_versions=(
"Classic ERA" # 1 - classic_era
"Retail" # 2 - retail
)
toc_files=(
"CzechQuests_Vanilla.toc"
"CzechQuests_Mainline.toc"
)
read_toc_version() {
local wow_version=$1
local toc_file=${toc_files[$wow_version]}
local current_version=0
if [[ -f "$toc_file" ]]; then
current_version=$(grep "## Version:" "$toc_file" | cut -d ' ' -f 3)
fi
echo "$current_version"
}
write_toc_version() {
local wow_version=$1
local next_version=$2
local toc_file=${toc_files[$wow_version]}
if [[ -f "$toc_file" ]]; then
sed -i '' "s/## Version: $current_version/## Version: $next_version/" "$toc_file"
fi
}
make_zip() {
local wow_version=$1
local current_version=$2
local zip_filename=""
local files_to_zip=()
# prepare output directory
mkdir -p $output_directory
mkdir -p "${output_directory}/Quests/Data/"
# Includes classic era continents
if [ "$wow_version" = "1" ]; then
cp -r "./Quests/Data/classic_era/" "${output_directory}/Quests/Data/"
cp "./CzechQuests_Vanilla.toc" "${output_directory}"
zip_filename="czech-quests-classic_era-v$current_version.zip"
fi
# Includes retail continents
if [ "$wow_version" = "2" ]; then
cp -r "./Quests/Data/retail/" "${output_directory}/Quests/Data/"
cp "./CzechQuests_Mainline.toc" "${output_directory}"
zip_filename="czech-quests-retail-v$current_version.zip"
fi
# includes frames
while IFS= read -r line; do
files_to_zip+=("$line")
done < <(find . -name "*.lua" -path "./Quests/Frames/*")
# includes other files
files_to_zip+=("./Quests/Data/other.lua" "./Quests/Quests.lua" "./Quests/Utils.lua" "./Init.lua")
files_to_zip+=("./morpheus_cz.ttf" "./frizquadratatt_cz.ttf")
# prepare output directory
for file in "${files_to_zip[@]}"; do
rsync -R "$file" $output_directory
done
# create zip file
zip -r "$zip_filename" $output_directory
# remove output directory
rm -r $output_directory
}
release_wow() {
local wow_version=$1
# Read current version from file for wow version
current_version=$(read_toc_version "$wow_version")
# Increase version
new_version="$current_version"
vared -p "Choose version: " new_version
# Write to file
write_toc_version "$wow_version" "$new_version"
# Generate zip
make_zip $wow_version $new_version
}
init() {
echo "Choose Wow:"
select opt in "${wow_versions[@]}"
do
case $opt in
"Classic ERA")
echo "You chose Classic ERA"
release_wow 1
return 0
;;
"Retail")
echo "You chose Retail"
release_wow 2
return 0
;;
esac
done
}
init