Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .github/workflows/releaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
name: "pre-release"

on:
push:
branches:
- "main"

jobs:
pre-release:
name: "Pre Release"
runs-on: "ubuntu-latest"
steps:
- uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: "latest"
prerelease: true
title: "Development Build"
12 changes: 12 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ inputs:
required: false
default: ''
description: 'Suppresses `-quit`. Exit your build method using `EditorApplication.Exit(0)` instead.'
cleanBuild:
required: false
default: ''
description: 'If the build will be a clean one or not.'
addressableBuild:
required: false
default: ''
description: 'If the build will be an addressable one or not.'
customParameters:
required: false
default: ''
Expand Down Expand Up @@ -209,6 +217,10 @@ inputs:
default: 'false'
required: false
description: 'Whether to cache the Unity hub and editor installation on MacOS'
cacheServerEndpoint:
default: ''
required: true
description: 'Cache Server Endpoint that we will use to build'
unityHubVersionOnMac:
default: ''
required: false
Expand Down
23 changes: 23 additions & 0 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

21 changes: 20 additions & 1 deletion dist/platforms/mac/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,27 @@ mkdir -p "$ACTIVATE_LICENSE_PATH"
#
# Run steps
#

#if clean run clean.sh
#if addressables run build-addressables
# always build.sh
source $ACTION_FOLDER/platforms/mac/steps/activate.sh
source $ACTION_FOLDER/platforms/mac/steps/build.sh

if [ -z "$CLEAN_BUILD" ]; then

source $ACTION_FOLDER/platforms/mac/steps/build-library.sh

elif [ -z "$ADDRESSABLE_BUILD" ]; then

source $ACTION_FOLDER/platforms/mac/steps/build-addressable.sh

else

source $ACTION_FOLDER/platforms/mac/steps/build.sh

fi


source $ACTION_FOLDER/platforms/mac/steps/return_license.sh

#
Expand Down
17 changes: 13 additions & 4 deletions dist/platforms/mac/steps/activate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,21 @@ elif [[ -n "$UNITY_LICENSING_SERVER" ]]; then

/Applications/Unity/Hub/Editor/$UNITY_VERSION/Unity.app/Contents/Frameworks/UnityLicensingClient.app/Contents/Resources/Unity.Licensing.Client --acquire-floating > license.txt #is this accessible in a env variable?

##PARSEDFILE=$(grep -oP '\".*?\"' < license.txt | tr -d '"')
DOUBLEQUOTE=$(grep '"' < license.txt)

if [ -n "$DOUBLEQUOTE" ]; then
echo "Double quotes isn't empty on the license file"
PARSEDFILE=$(ggrep -oP '\".*?\"' < license.txt | tr -d '"')
FLOATING_LICENSE=$(sed -n 2p <<< "$PARSEDFILE")
FLOATING_LICENSE_TIMEOUT=$(sed -n 4p <<< "$PARSEDFILE")

else
echo "Double quotes is empty on the license file"
FLOATING_LICENSE=$(cat license.txt | awk '/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/' | awk '{print $6}' | sed 's/.$//')
export FLOATING_LICENSE
##FLOATING_LICENSE=$(sed -n 2p <<< "$PARSEDFILE")
#FLOATING_LICENSE_TIMEOUT=$(sed -n 4p <<< "$PARSEDFILE")

fi

export FLOATING_LICENSE
echo "Acquired floating license: \"$FLOATING_LICENSE\""
# Store the exit code from the verify command
UNITY_EXIT_CODE=$?
Expand Down
181 changes: 181 additions & 0 deletions dist/platforms/mac/steps/build-addressable.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
#!/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 "$ACTION_FOLDER/default-build-script/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"
ANDROID_INSTALL_LOCATION="/Applications/Unity/Hub/Editor/$UNITY_VERSION/PlaybackEngines/AndroidPlayer"
export JAVA_HOME="$ANDROID_INSTALL_LOCATION/OpenJDK"
export ANDROID_HOME="$ANDROID_INSTALL_LOCATION/SDK"
yes | "$ANDROID_HOME/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

/Applications/Unity/Hub/Editor/$UNITY_VERSION/Unity.app/Contents/MacOS/Unity \
-logFile - \
-quit \
-cacheServerEndpoint "$CACHESERVERENDPOINT" \
-batchmode \
-nographics \
-projectPath "$UNITY_PROJECT_PATH" \
-buildTarget "$BUILD_TARGET" \
-executeMethod "$BUILD_METHOD" \
$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"
Loading