unity-builder/dist/platforms/ubuntu/steps/build.sh
AndrewKahr 3d0eb0805b
Initial Support for Windows Based Builds (#305)
* Implemented logic for windows based docker builds. Moved dockerfiles and scripts to platform specific folders.

* Add missing newline character

* Add build-tests for windows and a unity project configured to output il2cpp

* Add additional build targets (uwp and tvOS)
Adjustments to build scripts to not require win10 sdk when not needed (tvOS)
Platform-based prereq setup
Setup image tags for the new platforms with errors if building on the wrong base os
Rename test-project-il2cpp to test-project-windows to be used for all windows based project building (IL2CPP backend selected instead of mono)
Fix tests to be platform based

* Update dist/platforms/windows/steps/return_license.ps1

Co-authored-by: Webber Takken <webber.nl@gmail.com>

* Update src/model/docker.ts

Co-authored-by: Webber Takken <webber.nl@gmail.com>

* Update src/model/docker.ts

Co-authored-by: Webber Takken <webber.nl@gmail.com>

* Update src/model/docker.ts

Co-authored-by: Webber Takken <webber.nl@gmail.com>

* Fix outdated repository and homepage links in dockerfiles

* Fix comment style and rename validateWindowsPrereqs to validateWindowsPlatformRequirements

* Remove redundant comment

* Remove windows unity test project, add ProjectSettings for the il2cpp backend, and add logic to replace the projectsettings file with the il2cpp one on windows test builds.

* Fix action.test.ts to accept windows as a base platform

* Fix camelcase for wsaPlayer

* Switch from add to copy in windows dockerfile

* Change slash direction

* Switch ADD to COPY to conform with best practices, change ls to dir on windows dockerfile

* Improve error message for unset UNITY_EMAIL and UNITY_PASSWORD

* Further improve missing email and password error. Remove temppaths being mounted to docker image

* Add debug statement. TODO: Remove these

* Add more debug

* Explicitly pass in unity email to docker run

* Remove debug and fix environment variables for activation/deactivation scripts

* Prevent Unity serial from leaking to console

* Debug folder listings

* More debug print dirs

* fix debug print path

* fix reg export command

* Remove debug directory listings and try setSecret to mask serial

* Update src/model/action.ts

Co-authored-by: Webber Takken <webber.nl@gmail.com>

* Update src/model/docker.ts

Co-authored-by: Webber Takken <webber.nl@gmail.com>

* Update src/model/image-tag.ts

Co-authored-by: David Finol <davidmfinol@gmail.com>

* Update .github/workflows/build-tests.yml

Co-authored-by: David Finol <davidmfinol@gmail.com>

* Move platform validation and setup out of docker and into its own layer, remove branching on docker run command

* Fix test failure due to missing license

* Fix camelCase and duplicate variables

* Fix lint issues and make paths more understandable

* Fix typo in build-tests.yml

* Fix move command in build-tests.yml

* Different method to force move file

* Fix missing quote and backslash

* Pass unity email and password to builder action for windows build tests

* Push serial to windows test builds

* Make windows build tests only run on push to main

Co-authored-by: Webber Takken <webber.nl@gmail.com>
Co-authored-by: David Finol <davidmfinol@gmail.com>
2022-01-25 22:18:15 +01:00

187 lines
4.6 KiB
Bash

#!/usr/bin/env bash
#
# Set project path
#
UNITY_PROJECT_PATH="$GITHUB_WORKSPACE/$PROJECT_PATH"
echo "Using project path \"$UNITY_PROJECT_PATH\"."
#
# Display the name for the build, doubles as the output name
#
echo "Using build name \"$BUILD_NAME\"."
#
# Display the build's target platform;
#
echo "Using build target \"$BUILD_TARGET\"."
#
# Display build path and file
#
echo "Using build path \"$BUILD_PATH\" to save file \"$BUILD_FILE\"."
BUILD_PATH_FULL="$GITHUB_WORKSPACE/$BUILD_PATH"
CUSTOM_BUILD_PATH="$BUILD_PATH_FULL/$BUILD_FILE"
#
# Set the build method, must reference one of:
#
# - <NamespaceName.ClassName.MethodName>
# - <ClassName.MethodName>
#
# For example: `BuildCommand.PerformBuild`
#
# The method must be declared static and placed in project/Assets/Editor
#
if [ -z "$BUILD_METHOD" ]; then
# User has not provided their own build command.
#
# Use the script from this action which builds the scenes that are enabled in
# the project.
#
echo "Using built-in build method."
# Create Editor directory if it does not exist
mkdir -p "$UNITY_PROJECT_PATH/Assets/Editor/"
# Copy the build script of Unity Builder action
cp -R "/UnityBuilderAction/Assets/Editor/" "$UNITY_PROJECT_PATH/Assets/Editor/"
# Set the Build method to that of UnityBuilder Action
BUILD_METHOD="UnityBuilderAction.Builder.BuildProject"
# Verify recursive paths
ls -Ralph "$UNITY_PROJECT_PATH/Assets/Editor/"
#
else
# User has provided their own build method.
# Assume they also bring their own script.
#
echo "Using build method \"$BUILD_METHOD\"."
#
fi
#
# Prepare Android keystore and SDK, if needed
#
if [[ "$BUILD_TARGET" == "Android" && -n "$ANDROID_KEYSTORE_NAME" && -n "$ANDROID_KEYSTORE_BASE64" ]]; then
echo "Creating Android keystore."
echo "$ANDROID_KEYSTORE_BASE64" | base64 --decode > "$UNITY_PROJECT_PATH/$ANDROID_KEYSTORE_NAME"
echo "Created Android keystore."
else
echo "Not creating Android keystore."
fi
if [[ "$BUILD_TARGET" == "Android" && -n "$ANDROID_SDK_MANAGER_PARAMETERS" ]]; then
echo "Updating Android SDK with parameters: $ANDROID_SDK_MANAGER_PARAMETERS"
export JAVA_HOME="$(awk -F'=' '/JAVA_HOME=/{print $2}' /usr/bin/unity-editor.d/*)"
"$(awk -F'=' '/ANDROID_HOME=/{print $2}' /usr/bin/unity-editor.d/*)/tools/bin/sdkmanager" "$ANDROID_SDK_MANAGER_PARAMETERS"
echo "Updated Android SDK."
else
echo "Not updating Android SDK."
fi
#
# Pre-build debug information
#
echo ""
echo "###########################"
echo "# Custom parameters #"
echo "###########################"
echo ""
echo "$CUSTOM_PARAMETERS"
echo ""
echo "###########################"
echo "# Current build dir #"
echo "###########################"
echo ""
echo "Creating \"$BUILD_PATH_FULL\" if it does not exist."
mkdir -p "$BUILD_PATH_FULL"
ls -alh "$BUILD_PATH_FULL"
echo ""
echo "###########################"
echo "# Project directory #"
echo "###########################"
echo ""
ls -alh "$UNITY_PROJECT_PATH"
#
# Build
#
echo ""
echo "###########################"
echo "# Building project #"
echo "###########################"
echo ""
# Reference: https://docs.unity3d.com/2019.3/Documentation/Manual/CommandLineArguments.html
unity-editor \
-logfile /dev/stdout \
-quit \
-customBuildName "$BUILD_NAME" \
-projectPath "$UNITY_PROJECT_PATH" \
-buildTarget "$BUILD_TARGET" \
-customBuildTarget "$BUILD_TARGET" \
-customBuildPath "$CUSTOM_BUILD_PATH" \
-executeMethod "$BUILD_METHOD" \
-buildVersion "$VERSION" \
-androidVersionCode "$ANDROID_VERSION_CODE" \
-androidKeystoreName "$ANDROID_KEYSTORE_NAME" \
-androidKeystorePass "$ANDROID_KEYSTORE_PASS" \
-androidKeyaliasName "$ANDROID_KEYALIAS_NAME" \
-androidKeyaliasPass "$ANDROID_KEYALIAS_PASS" \
-androidTargetSdkVersion "$ANDROID_TARGET_SDK_VERSION" \
$CUSTOM_PARAMETERS
# Catch exit code
BUILD_EXIT_CODE=$?
# Display results
if [ $BUILD_EXIT_CODE -eq 0 ]; then
echo "Build succeeded";
else
echo "Build failed, with exit code $BUILD_EXIT_CODE";
fi
#
# Permissions
#
# Make a given user owner of all artifacts
if [[ -n "$CHOWN_FILES_TO" ]]; then
chown -R "$CHOWN_FILES_TO" "$BUILD_PATH_FULL"
chown -R "$CHOWN_FILES_TO" "$UNITY_PROJECT_PATH"
fi
# Add read permissions for everyone to all artifacts
chmod -R a+r "$BUILD_PATH_FULL"
chmod -R a+r "$UNITY_PROJECT_PATH"
# Add execute permissions to specific files
if [[ "$BUILD_TARGET" == "StandaloneOSX" ]]; then
OSX_EXECUTABLE_PATH="$BUILD_PATH_FULL/$BUILD_NAME.app/Contents/MacOS"
find "$OSX_EXECUTABLE_PATH" -type f -exec chmod +x {} \;
fi
#
# Results
#
echo ""
echo "###########################"
echo "# Build output #"
echo "###########################"
echo ""
ls -alh "$BUILD_PATH_FULL"