Android
Before 2018.4.8f1 for 2018 versions and before 2019.2.4f1 for 2019 versions, you will need a
specific Unity license (because that is not the same docker image). Add the content of your specific
Unity license in your CI's environment variable : UNITY_LICENSE_CONTENT_ANDROID. This is not
required anymore now that images share a base image
See related change
By default the apk is not signed and the build will use the Unity's default debug key. For security reasons, you should not add your keystore to git.
Encode your keystore
Encode your keystore file as base64 using openssl:
openssl base64 -A -in yourKeystore.keystore
Copy the result to your CI's environment variable ANDROID_KEYSTORE_BASE64
Add following environment variables:
KEYSTORE_PASS: Keystore passKEY_ALIAS_NAME: Keystore alias name to use (if not set, the program will use the alias name set in Project's PlayerSettings)KEY_ALIAS_PASS: Keystore alias pass to use
Note about keystore security, if you would like to use another solution for storage, see Where to Store Android KeyStore File in CI/CD Cycle?.
Android app bundle
BUILD_APP_BUNDLE env var is defined in gitlab-ci.yml. Set it to true to build an .aab file.
Note: to build an android app bundle, you need an image with Android NDK.
See related issue gableroux/unity3d#61
Bundle version code
The bundle version code must be increment for each deployed build.
To simplify the process, the BUNDLE_VERSION_CODE env var is used and set as bundle version code.
Currently, for gitlab, BUNDLE_VERSION_CODE = $CI_PIPELINE_IID.
Documentation
If you use another CI solution, set a CI env var incrementing for each pipeline.
Fastlane supply (deployement)
Follow setup instructions to get a google play
console token, then, add the content to env var GPC_TOKEN.
Uncomment the #deploy-android job in gitlab-ci.yml and replace com.youcompany.yourgame by your
package name.
You can change the track internal to alpha, beta or production (Note: if you are using the
internal track you will also have to mark your release as a draft in the fastlane supply command
using --release_status draft).
Gemfile
You will also need to add a Gemfile to your project to install the fastlane gem. Something like
the following:
source "https://rubygems.org"
gem "fastlane"
and then copy the file to the current directory prior to installing the gem. eg
cp $CI_PROJECT_DIR/Gemfile ..
That is the simplest way with command line but you can also make fastlane/Fastfile and
fastlane/Appfile, with the following command after building a temporary gradle project (export
gradle project option in Unity build settings):
fastlane init
Then run the following command:
fastlane supply init
and update all metadata, images, changelogs, etc... These will be uploaded to the store everytime. Refer to fastlane supply documentation for more details.