Skip to content

Meant to serve as a simple template CI/CD system using GameCI for Unity games using GitHub Actions.

License

Notifications You must be signed in to change notification settings

Persomatey/unity-ci-cd-system-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

66 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Unity CI/CD System Template

A simple free template CI/CD system using GameCI for Unity games using GitHub Actions.

You can check out the sample app on the Releases tab of this GitHub repo.

Features

  • GitHub Releases
    • Builds get submitted to the "Releases" tab of your repo as a new release with separate .zip files for each build.
  • Last Commit SHA is added to the project via a .json file.
    • \Assets\Data\data.json in the project which can be displayed in game (on a main menu or something if you want).
    • Showcased in the Unity project scene.
  • Version number is updated to Unity's player and can be accessed using Application.version.
  • Project name is updated to Unity's player and can be accessed using Application.productName.
  • Unity Build Profiles
    • Under the buildForAllSupportedPlatforms job, you can change the strategy's matrix and include whatever build profiles you want
    • Showcased in the differences between the built Unity projects, including the defines included in the Build Profiles as displayed in the Unity project scene.
  • Supports semantic versioning (MAJOR.MINOR.PATCH).
    • Every push increments the PATCH number, with MAJOR and MINOR being incremented maually.
  • (Optional) Parallel builds (to speed up development, but may need to be turned off if memory is exceeding what your runner supports).
    • Under the buildForAllSupportedPlatforms job, you can change the strategy's max-parallel value accordingly.
  • (Optional) Fail fast support, so you're not creating multiple builds if one fails.
    • Under the buildForAllSupportedPlatforms job, you can change the strategy's fail-fast accordingly.
    • It's set as false by default because sometimes there could be a problem with a single build profile or platform -- but it's there if you're stingy with your runner minutes.
  • (Optional) LFS support
    • Under the Checkout repository step, change the lfs value accordingly.
  • (Optional) Concurrent workflows
    • Under concurrency, set the cancel-in-progress value accordingly.
    • This is mostly to save on runner minutes, but if you don't care about that, leaving it false allows you to better track down a bug, especially when collaborating with multiple devs or if you have long build times.

Workflows

Build (build.yml)

Every time a push is made to the GitHub repository, builds will trigger using the Unity BuildProfiles files provided in the build.yml. This will also increment the PATCH version number. A Release Tag will be generated and the builds generated will be included in your repo page's "Releases" tab.

Build profiles included by default:

  • windows-dev: Dev build for Windows with DEV defines included
  • windows-rel: Release build for Windows with REL defines included
  • linux-dev: Dev build for Linux with DEV defines included
  • linux-rel: Release build for Linux with REL defines included
  • webgl-dev: Dev build for WebGL with DEV defines included
  • webgl-rel: Release build for WebGL with REL defines included

Version Bumping (version-bump.yml)

Used to manually version bump the version number. Should be in the format X.Y.Z. All future pushes will subsequently start incrementing based on the new MAJOR or MINOR version changes. - Ex: If the last version before triggering this workflow is v0.0.42, and the workflow was triggered with v0.1.0, the next build.yml workflow run will create the version tag v0.1.1.

Set up

  1. Fork/clone this repository (rename repository to match your project)
    • "Use this template" > "Create a new repository" > etc.
    • Or if you already have a project: Copy the workflows located in this repo's .github/workflows/ into your .github/workflows/ (create this directory if you don't have one already
      • .github/workflows/build.yml
      • .github/workflows/version-bump.yml
  2. Rename your Unity project name to whatever you want
    • unity_project/ -> MyAmazingUnityGame/
  3. Find/Generate Unity license
    1. Open Unity Hub and log in with your Unity account (if you do not have a current .ulf) then navigate to Preferences > Licenses > Add)
    2. Find your Unity_lic.ulf file
      • Windows: C:\ProgramData\Unity\Unity_lic.ulf
      • Mac: /Library/Application Support/Unity/Unity_lic.ulf
      • Linux: ~/.local/share/unity3d/Unity/Unity_lic.ulf
  4. Hook up Unity Credentials
    1. On your GitHub repo's, navigate to Setting > Secrets and variables > Actions
    2. Create three new Repository secrets
      • UNITY_LICENSE (Paste the contents of your license file into here)
      • UNITY_EMAIL (Add the email address that you use to log into Unity)
      • UNITY_PASSWORD (Add the password that you use to log into Unity)
  5. In .github/workflows/build.yml, in the env, set the following variables:
    • PROJECT_NAME (line 18) variable to your project's name
    • UNITY_VERSION(line 19) variable to your project's Unity version
      • Ensure it uses a version of Unity that GameCI supports on their tags page
    • PROJECT_PATH(line 20) variable to your project's path
  6. In .github/workflows/build.yml, in the on, set which branches you want to trigger builds from on push and on pull_request
  7. In .github/workflows/build.yml in the buildForAllSupportedPlatforms job, in the strategy matrix config, include the Unity Build Profiles you want generated

Future Plans

No plans on when I'd release these features, would likely depend on my needs for a specific project/boredom/random interest in moving this project along.

  • Include multiple workflow concurrency
  • Include platform and included defines in .json
  • Android build support
  • iOS build support
  • VR build support
  • itch.io CD
  • Steam CD
  • Epic Games CD
  • Slack notifications webhook
  • Google Meets notifications webhook
  • Discord notifications webhook
  • Microsoft Teams notifications webhook
  • Add more concurrency features for multiple in progress workflows

About

Meant to serve as a simple template CI/CD system using GameCI for Unity games using GitHub Actions.

Resources

License

Stars

Watchers

Forks

Packages

No packages published