abarichello / godot-ci

Docker image to export Godot Engine games. Templates for Gitlab CI and GitHub Actions to deploy to GitLab Pages/GitHub Pages/Itch.io.
https://hub.docker.com/r/barichello/godot-ci
MIT License
741 stars 132 forks source link

godot 4.3 project does not include keystore/... lines in export_presets.cfg, breaking example android export #161

Open ThunderFD opened 10 hours ago

ThunderFD commented 10 hours ago

the example gitlab-ci.yml file expects keystore/... lines to exist in the export_presets.cfg, but they do not in a new godot 4.3 project

gitlab-ci.yml lines in question:

    - sed 's@keystore/release=".*"@keystore/release="'/root/release.keystore'"@g' -i export_presets.cfg
    - sed 's@keystore/release_user=".*"@keystore/release_user="'$SECRET_RELEASE_KEYSTORE_USER'"@g' -i export_presets.cfg
    - sed 's@keystore/release_password=".*"@keystore/release_password="'$SECRET_RELEASE_KEYSTORE_PASSWORD'"@g' -i export_presets.cfg
    - godot --headless --verbose --export-release "Android" 

I ported this to github actions and it works fine if I append the following to my android release in my export_presets.cfg:

keystore/release=""
keystore/release_user=""
keystore/release_password=""

but this gets overwritten anytime I change something about my export presets from godot, so these lines go missing again, breaking the android export. What would be the best way to add these lines to the file if they are missing?

my export job for android for github actions looks something like this:

name: "godot-ci export"
on: push

env:
  GODOT_VERSION: 4.3
  EXPORT_NAME: export-name

jobs:
  export-android:
    name: Android Export
    runs-on: ubuntu-20.04
    container:
      image: barichello/godot-ci:4.3
    steps:
      - name: Checkout
        uses: actions/checkout@v4
        with:
          lfs: true
      - name: Setup
        run: |
          mkdir -v -p ~/.local/share/godot/export_templates/
          mkdir -v -p ~/.config/
          mv /root/.config/godot ~/.config/godot
          mv /root/.local/share/godot/export_templates/${GODOT_VERSION}.stable ~/.local/share/godot/export_templates/${GODOT_VERSION}.stable
          echo "the following line is a fix for the current docker file and will be fixed by PR 158"
          echo 'export/android/java_sdk_path = "/usr/lib/jvm/java-17-openjdk-amd64"' >> ~/.config/godot/editor_settings-4.3.tres
      - name: Android Build
        env:
          SECRET_RELEASE_KEYSTORE_BASE64: ${{ secrets.SECRET_RELEASE_KEYSTORE_BASE64 }}
          SECRET_RELEASE_KEYSTORE_USER: ${{ secrets.SECRET_RELEASE_KEYSTORE_USER }}
          SECRET_RELEASE_KEYSTORE_PASSWORD: ${{ secrets.SECRET_RELEASE_KEYSTORE_PASSWORD }}
        run: |
          mkdir -v -p build/android
          echo $SECRET_RELEASE_KEYSTORE_BASE64 | base64 --decode > /root/release.keystore
          sed -i 's|keystore/release=".*"|keystore/release="'/root/release.keystore'"|g' export_presets.cfg
          sed -i 's|keystore/release_user=".*"|keystore/release_user="'$SECRET_RELEASE_KEYSTORE_USER'"|g' export_presets.cfg
          sed -i 's|keystore/release_password=".*"|keystore/release_password="'$SECRET_RELEASE_KEYSTORE_PASSWORD'"|g' export_presets.cfg
          cat export_presets.cfg
          godot --headless --verbose --export-release "Android" "build/android/$EXPORT_NAME.apk"
      - name: Upload Artifact
        uses: actions/upload-artifact@v4
        with:
          name: android
          path: build/android
ThunderFD commented 10 hours ago

adding the following to the setup stage "fixes the issue", but is very hacky. The android export preset must be the last one in the file for this to work

echo 'keystore/release=""' >> export_presets.cfg
echo 'keystore/release_user=""' >> export_presets.cfg
echo 'keystore/release_password=""' >> export_presets.cfg