1.2.0 • Published 28 days ago

extensions.unity.ubuilder v1.2.0

Weekly downloads
-
License
-
Repository
-
Last release
28 days ago

UBuilder - Unity command line builder

npm openupm License Stand With Ukraine

Unity command line builder. Flexible setup through Environment variables in combination with command line variables. Well combined with Fastlane.

All operation systems are supported for running the build process:

  • :white_check_mark: Windows
  • :white_check_mark: MacOS
  • :white_check_mark: Linux

Supported platforms:

  • :white_check_mark: Standalone (Windows / Mac / Linux)
  • :white_check_mark: iOS
  • :white_check_mark: Android
  • :yellow_circle: other (supported but not tested)

How to install - Option 1 (RECOMMENDED)

  • Install OpenUPM-CLI
  • Open command line in Unity project folder
  • openupm add extensions.unity.ubuilder

How to install - Option 2

  • Add this code to /Packages/manifest.json
{
  "dependencies": {
    "extensions.unity.ubuilder": "1.2.0",
  },
  "scopedRegistries": [
    {
      "name": "Unity Extensions",
      "url": "https://registry.npmjs.org",
      "scopes": [
        "extensions.unity"
      ]
    }
  ]
}

Variables

Any variable can be passed as argument in command line such as output=./Builds/Destination or it could be set as environment variable in command line or in operation system or even in docker. In command line you can do this by this command

SET output=./Builds/Destination on Windows

output=./Builds/Destination on MacOS and Linux

Global variables

VariableTypeDefaultDescription
outputstringnullabsolute or relevant path to build destination
buildNumberintegertimestampinteger value of build number
buildVersionstringcurrent versionbuild version, should contains only numbers and dots, last and first characters should be numbers
developmentBuildbooleancurrent valuetrue/false, enable or disable Unity project flag - Development Build

iOS related variables

VariableTypeDefaultDescription
ios_SigningTeamIdstringcurrent valueApple signing team ID
ios_EnableAutomaticSigningbooleancurrent valuetrue/false, automatic signing build

Android related variables

VariableTypeDefaultDescription
android_BUILD_APP_BUNDLEstringcurrent valuetrue/false, true - compile .aab file for Google Play, false - compile .apk
android_KEYSTORE_PATHbooleannullrequired path to keystore
android_KEYSTORE_PASSWORDbooleannullrequired keystore password
android_KEYALIAS_NAMEbooleannullrequired key alias
android_KEYALIAS_PASSWORDbooleannullrequired key alias password

How to use in command line (MacOS & Linux)

Tip: If you don't have Unity Pro license that allow you to run Unity in batchmode (no GUI), you can use Unity Personal license. In this case you should run Unity Editor with GUI and it will build project. Just need to remove -batchmode -nographics from command line.

iOS

UnityEditor=/Applications/"Unity Editor"/2019.2.1f1/Unity.app/Contents/MacOS/Unity
"$UnityEditor" -projectPath ./ -logFile build.log -executeMethod UBuilder.CommandiOS.Build -quit -accept-apiupdate -quitTimeout 6000 -batchmode -nographics

Android

UnityEditor=/Applications/"Unity Editor"/2019.2.1f1/Unity.app/Contents/MacOS/Unity
android_KEYSTORE_PATH=***************
android_KEYSTORE_PASSWORD=***************
android_KEYALIAS_NAME=***************
android_KEYALIAS_PASSWORD=***************

"$UnityEditor" -projectPath ./ -logFile build.log -executeMethod UBuilder.CommandAndroid.Build -quit -accept-apiupdate -quitTimeout 6000 -batchmode -nographics

Other

UnityEditor=/Applications/"Unity Editor"/2019.2.1f1/Unity.app/Contents/MacOS/Unity
"$UnityEditor" -projectPath ./ -logFile build.log -executeMethod UBuilder.Command.Build -quit -accept-apiupdate -quitTimeout 6000 -batchmode -nographics

Or create .sh file and put the text inside. Ease way to start build process by single script.

How to use in command line (Windows)

Android

SET UnityEditor=C:/UnityEditor/Unity/2019.2.1f1/Editor/Unity.exe
SET android_BUILD_APP_BUNDLE=false
SET android_KEYSTORE_PATH=***************
SET android_KEYSTORE_PASSWORD=***************
SET android_KEYALIAS_NAME=***************
SET android_KEYALIAS_PASSWORD=***************

%UnityEditor% -projectPath ./ -logFile build.log -executeMethod UBuilder.CommandAndroid.Build -quit -accept-apiupdate -quitTimeout 6000 -batchmode -nographics

Other

SET UnityEditor=C:/UnityEditor/Unity/2019.2.1f1/Editor/Unity.exe
%UnityEditor% -projectPath ./ -logFile build.log -executeMethod UBuilder.Command.Build -quit -accept-apiupdate -quitTimeout 6000 -batchmode -nographics

Or create .bat file and put the text inside. Double click the bat file. Ease way to start build process by single script

Hot to use in code (any OS)

FunctionDescription
UBuilder.CommandiOS.Build()create XCode project (MacOS required)
UBuilder.CommandAndroid.Build()create APK (android_BUILD_APP_BUNDLE=false) or AAB (android_BUILD_APP_BUNDLE=true) file
UBuilder.CommandAndroid.Export()create Android Studio project
UBuilder.Command.Build()build current (from ProjectSettings) platform build

How to use in Unity Editor (codeless)

Press File/UBuilder and choose needed build options from the list.

Build Options

Customize project before build

Before execute the UBuilder functions, prepare a project to build. You can do that by creating public static class with public static method. In that method you should prepare your project and call needed UBuilder function. In command line call your new public static function instead of UBuilder function. Example:

public static class ProjectBuilder
{
    // customize package name (bundle id)
    [MenuItem("File/UBuilder/Build Android custom package")]
    public static void BuildiOSCustomPackage()
    {
        PlayerSettings.SetApplicationIdentifier(BuildTargetGroup.iOS, "my.project.game");
        UBuilder.CommandiOS.Build();
    }
    
    // customize package name (bundle id)
    [MenuItem("File/UBuilder/Build Android+iOS custom package")]
    public static void BuildiOSAndroidCustomPackage()
    {
        PlayerSettings.SetApplicationIdentifier(BuildTargetGroup.iOS, "my.project.game");
        PlayerSettings.SetApplicationIdentifier(BuildTargetGroup.Android, "my.project.game");
        UBuilder.CommandiOS.Build();
        UBuilder.CommandAndroid.Build();
    }
}
SET UnityEditor=C:/UnityEditor/Unity/2019.2.1f1/Editor/Unity.exe
%UnityEditor% -projectPath ./.. -logFile build.log -executeMethod BuildProject.BuildiOSCustomPackage -quit -accept-apiupdate -quitTimeout 6000 -batchmode -nographics output=Builds/iOS_Custom_Package
1.2.0

28 days ago

1.1.3

1 year ago

1.1.2

1 year ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago