This set of scripts can be used in CI systems (like Gitlab CI) to automatically build unity android projects and store the resulting APKs.
- Copy
buildwindows.bat
to your project root folder - Copy
buildproject.cs
toAssets/_scritps/Editor
(create the folder if necessary) - Define the following environment variables (gitlab project settings -> variables):
ANDROID_KEYSTORE_NAME
: Filename of the key store. For exampleyourcompany.keystore
ANDROID_KEYSTORE_PASSWORD
: Password for the key storeANDROID_KEYALIAS_NAME
: Name of the key alias used to sign the applicationANDROID_KEYALIAS_PASSWORD
: Password for the key aliasANDROID_SDK_ROOT
: Path to the android SDK on the build hostAPK_OUTPUT_DIR
: path where the APK should be saved, for examplebuild\android
(this will be generated relative to the project root on the ci runner)APK_OUTPUT_FILE
: name of the APK to be generated, for examplemyproject.apk
UNITY_EXE_PATH
: full path to Unity.exe on the build host, for exampleC:\Program Files\Unity\Editor\Unity.exe
- Create your CI configuration (
.gitlab-ci.yml
) like this example:
stages:
- compile
compile:
stage: compile
script: buildwindows.bat
artifacts:
paths:
- build/android/myproject.apk
- build.log
expire_in: 7 days
when: always
tags:
- windows-unity