Created
September 25, 2020 23:10
-
-
Save ifnull/33efb4eb0b6daab4504b08b34c96464a to your computer and use it in GitHub Desktop.
Continuous Integration for Unity with CircleCI - Sample Files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -e | |
set -x | |
echo "Building for $BUILD_TARGET" | |
export BUILD_PATH=./Builds/$CIRCLE_BRANCH/$CIRCLE_BUILD_NUM/$BUILD_TARGET/ | |
mkdir -p $BUILD_PATH | |
echo "Initialize manual license file..." | |
/opt/Unity/Editor/Unity \\ | |
-quit \\ | |
-batchmode \\ | |
-nographics \\ | |
-silent-crashes \\ | |
-manualLicenseFile $(pwd)/.circleci/unity3d.x.ulf || true # prevent script from exit | |
echo "Building Unity project..." | |
/opt/Unity/Editor/Unity \\ | |
-projectPath $(pwd) \\ | |
-quit \\ | |
-batchmode \\ | |
-nographics \\ | |
-buildTarget $BUILD_TARGET \\ | |
-customBuildTarget $BUILD_TARGET \\ | |
-customBuildName $BUILD_NAME$CIRCLE_BUILD_NUM-$CIRCLE_USERNAME \\ | |
-customBuildPath $BUILD_PATH \\ | |
-customBuildOptions AcceptExternalModificationsToPlayer \\ | |
-executeMethod BuildCommand.PerformBuild \\ | |
-logFile /dev/stdout | |
UNITY_EXIT_CODE=$? | |
if [ $UNITY_EXIT_CODE -eq 0 ]; then | |
echo "Run succeeded, no failures occurred"; | |
elif [ $UNITY_EXIT_CODE -eq 2 ]; then | |
echo "Run succeeded, some tests failed"; | |
elif [ $UNITY_EXIT_CODE -eq 3 ]; then | |
echo "Run failure (other failure)"; | |
else | |
echo "Unexpected exit code $UNITY_EXIT_CODE"; | |
fi | |
ls -la $BUILD_PATH | |
[ -n "$(ls -A $BUILD_PATH)" ] # fail job if build folder is empty | |
#!/usr/bin/env bash | |
set -e | |
docker run \\ | |
-e BUILD_NAME \\ | |
-e BUILD_TARGET \\ | |
-e UNITY_USERNAME \\ | |
-e UNITY_PASSWORD \\ | |
-w /project/ \\ | |
-v $(pwd):/project/ \\ | |
$IMAGE_NAME \\ | |
/bin/bash -c "/project/bin/build.sh" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment