godot 4.3 project does not include keystore/... lines in export_presets.cfg, breaking example android export
Opened this issue · 5 comments
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
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
I now understand why these lines are missing:
this sensitive data has been moved to .godot/export_credentials.cfg in some godot update (4.1?)
Not sure if there is a way to generate this file. godot --headless --verbose --import
did not generate this file unfortunately. So the sed
command cannot just be pointed to this file instead.
Edit: you can generate this file and build your Android project with Github Actions with the following workflow:
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
- name: generate export credentials
run: |
echo "generating export_credentials file"
mkdir .godot
echo ${{ secrets.SECRET_RELEASE_KEYSTORE_BASE64 }} | base64 --decode > /root/release.keystore
for num in $(grep -B3 'platform="Android"' export_presets.cfg | grep 'preset\.' | cut -d'.' -f2 | tr -d '[]'); do
echo "generating for preset number: $num"
echo "[preset.$num]" >> .godot/export_credentials.cfg
echo "[preset.$num.options]" >> .godot/export_credentials.cfg
echo "keystore/release=\"/root/release.keystore\"" >> .godot/export_credentials.cfg
echo "keystore/release_user=\"${{ secrets.SECRET_RELEASE_KEYSTORE_USER }}\"" >> .godot/export_credentials.cfg
echo "keystore/release_password=\"${{ secrets.SECRET_RELEASE_KEYSTORE_PASSWORD }}\"" >> .godot/export_credentials.cfg
done
echo "generated export credentials:"
cat .godot/export_credentials.cfg
- name: Android Build
run: |
mkdir -v -p build/android
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
maybe something like this could be added to the included example file?
I switched from using the export config to using environment variables for android.
so in my gitlab ci yml, im doing the following
android:
stage: export
rules:
- if: $SECRET_RELEASE_KEYSTORE_USER
- if: $SECRET_RELEASE_KEYSTORE_PASSWORD
script:
- echo $SECRET_RELEASE_KEYSTORE_BASE64 | base64 --decode > /root/release.keystore
- export GODOT_ANDROID_KEYSTORE_RELEASE_PATH=/root/release.keystore
- export GODOT_ANDROID_KEYSTORE_RELEASE_USER=$SECRET_RELEASE_KEYSTORE_USER
- export GODOT_ANDROID_KEYSTORE_RELEASE_PASSWORD=$SECRET_RELEASE_KEYSTORE_PASSWORD
- sed 's@version/code=".*"@version/code='$CI_PIPELINE_IID'@g' -i export_presets.cfg
- sed 's@version/name=".*"@version/name="'$CI_COMMIT_SHORT_SHA'"@g' -i export_presets.cfg
- godot --headless --verbose --export-release "Android" ./build/android/$EXPORT_NAME.apk
artifacts:
name: $EXPORT_NAME-$CI_JOB_NAME
paths:
- build/android
tags:
- godot
i'm having a different issue where it says theres a configuration error, but doesnt print what the error is. I don't think its related to the keystore, because i get the same error whether or not I use the old method or this one.
I switched from using the export config to using environment variables for android.
... wow. I totally missed that those exist, that seems way easier.
i'm having a different issue where it says theres a configuration error, but doesnt print what the error is. I don't think its related to the keystore, because i get the same error whether or not I use the old method or this one.
have you tried removing those sed
lines and printing out your config with cat export_presets.cfg
to see what the file contains?
Oh, I managed to fix it. I don't fully understand sed, so my edits most likely were putting quotes around something that didn't need them.