Giter Club home page Giter Club logo

unity-build-server's Introduction

Unity Build Server

Flask based Unity build server with a web interface. Version 2.6

How it works?

  1. The server handles HTTP requests over localhost:80.
  2. When you start a build trough its web interface, it reads the projects.cfg file and choses the config for the specific project.
  3. It tries to open the project's own BuildSettings.txt file which may contain additional configurations, arguments or overrides. (Not necessary, used to increase version)
  4. Executes the value of updateProjectScript (Used to pull the latest changes)
  5. The server opens unity using all the configuration entries as arguments.
  6. Unity runs the static method defined in executeMethod (Used to set internal project parameters)
  7. After the build is finished, runs postBuildScript if exists in configs (Used to upload addressables)

Installation

  1. Use the package manager pip to install the dependencies.
pip install flask
pip install psutil
  1. Configure the server as it is written bellow
  2. Copy the contents of the unity_plugin directory into your Unity project assets. You can modify it to your heart's content, as it will be certainly unique for each project.
  3. Create all necessary directories for your projects. (You might even want to clone them)
  4. Run the _START_SERVER.ps1 (on Windows) or build_server.py trough Python

Config

How to add your project

Edit the projects.cfg file to add a new build project. Example:

[
   {
      "project":"SimpleUnityProject",
      "engineVersion":"2019.1.2f1",
      "executeMethod":"Editor.Builder.BuildCommand.ExecuteBuild",
      "postBuildScript":"scripts/upload_addressables.ps1",
      "updateProjectScript":"scripts/update_workspace_git.ps1",
      "webhookUrl":"Slack/ Discord URL",
      "xcodeScript":"scripts/build_xcode.ps1"
   }
]

Here you can add all the fundamental variables to your project, which will be later inherited by all build configurations for the project.

How to add a build configuration to an existing project

Edit (or create) a file called {project}.project (SimpleUnityProject.project) in the config directory. This file can extend and override the content for its corresponding project config (mentioned above) Example:

   {  
      #This is the name of this configuration
      "name":"SC Dev",
      #Unity engine version
      "engineVersion":"2018.2.14f1",
      #Version of the project, used at naming and passed as argument to Unity
      "projectVersion":"1.0.0",
      #Unique path to the project to ensure paralell builds
      "projectPath":"D:\\wkspaces\\SimpleUnityProject_Dev",
      #Static method to execute inside of the project. You may parse build args here
      "executeMethod":"Editor.Builder.BuildCommand.ExecuteBuild",
      #Build output directory
      "buildDirectory":"E:\\OneDrive - PXFD\\Builds\\SimpleUnityProject\\Dev",
      #Target platform
      "buildTarget":"Android",
      #Target environment, passed as argument
      "env":"Development",
      #Script to call before build, to pull the latest version of the game
      "updateProjectScript":"scripts\\update_workspace_git.ps1",
      #Script to call after build, to upload generated addressable assets,
      "postBuildScript":"scripts\\upload_addressables.ps1",
      #A Json of build reports will be sent to this URL. Perfect for Slack messages
      "webhookUrl":"Slack/ Discord URL",
      #This is a special script, necessary for iOS builds, handling the xcode build phase
      "xcodeScript":"scripts/build_xcode.ps1"
   }

Every entry of the configuration will be passed as arguments as well into unity.

It is possible to override most of these by committing a BuildSettings.txt file into the project root. The build server will prioritize its content over the projects config file. Example of BuildSettings.txt:

{  
   "engineVersion":"2018.2.14f1",
   "projectVersion":"1.1.2",
   "executeMethod":"Editor.Builder.BuildCommand.ExecuteBuild"
}

After the build server pulls the latest version of this file, it will use the values of the engineVersion, projectVersion and executeMethod to build the project

iOS Build

Is working on the apple_system branch. Will build your app and upload it straight to TestFlight. This makes it possible to build iOS from any platform.

You'll need the following things to make it work:

  • Download your provisioning licence file and name it "ios.mobileprovision" to your project root
  • Import the xcode manipulation script to your unity project
    • Is in this repo, in the unity_plugins folder, called XcodeBuildPostProcessor
  • Unity Team Id: HFN7ALEN9T to build settings
  • A build configuration with iOS target

unity-build-server's People

Contributors

z4urce avatar

Watchers

 avatar  avatar

Forkers

itkdo

unity-build-server's Issues

Crash When Configuring a Project

Hey,
I was trying to set this server up to do some build stuff and encountered a problem when trying to configure it, the stacktrace is below:

Traceback (most recent call last):
  File "C:\Users\kaide\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\flask\app.py", line 2190, in wsgi_app
    response = self.full_dispatch_request()
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\kaide\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\flask\app.py", line 1486, in full_dispatch_request
    rv = self.handle_user_exception(e)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\kaide\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\flask\app.py", line 1484, in full_dispatch_request
    rv = self.dispatch_request()
         ^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\kaide\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\flask\app.py", line 1469, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\kaide\Documents\UnityBuildServer\unity-build-server\build_server.py", line 26, in project_home
    configs = utils.read_configs(project_id)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\kaide\Documents\UnityBuildServer\unity-build-server\utils.py", line 85, in read_configs
    config[setting] = project_base_config[setting]
    ~~~~~~^^^^^^^^^
TypeError: 'str' object does not support item assignment
127.0.0.1 - - [17/Jun/2023 13:12:00] "GET /project/TestCICD HTTP/1.1" 500 -
127.0.0.1 - - [17/Jun/2023 13:12:00] "GET /favicon.ico HTTP/1.1" 304 -
Thread task started
Exception in thread Thread-1:
Traceback (most recent call last):
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.1264.0_x64__qbz5n2kfra8p0\Lib\threading.py", line 1038, in _bootstrap_inner
    self.run()
  File "C:\Users\kaide\Documents\UnityBuildServer\unity-build-server\utils.py", line 28, in run
    self.hFunction()
  File "C:\Users\kaide\Documents\UnityBuildServer\unity-build-server\build_server.py", line 210, in query_project_changes_all
    paths = utils.get_unique_project_paths()
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\kaide\Documents\UnityBuildServer\unity-build-server\utils.py", line 113, in get_unique_project_paths
    project_configs = read_configs(project)
                      ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\kaide\Documents\UnityBuildServer\unity-build-server\utils.py", line 85, in read_configs
    config[setting] = project_base_config[setting]
    ~~~~~~^^^^^^^^^
TypeError: 'str' object does not support item assignment```

I was wondering if you had any insight into this issue?
Any help is appreciated!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.