From fe690ca3163b609aa0ff0604e5757acd2cf46b1a Mon Sep 17 00:00:00 2001
From: Louis Capitanchik <contact@louiscap.co>
Date: Fri, 15 Nov 2024 05:40:55 +0000
Subject: [PATCH] Install export templates alongside Godot

---
 Dockerfile                |  8 +++-----
 commands/godot_install.sh | 20 ++++++++++++++++----
 2 files changed, 19 insertions(+), 9 deletions(-)

diff --git a/Dockerfile b/Dockerfile
index 4b16366..e2018bd 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -4,8 +4,6 @@ ARG PLATFORM="linux.x86_64"
 ARG GODOT_VERSION="4.3-stable"
 ARG BUTLER_VERSION="15.12.0"
 
-ENV BUTLER_API_KEY=""
-
 RUN apt-get update \
     && apt-get install -y wget zip unzip libfontconfig1 \
     && rm -rf /var/lib/apt/lists/*
@@ -18,6 +16,6 @@ COPY commands/godot_project_title.sh /usr/bin/godot_project_title
 COPY commands/butler_install.sh /usr/bin/butler_install
 COPY commands/butler_upload.sh /usr/bin/butler_upload
 
-RUN chmod +x /usr/bin/godot_* /usr/bin/butler_* && \
-    godot_install $GODOT_VERSION $PLATFORM && cp ./godot /usr/bin/godot && \
-    butler_install $BUTLER_VERSION
\ No newline at end of file
+RUN chmod +x /usr/bin/godot_* /usr/bin/butler_*
+RUN godot_install $GODOT_VERSION $PLATFORM
+RUN butler_install $BUTLER_VERSION
\ No newline at end of file
diff --git a/commands/godot_install.sh b/commands/godot_install.sh
index dd08224..9bed3b9 100755
--- a/commands/godot_install.sh
+++ b/commands/godot_install.sh
@@ -3,13 +3,25 @@
 VERSION="$1"
 PLATFORM="$2"
 
-TMP_PATH="/tmp/godot"
-mkdir -p "$TMP_PATH"
+SAFE_VERSION=$(echo "$VERSION" | sed -nE 's/-/./p')
+
+TMP_ROOT="/tmp/godot"
+mkdir -p "$TMP_ROOT"
 
 BINARY_NAME="Godot_v${VERSION}_${PLATFORM}"
-TMP_PATH="$TMP_PATH/godot_${VERSION}_${PLATFORM}.zip"
+TMP_PATH="$TMP_ROOT/godot_${VERSION}_${PLATFORM}.zip"
+LOCAL_PATH="$HOME/.local/share/godot/export_templates/$SAFE_VERSION"
+
 ARTIFACT_PATH="https://github.com/godotengine/godot-builds/releases/download/${VERSION}/${BINARY_NAME}.zip"
+TEMPLATES_PATH="https://github.com/godotengine/godot/releases/download/${VERSION}/Godot_v${VERSION}_export_templates.tpz"
 
 wget -O "$TMP_PATH" "$ARTIFACT_PATH"
 unzip -o "$TMP_PATH" -d "$(pwd)"
-mv "$BINARY_NAME" godot
\ No newline at end of file
+mv "$BINARY_NAME" /usr/bin/godot
+
+mkdir -p "$LOCAL_PATH"
+wget -O "${TMP_ROOT}/templates.tpz" "$TEMPLATES_PATH"
+unzip -o "${TMP_ROOT}/templates.tpz" -d "${TMP_ROOT}/godot_templates"
+mv -r "${TMP_ROOT}/godot_templates/*" "$LOCAL_PATH/"
+
+rm -r "$TMP_ROOT"
\ No newline at end of file
-- 
GitLab