tools for exporting godot projects via Github Actions
| -rw-r--r-- | .github/actions/export-android/action.yml | 18 | ||||
| -rw-r--r-- | .github/actions/export-linux/action.yml | 10 | ||||
| -rw-r--r-- | .github/actions/export-mac/action.yml | 10 | ||||
| -rw-r--r-- | .github/actions/export-web/action.yml | 14 | ||||
| -rw-r--r-- | .github/actions/export-windows/action.yml | 10 | ||||
| -rw-r--r-- | .github/actions/get-export-name/action.yml | 23 | ||||
| -rwxr-xr-x | .github/actions/get-export-name/get-export-name.py | 16 | ||||
| -rw-r--r-- | .github/actions/setup-godot/action.yml | 15 | ||||
| -rw-r--r-- | .gitignore | 1 |
9 files changed, 100 insertions, 17 deletions
diff --git a/.github/actions/export-android/action.yml b/.github/actions/export-android/action.yml index 9337fc4..a5b31ef 100644 --- a/.github/actions/export-android/action.yml +++ b/.github/actions/export-android/action.yml @@ -16,7 +16,14 @@ 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 + if: steps.get-export-name.outputs.export-name run: | # Generate android keystore and settings export ANDROID_HOME="/usr/lib/android-sdk" @@ -34,35 +41,36 @@ runs: shell: bash - name: Setup editor settings + if: steps.get-export-name.outputs.export-name run: | mkdir -p ~/.config/godot/ mv /root/.config/godot/editor_settings-3.tres ~/.config/godot/editor_settings-3.tres shell: bash - name: Build (release) - if: ${{ inputs.android-keystore-base64 }} + if: inputs.android-keystore-base64 && steps.get-export-name.outputs.export-name 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" - echo "Configuring with $alias, $password" 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 --export "Android" ./build/android/$NAME.apk + godot -v --export "${{steps.get-export-name.outputs.export-name}}" ./build/android/$NAME.apk echo "::endgroup::" shell: bash - name: Build (debug) - if: ${{ inputs.android-keystore-base64 }} == "" + if: ${{ ! inputs.android-keystore-base64 && steps.get-export-name.outputs.export-name }} run: | echo "::group::Build android (debug)" mkdir -p build/android || true - godot -v --export-debug "Android" ./build/android/$NAME.apk + godot -v --export-debug "${{steps.get-export-name.outputs.export-name}}" ./build/android/$NAME.apk echo "::endgroup::" shell: bash - name: Upload + if: steps.get-export-name.outputs.export-name uses: actions/upload-artifact@v1 with: name: android diff --git a/.github/actions/export-linux/action.yml b/.github/actions/export-linux/action.yml index cfb5dc2..87ac8dd 100644 --- a/.github/actions/export-linux/action.yml +++ b/.github/actions/export-linux/action.yml @@ -7,15 +7,23 @@ 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: Linux/X11 + - name: Linux Build + if: steps.get-export-name.outputs.export-name run: | echo "::group::Linux Build" mkdir -vp build/linux - godot -v --export "Linux" ./build/linux/$NAME.x86_64 + godot -v --export "${{ steps.get-export-name.outputs.export-name }}" ./build/linux/$NAME.x86_64 echo "::endgroup::" shell: bash - uses: actions/upload-artifact@v1 + if: steps.get-export-name.outputs.export-name with: name: linux path: build/linux diff --git a/.github/actions/export-mac/action.yml b/.github/actions/export-mac/action.yml index 1513a86..a6d9be7 100644 --- a/.github/actions/export-mac/action.yml +++ b/.github/actions/export-mac/action.yml @@ -7,15 +7,23 @@ 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: "Mac OSX" + - name: Mac Build + if: steps.get-export-name.outputs.export-name run: | echo "::group::Mac Build" mkdir -vp build/mac - godot -v --export "Mac" ./build/mac/$NAME.zip + godot -v --export "${{ steps.get-export-name.outputs.export-name }}" ./build/mac/$NAME.zip echo "::endgroup::" shell: bash - name: Upload + if: steps.get-export-name.outputs.export-name uses: actions/upload-artifact@v1 with: name: mac diff --git a/.github/actions/export-web/action.yml b/.github/actions/export-web/action.yml index d8c6851..f1f52a2 100644 --- a/.github/actions/export-web/action.yml +++ b/.github/actions/export-web/action.yml @@ -17,27 +17,36 @@ 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: HTML5 + - name: Web Build + if: steps.get-export-name.outputs.export-name run: | echo "::group::Web Build" mkdir -vp build/web - godot -v --export "HTML" ./build/web/index.html + godot -v --export "${{ steps.get-export-name.outputs.export-name }}" ./build/web/index.html echo "::endgroup::" shell: bash - name: Upload + if: steps.get-export-name.outputs.export-name uses: actions/upload-artifact@v1 with: name: web path: build/web - name: Test git repo + if: steps.get-export-name.outputs.export-name id: is-repo run: "echo ::set-output name=is-repo::$(git rev-parse --is-inside-work-tree || echo false)" shell: bash - name: Deploy - if: steps.is-repo.outputs.is-repo == 'true' + if: steps.is-repo.outputs.is-repo == 'true' && steps.get-export-name.outputs.export-name uses: JamesIves/github-pages-deploy-action@releases/v4 with: branch: gh-pages @@ -45,3 +54,4 @@ runs: git-config-name: ${{ inputs.git-name }} git-config-email: ${{ inputs.git-email }} single-commit: true + silent: true diff --git a/.github/actions/export-windows/action.yml b/.github/actions/export-windows/action.yml index c12d77a..20d050f 100644 --- a/.github/actions/export-windows/action.yml +++ b/.github/actions/export-windows/action.yml @@ -7,15 +7,23 @@ 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: "Windows Desktop" + - name: Windows Build + if: steps.get-export-name.outputs.export-name run: | echo "::group::Windows Build" mkdir -p build/windows - godot -v --export "Windows" ./build/windows/$NAME.exe + godot -v --export "${{ steps.get-export-name.outputs.export-name }}" ./build/windows/$NAME.exe echo "::endgroup::" shell: bash - name: Upload + if: steps.get-export-name.outputs.export-name uses: actions/upload-artifact@v1 with: name: windows diff --git a/.github/actions/get-export-name/action.yml b/.github/actions/get-export-name/action.yml new file mode 100644 index 0000000..1506643 --- /dev/null +++ b/.github/actions/get-export-name/action.yml @@ -0,0 +1,23 @@ +name: "Get the export name for a platform" +description: "Get the export name for a platform, from the export_presets.cfg" + +inputs: + platform: + description: "The platform to get the export name for" + required: true + +outputs: + export-name: + value: ${{ steps.get-export-name.outputs.export-name }} + description: "The export name for the platform" + +runs: + using: "composite" + steps: + - name: Get export name + id: get-export-name + run: | + 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 }}" || echo "::notice file=export_presets.cfg,title=Missing Configuration::No export for ${{ inputs.platform }}." + echo "::set-output name=export-name::$(python get-export-name.py "${{ inputs.platform }}")" + shell: bash diff --git a/.github/actions/get-export-name/get-export-name.py b/.github/actions/get-export-name/get-export-name.py new file mode 100755 index 0000000..7e9be8b --- /dev/null +++ b/.github/actions/get-export-name/get-export-name.py @@ -0,0 +1,16 @@ +#!/usr/bin/env python3 + +import re +import sys + +platform = f'"{sys.argv[1]}"' + +with open('export_presets.cfg', "r") as f: + export_presets = f.read() + regex = r'\[preset.[0-9]\]\n+name="([A-Za-z0-9]+)"\n+platform=' + platform + matches = re.search( + regex, export_presets) + if matches: + print(matches.groups()[0]) + else: + sys.exit(1) diff --git a/.github/actions/setup-godot/action.yml b/.github/actions/setup-godot/action.yml index 4264db4..37f92a2 100644 --- a/.github/actions/setup-godot/action.yml +++ b/.github/actions/setup-godot/action.yml @@ -7,11 +7,8 @@ runs: - name: Check if clean id: clean run: | - if [[ -z $(find . -mindepth 1 -maxdepth 1) ]]; then - echo "::set-output name=clean::true" && echo "clean" - else - echo "::set-output name=clean::false" && echo "dirty" - fi + if [[ -z $(find . -mindepth 1 -maxdepth 1) ]]; then echo "::set-output name=clean::true"; + else echo "::set-output name=clean::false"; fi shell: bash - name: Checkout @@ -21,7 +18,13 @@ runs: fetch-depth: 0 lfs: true submodules: recursive - - name: Setup + + - name: Setup python + uses: actions/setup-python@v4 + with: + python-version: "3.9" + + - name: Setup godot run: | echo "::group::Setup godot" git config --global --add safe.directory $(pwd) @@ -1,7 +1,6 @@ .import/ logs/ *.sh -*.py *.pgn .vscode/ exports/ |