1
0
mirror of https://github.com/Refactorio/RedMew.git synced 2024-12-14 10:13:13 +02:00
RedMew/.travis/release_builder.sh

59 lines
2.4 KiB
Bash
Raw Normal View History

#!/bin/bash
#Copy the repo, clean it, and write the version for the release
cd ~/build || exit
echo "Changing dir to :"
pwd
echo "Copying RedMew folder to work on"
cp -rf Refactorio/RedMew working_copy
echo "Removing git files"
rm -rf working_copy/.??*
echo "Writing the version file"
echo "global.redmew_version=$DATE_FORMATTED-$COMMIT_SHA" > working_copy/resources/version.lua
echo "Contents of the version file:"
cat working_copy/resources/version.lua
echo "Copying map_selection.lua.sample to map_selection.lua"
cp working_copy/map_selection.lua.sample working_copy/map_selection.lua
#Create zips for each of the major maps/scenarios
function process_map (){
2019-02-01 03:36:08 +02:00
#Show us which file is being worked on
echo "-----$1-----"
2019-02-01 03:36:08 +02:00
#Rename the directory per map
mv "$3" "$1"
# Overwrite the first line of map_selection.lua
sed -i "1s/.*/return require 'map_gen.maps.$2'/" "$1/map_selection.lua"
echo "First line of map_selection:"
#Display the first line of map_selection.lua for verification
head -1 "$1/map_selection.lua"
2019-02-01 03:36:08 +02:00
if [ "$4" != true ]; then #Base RedMew can't be deflated
echo "Remove binary files (images)"
#Remove the binary files that don't compress well
2019-02-01 03:47:26 +02:00
rm "$1"/redmew_git_banner.png -f
rm "$1"/map_gen/data/.source_images -rf
rm "$1"/map_gen/data/.map_previews -rf
2019-02-01 03:36:08 +02:00
fi
echo "Creating zip..."
2019-02-01 03:36:08 +02:00
#Create the actual zip file with recursion, quiet, and max compression
zip -r9q "$1.zip" "$1"
echo "Stats on the zip:"
ls -al "$1.zip"
cp "$1.zip" "$HOME/build/Refactorio/RedMew/$1.zip"
PREVIOUS_NAME=$1
export PREVIOUS_NAME
return 0
}
#Each map after the default redmew release repeats the pattern of $1=The regular name of the map (proper casing), $2=The name of the map file (lower case), $3 "$PREVIOUS_NAME"
process_map "RedMew" "default" "working_copy" true
2019-02-01 03:36:08 +02:00
process_map "Diggy" "diggy" "$PREVIOUS_NAME"
process_map "Crashsite" "crash_site" "$PREVIOUS_NAME"
process_map "Tetris" "tetris" "$PREVIOUS_NAME"
process_map "Beach" "beach" "$PREVIOUS_NAME"
process_map "Danger_Ores" "danger_ores" "$PREVIOUS_NAME"
process_map "Grid_Islands_Rotated" "grid_islands_rotated" "$PREVIOUS_NAME"
process_map "Toxic_Danger_Ore_Jungle" "toxic_danger_ore_jungle" "$PREVIOUS_NAME"
process_map "Hub_Spiral" "hub_spiral" "$PREVIOUS_NAME"
process_map "Bacon_Islands" "bacon_islands" "$PREVIOUS_NAME"
process_map "Triangle_of_Death" "triangle_of_death" "$PREVIOUS_NAME"