Skip to content

Latest commit

 

History

History
104 lines (80 loc) · 4.54 KB

README.md

File metadata and controls

104 lines (80 loc) · 4.54 KB

Unity Build Factory

project builder

Unity Build Factory is a workflow for building and deploying multi-architecture Unity projects using GitHub Actions and GameCI. It was created to unify the repetitive build process for multiple projects and simplify deploying to GitHub Pages for private repositories with build artifacts that can be download by unauthenticated visitors.

By default the workflow will compile and build the Unity project for the following platforms:

  • Windows
  • Linux
  • WebGL
  • console support coming

It is capable of deploying the build artifacts to the following platforms:

  • GitHub Pages
  • steam support coming

I'm currently using Unity Build Factory to rapidly deploy demos for a few of my projects, like Neebo.

Usage

  1. Have a GitHub repository containing a Unity project.
  2. Fork this repository and enable Actions.
  3. Create a GitHub Personal Access Token with read/write access to the target Unity project repository.
  4. Review GameCI and add the following GitHub repository secrets to your fork:
    • UNITY_EMAIL
    • UNITY_PASSWORD
    • UNITY_LICENSE
    • PAT_TOKEN
  5. In your fork, find the Actions workflow named project builder and select Run workflow
    1. enter the owner/repo corresponding to the target Unity project repository
    2. (optional) enter the ref or leave blank to use the repository's default branch
    3. (optional) toggle deploy-to-pages and set the pages-deploy-branch
    4. run the workflow

Each project will likely take a long time to finish building on the first run but caching will speed up subsequent runs.

Be wary of GitHub Actions billing, as the Unity Build Factory workflow can consume a lot of minutes and Artifact storage space if you have a lot of projects or are building frequently.

Artifacts

The workflow will create a pre-release for each platform and attach the corresponding build that was produced in Actions. The pre-releases are updated with each run as to not clutter the repository with tags while testing and deploying numerous builds.

To download the built artifacts simply navigate to the releases section of the target repository and download the artifacts from the pre-release that corresponds to the platform you want to download.

GitHub Pages

To enable support for deploying to GitHub Pages, the following steps are required:

  1. Enable repo:write access for the GitHub Personal Access Token used by the workflow.
  2. Set Compression Format to Brotli in the Unity project's WebGL deploy settings.
  3. Enable GitHub Pages for the target repository.
  4. Add the following workflow to the target repository:
deploy-pages.yml
name: deploy project to gh-pages

on:
  push:
    branches:
      - 'gh-pages'

permissions:
  contents: write
  pages: write
  id-token: write

concurrency:
  group: deploy
  cancel-in-progress: true

jobs:
  deploy:
    needs: read
    runs-on: ubuntu-latest
    environment:
      name: github-pages
      url: ${{ steps.deployment.outputs.page_url }}
    steps:
      - name: configure pages
        uses: actions/configure-pages@v2
      - name: upload pages build artifact
        uses: actions/upload-pages-artifact@v1
        with:
          path: .
      - name: deploy pages
        id: deployment
        uses: actions/deploy-pages@v1
  1. Add a WebGL build demo template to the target repository under the directory WebGL.

    A WebGL template in this context refers to a directory following the structure produced by Unity when running a WebGL build, the build factory will replace the template's game contents with what your project produces and keep the rest of the WebGL template as-is, allowing you to create a custom-tailored static site that hosts your game's WebGL build.

Feedback

Open an issue: https://github.com/plyr4/unity-factory/issues

License

See https://www.gnu.org/licenses/.