aboutsummaryrefslogtreecommitdiff
path: root/.github/actions/openvic-env/url-environment.sh
diff options
context:
space:
mode:
author Spartan322 <Megacake1234@gmail.com>2023-07-17 21:39:41 +0200
committer Spartan322 <Megacake1234@gmail.com>2023-07-20 00:53:44 +0200
commit8a8be87279db46c5d50aedcb51b0ef2371c3484d (patch)
treeb81dd4bf0d661bb47e4f9c8219d2f0a547e546f2 /.github/actions/openvic-env/url-environment.sh
parent1cb52daa06968aef519b66402ba6a3f4005000ee (diff)
Update to Godot 4.1.1 Stable Release
Add bash-based Godot URL environment variable handling to openvic-env action Sets GODOT_LINUX_URL and GODOT_TEMPLATE_URL according to GODOT_BASE_URL, GODOT_VERSION, and GODOT_VERSION_TYPE Handles downloads.tuxfamily.org/godotengine and github.com/godotengine differently Errors if GODOT_LINUX_URL or GODOT_TEMPLATE_URL are not set or if links do not exist Will not override GODOT_LINUX_URL if previously set Will not override GODOT_TEMPLATE_URL if previously set
Diffstat (limited to '.github/actions/openvic-env/url-environment.sh')
-rwxr-xr-x.github/actions/openvic-env/url-environment.sh57
1 files changed, 57 insertions, 0 deletions
diff --git a/.github/actions/openvic-env/url-environment.sh b/.github/actions/openvic-env/url-environment.sh
new file mode 100755
index 0000000..352218b
--- /dev/null
+++ b/.github/actions/openvic-env/url-environment.sh
@@ -0,0 +1,57 @@
+#!/bin/bash
+
+# $1 = environment name
+# $2 = value to set environment
+set_var() {
+ if [[ -z ${!1+set} ]]; then
+ export $1=$2
+ fi
+}
+
+# $1 = left side
+# $2 = right side
+# returns $1 and $2 joined together with a single '/''
+join_path() {
+ result=$1
+ if [[ $result == *"/" && $2 == "/"* ]]; then
+ result=${result%/}
+ fi
+ if [[ $result != *"/" && $2 != "/"* ]]; then
+ result="$result/"
+ fi
+ echo "$result$2"
+}
+
+# $1 = environment name
+set_github_var() {
+ if [ "${!1}" == "" ]; then
+ echo "::error::$1 environment variable has not been set."
+ elif ! curl -o /dev/null --head --silent --fail "${!1}"; then
+ echo "::error::${!1} does not exist."
+ else
+ echo "$1=${!1}" >> $GITHUB_ENV
+ fi
+}
+
+if [[ $GODOT_BASE_DOWNLOAD_URL == *"downloads.tuxfamily.org/godotengine"* ]]; then
+ if [[ $GODOT_BASE_DOWNLOAD_URL != *"${GODOT_VERSION}"* ]]; then
+ GODOT_BASE_DOWNLOAD_URL="$(join_path ${GODOT_BASE_DOWNLOAD_URL} ${GODOT_VERSION})"
+ fi
+ if [[ $GODOT_VERSION_TYPE != "stable" ]]; then
+ GODOT_BASE_DOWNLOAD_URL="$(join_path ${GODOT_BASE_DOWNLOAD_URL} ${GODOT_VERSION_TYPE})"
+ fi
+ set_var GODOT_LINUX_URL "$(join_path ${GODOT_BASE_DOWNLOAD_URL} "Godot_v${GODOT_VERSION}-${GODOT_VERSION_TYPE}_linux.x86_64.zip")"
+ set_var GODOT_TEMPLATE_URL "$(join_path ${GODOT_BASE_DOWNLOAD_URL} "Godot_v${GODOT_VERSION}-${GODOT_VERSION_TYPE}_export_templates.tpz")"
+elif [[ $GODOT_BASE_DOWNLOAD_URL == *"github.com/godotengine"* ]]; then
+ if [[ $GODOT_BASE_DOWNLOAD_URL != *"/releases"* ]]; then
+ GODOT_BASE_DOWNLOAD_URL=$(join_path $GODOT_BASE_DOWNLOAD_URL "releases")
+ fi
+ if [[ $GODOT_BASE_DOWNLOAD_URL != *"/download"* ]]; then
+ GODOT_BASE_DOWNLOAD_URL=$(join_path $GODOT_BASE_DOWNLOAD_URL "download")
+ fi
+ set_var GODOT_LINUX_URL "$(join_path ${GODOT_BASE_DOWNLOAD_URL} "${GODOT_VERSION}-${GODOT_VERSION_TYPE}/Godot_v${GODOT_VERSION}-${GODOT_VERSION_TYPE}_linux.x86_64.zip")"
+ set_var GODOT_TEMPLATE_URL "$(join_path ${GODOT_BASE_DOWNLOAD_URL} "${GODOT_VERSION}-${GODOT_VERSION_TYPE}/Godot_v${GODOT_VERSION}-${GODOT_VERSION_TYPE}_export_templates.tpz")"
+fi
+
+set_github_var GODOT_LINUX_URL
+set_github_var GODOT_TEMPLATE_URL \ No newline at end of file