#!/bin/sh
set -e
# Move godot templates already installed from the docker image to home
mkdir -v -p ~/.local/share/godot/export_templates
cp -a /root/.local/share/godot/export_templates/. ~/.local/share/godot/export_templates/
if [ "$3" != "" ]
then
SubDirectoryLocation="$3/"
fi
mode="export-release"
if [ "$6" = "true" ]
echo "Exporting in debug mode!"
mode="export-debug"
# Export for project
echo "Building $1 for $2"
mkdir -p $GITHUB_WORKSPACE/build/${SubDirectoryLocation:-""}
cd "$GITHUB_WORKSPACE/$5"
godot --headless --${mode} "$2" $GITHUB_WORKSPACE/build/${SubDirectoryLocation:-""}$1
echo "Build Done"
echo build=build/${SubDirectoryLocation:-""} >> $GITHUB_OUTPUT
if [ "$4" = "true" ]
echo "Packing Build"
mkdir -p $GITHUB_WORKSPACE/package
cd $GITHUB_WORKSPACE/build
zip $GITHUB_WORKSPACE/package/artifact.zip ${SubDirectoryLocation:-"."} -r
echo artifact=package/artifact.zip >> $GITHUB_OUTPUT
echo "Done"