tools for exporting godot projects via Github Actions
Support godot-builds#49413e1 and godot4
adds a better version parser creates a new action for exports contains fallback code for 3.x issues created in development: closes https://github.com/bend-n/godot-template/issues/1 closes https://github.com/freeorion/freeorion/issues/4336 works around https://github.com/actions/setup-python/issues/556
bendn 2022-12-05
parent 0bf36a3 · commit 0d6ec3c
-rw-r--r--.github/actions/export-android/action.yml39
-rw-r--r--.github/actions/export-linux/action.yml32
-rw-r--r--.github/actions/export-mac/action.yml33
-rw-r--r--.github/actions/export-web/action.yml34
-rw-r--r--.github/actions/export-windows/action.yml35
-rw-r--r--.github/actions/export/action.yml56
-rw-r--r--.github/actions/get-export-name/action.yml4
-rwxr-xr-x.github/actions/get-export-name/get-export-name.py19
-rw-r--r--.github/actions/setup-godot/action.yml47
-rwxr-xr-x.github/actions/setup-godot/parse.py9
-rw-r--r--.github/workflows/callable-export.yml4
11 files changed, 144 insertions, 168 deletions
diff --git a/.github/actions/export-android/action.yml b/.github/actions/export-android/action.yml
index 2d491c6..d510dd6 100644
--- a/.github/actions/export-android/action.yml
+++ b/.github/actions/export-android/action.yml
@@ -16,12 +16,6 @@ runs:
- name: Setup
uses: bend-n/godot-actions/.github/actions/setup-godot@main
- - name: Get export name
- id: get-export-name
- uses: bend-n/godot-actions/.github/actions/get-export-name@main
- with:
- platform: Android
-
- name: Download android sdks
run: |
# Generate android keystore and settings
@@ -39,38 +33,19 @@ runs:
fi
shell: bash
- - name: Build (release)
+ - name: Prep build
if: inputs.android-keystore-base64
run: |
password="${{ inputs.android-password }}"
echo "::group::Build android (release)"
echo "${{ inputs.android-keystore-base64 }}" | base64 --decode > ~/release.keystore && echo "Decoded keystore"
- alias=$(keytool -storepass "$password" -list -v -keystore ~/release.keystore | grep -E '^Alias name:\s*(.+)$' | cut -d ' ' -f 3-) && echo "Got alias name"
+ alias=$(keytool -storepass "$password" -list -v -keystore ~/release.keystore | grep -E '^Alias name:\s*(.+)$' | cut -d ' ' -f 3-) && echo "Got alias name"
sed "s@keystore/release=\"\"@keystore/release=\"$HOME/release.keystore\"@g" -i export_presets.cfg && sed 's@keystore/release_user=".*"@keystore/release_user="'$alias'"@g' -i export_presets.cfg && sed 's@keystore/release_password=".*"@keystore/release_password="'$password'"@g' -i export_presets.cfg && echo "Configured export_presets.cfg"
- mkdir -p build/android
- godot -v --path "${{ env.PROJECT_PATH }}" --export "${{ steps.get-export-name.outputs.export-name }}" "$(realpath ./build/android/${{ env.NAME }}.apk)"
- echo "::endgroup::"
- shell: bash
-
- - name: Build (debug)
- if: ${{ !inputs.android-keystore-base64 }}
- run: |
- echo "::group::Build android (debug)"
- mkdir -p build/android || true
- godot -v --path "${{ env.PROJECT_PATH }}" --export-debug "${{ steps.get-export-name.outputs.export-name }}" "$(realpath ./build/android/${{ env.NAME }}.apk)"
- echo "::endgroup::"
- shell: bash
-
- - name: Add extra files
- run: |
- if [[ -f .github/post_export ]]; then
- chmod +x .github/post_export
- ./.github/post_export android
- fi
shell: bash
- - name: Upload
- uses: actions/upload-artifact@v3
+ - name: Build
+ uses: bend-n/godot-actions/.github/actions/export@main
with:
- name: android
- path: build/android
+ debug: ${{ inputs.android-keystore-base64 }}
+ extension: apk
+ platform: android
diff --git a/.github/actions/export-linux/action.yml b/.github/actions/export-linux/action.yml
index 3667c25..382e2df 100644
--- a/.github/actions/export-linux/action.yml
+++ b/.github/actions/export-linux/action.yml
@@ -4,32 +4,8 @@ description: Linux export
runs:
using: composite
steps:
- - name: Setup
- uses: bend-n/godot-actions/.github/actions/setup-godot@main
-
- - name: Get export name
- id: get-export-name
- uses: bend-n/godot-actions/.github/actions/get-export-name@main
- with:
- platform: Linux/X11
-
- - name: Linux Build
- run: |
- echo "::group::Linux Build"
- mkdir -vp build/linux
- godot -v --path "${{ env.PROJECT_PATH }}" --export "${{ steps.get-export-name.outputs.export-name }}" "$(realpath ./build/linux/${{ env.NAME }}.x86_64)"
- echo "::endgroup::"
- shell: bash
-
- - name: Add extra files
- run: |
- if [[ -f .github/post_export ]]; then
- chmod +x .github/post_export
- ./.github/post_export linux
- fi
- shell: bash
-
- - uses: actions/upload-artifact@v3
+ - name: Build
+ uses: bend-n/godot-actions/.github/actions/export@main
with:
- name: linux
- path: build/linux
+ extension: x86_64
+ platform: linux
diff --git a/.github/actions/export-mac/action.yml b/.github/actions/export-mac/action.yml
index 99401c3..9a702ac 100644
--- a/.github/actions/export-mac/action.yml
+++ b/.github/actions/export-mac/action.yml
@@ -4,33 +4,8 @@ description: Mac export
runs:
using: composite
steps:
- - name: Setup
- uses: bend-n/godot-actions/.github/actions/setup-godot@main
-
- - name: Get export name
- id: get-export-name
- uses: bend-n/godot-actions/.github/actions/get-export-name@main
- with:
- platform: "Mac OSX"
-
- - name: Mac Build
- run: |
- echo "::group::Mac Build"
- mkdir -vp build/mac
- godot -v --path "${{ env.PROJECT_PATH }}" --export "${{ steps.get-export-name.outputs.export-name }}" "$(realpath ./build/mac/${{ env.NAME }}.zip)"
- echo "::endgroup::"
- shell: bash
-
- - name: Add extra files
- run: |
- if [[ -f .github/post_export ]]; then
- chmod +x .github/post_export
- ./.github/post_export mac
- fi
- shell: bash
-
- - name: Upload
- uses: actions/upload-artifact@v3
+ - name: Build
+ uses: bend-n/godot-actions/.github/actions/export@main
with:
- name: mac
- path: build/mac
+ extension: app
+ platform: mac
diff --git a/.github/actions/export-web/action.yml b/.github/actions/export-web/action.yml
index 6478342..67ef917 100644
--- a/.github/actions/export-web/action.yml
+++ b/.github/actions/export-web/action.yml
@@ -18,36 +18,12 @@ inputs:
runs:
using: composite
steps:
- - name: Setup
- uses: bend-n/godot-actions/.github/actions/setup-godot@main
-
- - name: Get export name
- id: get-export-name
- uses: bend-n/godot-actions/.github/actions/get-export-name@main
- with:
- platform: HTML5
-
- - name: Web Build
- run: |
- echo "::group::Web Build"
- mkdir -vp build/web
- godot -v --path "${{ env.PROJECT_PATH }}" --export "${{ steps.get-export-name.outputs.export-name }}" "$(realpath ./build/web/index.html)"
- echo "::endgroup::"
- shell: bash
-
- - name: Add extra files
- run: |
- if [[ -f .github/post_export ]]; then
- chmod +x .github/post_export
- ./.github/post_export web
- fi
- shell: bash
-
- - name: Upload
- uses: actions/upload-artifact@v3
+ - name: Build
+ uses: bend-n/godot-actions/.github/actions/export@main
with:
- name: web
- path: build/web
+ name: index
+ extension: html
+ platform: web
- name: Test git repo
id: is-repo
diff --git a/.github/actions/export-windows/action.yml b/.github/actions/export-windows/action.yml
index 8342ab4..95aec58 100644
--- a/.github/actions/export-windows/action.yml
+++ b/.github/actions/export-windows/action.yml
@@ -4,35 +4,8 @@ description: "Windows export"
runs:
using: "composite"
steps:
- - name: Setup
- uses: bend-n/godot-actions/.github/actions/setup-godot@main
-
- - name: Get export name
- id: get-export-name
- uses: bend-n/godot-actions/.github/actions/get-export-name@main
- with:
- platform: "Windows Desktop"
-
- - name: Windows Build
- run: |
- echo "::group::Windows Build"
- export WINEPREFIX="$HOME/wineprefix"
- mkdir "$WINEPREFIX" && chown -R "${USER}:" "$WINEPREFIX"
- mkdir -p build/windows
- godot -v --path "${{ env.PROJECT_PATH }}" --export "${{ steps.get-export-name.outputs.export-name }}" "$(realpath ./build/windows/${{ env.NAME }}.exe)"
- echo "::endgroup::"
- shell: bash
-
- - name: Add extra files
- run: |
- if [[ -f .github/post_export ]]; then
- chmod +x .github/post_export
- ./.github/post_export windows
- fi
- shell: bash
-
- - name: Upload
- uses: actions/upload-artifact@v3
+ - name: Build
+ uses: bend-n/godot-actions/.github/actions/export@main
with:
- name: windows
- path: build/windows
+ extension: exe
+ platform: windows
diff --git a/.github/actions/export/action.yml b/.github/actions/export/action.yml
new file mode 100644
index 0000000..4c3bd67
--- /dev/null
+++ b/.github/actions/export/action.yml
@@ -0,0 +1,56 @@
+name: Export
+description: exports
+
+inputs:
+ platform:
+ description: The platform (web, linux, mac, android)
+ required: true
+ extension:
+ description: File extension (x86_64, exe, etc)
+ required: true
+ debug:
+ description: Debug build or no (non empty string = true)
+ required: false
+ default: ""
+ name:
+ description: The name ($name.exe) # defaults to $NAME
+ required: false
+
+runs:
+ using: composite
+ steps:
+ - name: Setup
+ uses: bend-n/godot-actions/.github/actions/setup-godot@main
+
+ - name: Get export name
+ id: n
+ uses: bend-n/godot-actions/.github/actions/get-export-name@main
+ with:
+ platform: ${{ inputs.platform }}
+
+ - name: Build
+ run: |
+ p="${{ inputs.platform }}"
+ echo "::group::${p^} Build"
+ export="--export"
+ [[ ${GODOT_VERSION:0:1} -gt 3 ]] && export="--export-release"
+ [[ -n $debug ]] && export="--export-debug"
+ mkdir -vp build/${{ inputs.platform }}
+ n="$NAME"
+ [[ -z "${{ inputs.name}}" ]] && n="${{ inputs.name }}"
+ godot -v --headless --path "${{ env.PROJECT_PATH }}" "$export" "${{ steps.n.outputs.export-name }}" "./build/${{ inputs.platform }}/$n.${{ inputs.extension }}"
+ echo "::endgroup::"
+
+ if [[ -f .github/post_export ]]; then
+ echo "::group::Run post export script"
+ chmod +x .github/post_export
+ ./.github/post_export ${{ inputs.platform }}
+ echo "::endgroup::"
+ fi
+ shell: bash
+
+ - uses: actions/upload-artifact@v3
+ with:
+ name: ${{ inputs.platform }}
+ path: build/${{ inputs.platform}}
+ if-no-files-found: error
diff --git a/.github/actions/get-export-name/action.yml b/.github/actions/get-export-name/action.yml
index 5b6972b..c3b413a 100644
--- a/.github/actions/get-export-name/action.yml
+++ b/.github/actions/get-export-name/action.yml
@@ -19,9 +19,9 @@ runs:
run: |
cd "${{ env.PROJECT_PATH }}"
wget -nv 'https://raw.githubusercontent.com/bend-n/godot-actions/main/.github/actions/get-export-name/get-export-name.py' -O get-export-name.py
- python get-export-name.py "${{ inputs.platform }}" || (
+ python get-export-name.py "${GODOT_VERSION:0:1}" "${{ inputs.platform }}" || (
echo "::error file=${PROJECT_PATH}/export_presets.cfg,title=Missing Configuration::No export for ${{ inputs.platform }}."
exit 1
)
- echo "export-name=$(python get-export-name.py "${{ inputs.platform }}")" >> "$GITHUB_OUTPUT"
+ echo "export-name=$(python get-export-name.py "${GODOT_VERSION:0:1}" "${{ inputs.platform }}")" >> "$GITHUB_OUTPUT"
shell: bash
diff --git a/.github/actions/get-export-name/get-export-name.py b/.github/actions/get-export-name/get-export-name.py
index 7e9be8b..1908eca 100755
--- a/.github/actions/get-export-name/get-export-name.py
+++ b/.github/actions/get-export-name/get-export-name.py
@@ -3,7 +3,24 @@
import re
import sys
-platform = f'"{sys.argv[1]}"'
+map = {
+ 3: {
+ "android": "Android",
+ "linux": "Linux/X11",
+ "mac": "Mac OSX",
+ "web": "HTML5",
+ "windows": "Windows Desktop",
+ },
+ 4: {
+ "android": "Android",
+ "linux": "Linux/X11",
+ "mac": "macOS",
+ "web": "Web",
+ "windows": "Windows Desktop",
+ }
+}
+
+platform = f'"{map[int(sys.argv[1])][sys.argv[2]]}"'
with open('export_presets.cfg', "r") as f:
export_presets = f.read()
diff --git a/.github/actions/setup-godot/action.yml b/.github/actions/setup-godot/action.yml
index 6726604..b5902e3 100644
--- a/.github/actions/setup-godot/action.yml
+++ b/.github/actions/setup-godot/action.yml
@@ -20,40 +20,59 @@ runs:
submodules: recursive
- name: Setup python
+ if: steps.clean.outputs.clean == 'true'
uses: actions/setup-python@v4
with:
python-version: "3.9"
+ cache: pip
- name: Setup godot
+ if: steps.clean.outputs.clean == 'true'
run: |
+ echo "::group::Pip install"
+ python -m pip install packaging
+ echo "::endgroup::"
echo "::group::Setup godot"
+ wget -q 'https://raw.githubusercontent.com/bend-n/godot-actions/main/.github/actions/setup-godot/parse.py' -O pv.py
# config
mkdir -p ~/.config/godot/
mv /root/.config/godot/editor_settings-3.tres ~/.config/godot/editor_settings-3.tres
- if [[ -z $PROJECT_PATH ]]; then
- cd "$PROJECT_PATH"
- echo "PROJECT_PATH=." >> $GITHUB_ENV
- fi
+ [[ -z $PROJECT_PATH ]] && echo "PROJECT_PATH=." >>$GITHUB_ENV
+ cd "$PROJECT_PATH" || true
# create version label thing
- git config --global --add safe.directory "$(pwd)" && printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)" > version
+ git config --global --add safe.directory "$(pwd)" && printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)" >version
# templates
- [[ -z $RELEASE ]] && RELEASE=stable
- TEMPLATES_PATH=".local/share/godot/templates/${GODOT_VERSION}.${RELEASE}"
- mkdir -p "${HOME}/${TEMPLATES_PATH}"
- mv "/root/${TEMPLATES_PATH}/"* "${HOME}/${TEMPLATES_PATH}"
- ls "${HOME}/${TEMPLATES_PATH}"| tr '\n' ' '
+ TEMPS_DIRNAME="templates"
+ [[ ${GODOT_VERSION:0:1} -gt 3 ]] && TEMPS_DIRNAME="export_templates"
+ VERSION="$(python pv.py "$GODOT_VERSION")"
+ TEMPLATES_PATH=".local/share/godot/$TEMPS_DIRNAME/$VERSION"
+ echo "Putting export templates in $TEMPLATES_PATH."
+ mkdir -p "$HOME/$TEMPLATES_PATH"
+ if [[ -f /root/templates.tpz ]]; then # brand new container
+ mkdir -p ~/.cache
+ unzip -q /root/templates.tpz -d "$HOME/$TEMPLATES_PATH"
+ else # fallback to the old container method
+ mv "/root/$TEMPLATES_PATH/"* "$HOME/$TEMPLATES_PATH"
+ fi
+ echo -e "Installed templates: $(ls "$HOME/$TEMPLATES_PATH" | tr '\n' ' ')\n"
# gpm
if [[ -f godot.package ]]; then
+ echo "Installing addons via the GPM"
+ if [[ ${GODOT_VERSION:0:1} -gt 3 ]]; then
+ wget -q "https://github.com/bend-n/godot-builds/releases/download/3.5/godot-2d_v3.5_linux_headless.64" -O /usr/local/bin/godot3
+ chmod +x /usr/local/bin/godot3
+ else
+ ln -s /usr/local/bin/godot /usr/local/bin/godot3
+ fi
[[ ! -d addons ]] && mkdir addons
- git clone --depth 1 https://github.com/you-win/godot-package-manager
+ git clone -q --depth 1 https://github.com/you-win/godot-package-manager
mv godot-package-manager/addons/godot-package-manager addons/
- rm -rf godot-package-manager
- godot -s addons/godot-package-manager/cli.gd update
- rm -rf addons/godot-package-manager
+ godot3 -s addons/godot-package-manager/cli.gd update || true
+ rm -rf addons/godot-package-manager godot-package-manager
fi
echo "::endgroup::"
shell: bash
diff --git a/.github/actions/setup-godot/parse.py b/.github/actions/setup-godot/parse.py
new file mode 100755
index 0000000..45874dc
--- /dev/null
+++ b/.github/actions/setup-godot/parse.py
@@ -0,0 +1,9 @@
+#!/usr/bin/env python3
+
+from packaging.version import parse
+from sys import argv
+
+parsed = parse(argv[1])
+release = argv[1].replace(
+ parsed.base_version, '').strip('.')
+print(f"{parsed.base_version}.{release if release else 'stable'}")
diff --git a/.github/workflows/callable-export.yml b/.github/workflows/callable-export.yml
index 982a47a..606c208 100644
--- a/.github/workflows/callable-export.yml
+++ b/.github/workflows/callable-export.yml
@@ -6,12 +6,12 @@ on:
description: the godot version
default: 3.5
required: true
- type: number
+ type: string
image:
description: the container to use
default: ghcr.io/bend-n/godot-2d:3.5
- type: string
required: true
+ type: string
export-name:
description: the name of the exec. ($export-name.exe)
default: ${{ github.event.repository.name }}