diff --git a/.gitignore b/.gitignore index bc20e914..38624a6f 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,6 @@ lib/ .vsconfig yarn-error.log .orig +.env +build/* +dist/unity-config/*.txt \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json index 9c7be0a5..7e004362 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -1,5 +1,16 @@ { "configurations": [ + { + "type": "node-terminal", + "request": "launch", + "name": "Launch Program", + "command": "ts-node -- ${workspaceFolder}/src/index.ts", + "cwd": "${workspaceFolder}", + "envFile": "${workspaceRoot}/.env", + "env": { + "UNITY_NOPROXY": "localhost,127.0.0.1" + } + }, { "type": "node", "request": "launch", diff --git a/dist/index.js b/dist/index.js index 9c38ab9a..7e2642ff 100644 Binary files a/dist/index.js and b/dist/index.js differ diff --git a/dist/index.js.map b/dist/index.js.map index ca610bdb..f1d937a0 100644 Binary files a/dist/index.js.map and b/dist/index.js.map differ diff --git a/dist/platforms/mac/entrypoint.sh b/dist/platforms/mac/entrypoint.sh index 37cf7a4b..d95066a5 100755 --- a/dist/platforms/mac/entrypoint.sh +++ b/dist/platforms/mac/entrypoint.sh @@ -4,7 +4,7 @@ # Create directories for license activation # -sudo mkdir /Library/Application\ Support/Unity +sudo mkdir -p /Library/Application\ Support/Unity/config sudo chmod -R 777 /Library/Application\ Support/Unity ACTIVATE_LICENSE_PATH="$ACTION_FOLDER/BlankProject" diff --git a/dist/platforms/mac/steps/activate.sh b/dist/platforms/mac/steps/activate.sh index c9511eb5..720514f4 100755 --- a/dist/platforms/mac/steps/activate.sh +++ b/dist/platforms/mac/steps/activate.sh @@ -6,19 +6,61 @@ pushd "$ACTIVATE_LICENSE_PATH" echo "Requesting activation" -# Activate license -/Applications/Unity/Hub/Editor/$UNITY_VERSION/Unity.app/Contents/MacOS/Unity \ - -logFile - \ - -batchmode \ - -nographics \ - -quit \ - -serial "$UNITY_SERIAL" \ - -username "$UNITY_EMAIL" \ - -password "$UNITY_PASSWORD" \ - -projectPath "$ACTIVATE_LICENSE_PATH" -# Store the exit code from the verify command -UNITY_EXIT_CODE=$? +if [[ -n "$UNITY_SERIAL" && -n "$UNITY_EMAIL" && -n "$UNITY_PASSWORD" ]]; then + + + # Activate license + /Applications/Unity/Hub/Editor/$UNITY_VERSION/Unity.app/Contents/MacOS/Unity \ + -logFile - \ + -batchmode \ + -nographics \ + -quit \ + -serial "$UNITY_SERIAL" \ + -username "$UNITY_EMAIL" \ + -password "$UNITY_PASSWORD" \ + -projectPath "$ACTIVATE_LICENSE_PATH" + + # Store the exit code from the verify command + UNITY_EXIT_CODE=$? + +elif [[ -n "$UNITY_LICENSING_SERVER" ]]; then + + # + # Custom Unity License Server + # + echo "Adding licensing server config" + echo "Echoing the floating license address $UNITY_LICENSING_SERVER" + echo "Copying the services-config.json to Library" + cp ../unity-config/services-config.json /Library/Application\ Support/Unity/config/ + + /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 '"') + 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") + + echo "Acquired floating license: \"$FLOATING_LICENSE\"" + # Store the exit code from the verify command + UNITY_EXIT_CODE=$? + +else + # + # NO LICENSE ACTIVATION STRATEGY MATCHED + # + # This will exit since no activation strategies could be matched. + # + echo "License activation strategy could not be determined." + echo "" + echo "Visit https://game.ci/docs/github/getting-started for more" + echo "details on how to set up one of the possible activation strategies." + + # Immediately exit as no UNITY_EXIT_CODE can be derrived. + exit 1; + +fi # # Display information about the result diff --git a/dist/platforms/mac/steps/build.sh b/dist/platforms/mac/steps/build.sh index 8fd98f69..50727059 100755 --- a/dist/platforms/mac/steps/build.sh +++ b/dist/platforms/mac/steps/build.sh @@ -132,8 +132,6 @@ echo "" -quit \ -batchmode \ -nographics \ - -username "$UNITY_EMAIL" \ - -password "$UNITY_PASSWORD" \ -customBuildName "$BUILD_NAME" \ -projectPath "$UNITY_PROJECT_PATH" \ -buildTarget "$BUILD_TARGET" \ diff --git a/dist/platforms/mac/steps/return_license.sh b/dist/platforms/mac/steps/return_license.sh index 1749f9e7..aaa520e9 100755 --- a/dist/platforms/mac/steps/return_license.sh +++ b/dist/platforms/mac/steps/return_license.sh @@ -4,15 +4,27 @@ echo "Changing to \"$ACTIVATE_LICENSE_PATH\" directory." pushd "$ACTIVATE_LICENSE_PATH" -/Applications/Unity/Hub/Editor/$UNITY_VERSION/Unity.app/Contents/MacOS/Unity \ - -logFile - \ - -batchmode \ - -nographics \ - -quit \ - -username "$UNITY_EMAIL" \ - -password "$UNITY_PASSWORD" \ - -returnlicense \ - -projectPath "$ACTIVATE_LICENSE_PATH" + +if [[ -n "$UNITY_LICENSING_SERVER" ]]; then + # + # Return any floating license used. + # + echo "Returning floating license: \"$FLOATING_LICENSE\"" + /Applications/Unity/Hub/Editor/$UNITY_VERSION/Unity.app/Contents/Frameworks/UnityLicensingClient.app/Contents/Resources/Unity.Licensing.Client --return-floating "$FLOATING_LICENSE" + +else + + /Applications/Unity/Hub/Editor/$UNITY_VERSION/Unity.app/Contents/MacOS/Unity \ + -logFile - \ + -batchmode \ + -nographics \ + -quit \ + -username "$UNITY_EMAIL" \ + -password "$UNITY_PASSWORD" \ + -returnlicense \ + -projectPath "$ACTIVATE_LICENSE_PATH" + +fi # Return to previous working directory popd diff --git a/src/model/build-parameters.ts b/src/model/build-parameters.ts index bd5f9103..10840a80 100644 --- a/src/model/build-parameters.ts +++ b/src/model/build-parameters.ts @@ -23,6 +23,7 @@ class BuildParameters { public unityLicensingServer!: string; public runnerTempPath!: string; public targetPlatform!: string; + public targetArchitecture!: string; public projectPath!: string; public buildName!: string; public buildPath!: string; @@ -134,6 +135,7 @@ class BuildParameters { unityLicensingServer: Input.unityLicensingServer, runnerTempPath: Input.runnerTempPath, targetPlatform: Input.targetPlatform, + targetArchitecture: Input.targetArchitecture, projectPath: Input.projectPath, buildName: Input.buildName, buildPath: `${Input.buildsPath}/${Input.targetPlatform}`, diff --git a/src/model/input.ts b/src/model/input.ts index f50b0633..5d793275 100644 --- a/src/model/input.ts +++ b/src/model/input.ts @@ -80,6 +80,10 @@ class Input { return Input.getInput('targetPlatform') || Platform.default; } + static get targetArchitecture(): string { + return Input.getInput('targetArchitecture') || Platform.defaultarch; + } + static get unityVersion(): string { return Input.getInput('unityVersion') || 'auto'; } diff --git a/src/model/platform-setup/setup-mac.ts b/src/model/platform-setup/setup-mac.ts index d529d21f..33c8355a 100644 --- a/src/model/platform-setup/setup-mac.ts +++ b/src/model/platform-setup/setup-mac.ts @@ -76,7 +76,7 @@ class SetupMac { const moduleArgument = []; switch (targetPlatform) { case 'iOS': - moduleArgument.push('--module', 'ios'); + moduleArgument.push('--module', 'ios', '--module', 'android'); break; case 'tvOS': moduleArgument.push('--module', 'tvos'); @@ -85,7 +85,7 @@ class SetupMac { moduleArgument.push('--module', 'mac-il2cpp'); break; case 'Android': - moduleArgument.push('--module', 'android'); + moduleArgument.push('--module', 'android', '--module', 'ios'); break; case 'WebGL': moduleArgument.push('--module', 'webgl'); @@ -111,6 +111,7 @@ class SetupMac { const unityChangeset = await getUnityChangeset(buildParameters.editorVersion); const moduleArguments = SetupMac.getModuleParametersForTargetPlatform(buildParameters.targetPlatform); + const unityArch = buildParameters.targetArchitecture; const execArguments: string[] = [ '--', @@ -120,6 +121,7 @@ class SetupMac { ...['--changeset', unityChangeset.changeset], ...moduleArguments, '--childModules', + ...['--architecture', unityArch], ]; // Ignoring return code because the log seems to overflow the internal buffer which triggers diff --git a/src/model/platform.ts b/src/model/platform.ts index 768e51b4..b39b0957 100644 --- a/src/model/platform.ts +++ b/src/model/platform.ts @@ -3,6 +3,17 @@ class Platform { return Platform.types.StandaloneWindows64; } + static get defaultarch() { + return Platform.archs.X86_64; + } + + static get archs() { + return { + X86_64: 'x86_64', + Arm64: 'arm64', + }; + } + static get types() { return { StandaloneOSX: 'StandaloneOSX',