Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 107 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
# CI for pull requests
# https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle?learn=continuous_integration&learnProduct=actions
# Using gradle-build-action. See https://github.com/gradle/gradle-build-action

name: CI

on: [pull_request,workflow_dispatch]

# push:
# branches:
# - 'build'
# #- 'releases/**'
# #- '!releases/**-alpha'

jobs:
build:
runs-on: ubuntu-latest
env:
UPM_PACKAGE_CREDENTIAL_UPMCONFIG_TOML: ${{ secrets.UPM_PACKAGE_CREDENTIAL_UPMCONFIG_TOML }}
strategy:
matrix:
unity-version-matrix: [ 2019.4.36f1, 2020.3.30f1, 2021.2.14f1 ] #, 2022.1.0b14

steps:
- name: Checkout Code
uses: actions/checkout@v2
with:
submodules: 'true'
#not great, but let's also set up java so we can run sdkmanager. probably a way to avoid this.
#https://github.com/marketplace/actions/setup-unity
#possible modules on linux - android,ios,webgl,linux-il2cpp,mac-mono,windows-mono
- name: Setup Unity
uses: kuler90/setup-unity@v1
with:
unity-version: ${{ matrix.unity-version-matrix }}
unity-modules: android
install-path: /opt/Unity
#need 2fa to not error out I think
- name: Activate Unity
continue-on-error: true
uses: kuler90/activate-unity@v1
with:
unity-username: ${{ secrets.UNITY_USERNAME }}
unity-password: ${{ secrets.UNITY_PASSWORD }}
- name: list all files in current dir
run: |
find .
- name: environment tests
run: |
echo $UNITY_PATH
find $UNITY_PATH
echo $ANDROID_HOME
echo $ANDROID_NDK_HOME
echo $NDK_HOME
echo $JAVA_HOME
echo ${{ matrix.unity-version-matrix }}
echo env UNITY_PATH: ${{ env.UNITY_PATH }}

# https://stackoverflow.com/questions/46402772/failed-to-install-android-sdk-java-lang-noclassdeffounderror-javax-xml-bind-a
- name: accept licenses if not already done
continue-on-error: true
run: |
echo "y" | /opt/Unity/${{ matrix.unity-version-matrix }}/Editor/Data/PlaybackEngines/AndroidPlayer/SDK/tools/bin/sdkmanager --sdk_root="/opt/Unity/${{ matrix.unity-version-matrix }}/Editor/Data/PlaybackEngines/AndroidPlayer/SDK" --licenses
- name: list all files in unity install dir
run: |
find /opt/Unity/
#- run:
# name: accept licenses
# command: |
# echo "y" | ${ANDROID_HOME}/tools/bin/sdkmanager --licenses
#https://docs.unity3d.com/Manual/EditorCommandLineArguments.html

- name: Build Unity
uses: kuler90/build-unity@v1
continue-on-error: true
with:
build-target: Android
build-method: TestBuilder.Build
project-path: ${{ github.workspace }}

#return license failed - "activated manually for this computer and can't be returned" https://github.com/hardcoded2/WavePassthroughOverlayExample/runs/5540616684?check_suite_focus=true#step:9:79
#feels wrong not to do it... just ignore the error code i guess?

#not sure if needed with kuler90 plugin
# - name: return license
# continue-on-error: true
# run: |
# /opt/Unity/${{ matrix.unity-version-matrix }}/Editor/Unity -quit -batchMode -logFile -noGraphics -returnlicense || exit 0
- name: list all files
run: |
find .
- name: list all files in build dir
run: |
find Builds/
- name: Archive production artifacts
uses: actions/upload-artifact@v3
with:
name: build${{ matrix.unity-version-matrix}}_${{github.run_id}}_${{github.run_number}}_${{github.run_attempt}}
retention-days: 30
path: |
Builds/*.apk

# - name: 'Upload Artifact'
# uses: actions/upload-artifact@v2
# with:
# name: build${{ github.run_number }}
# path: Builds/*apk
20 changes: 20 additions & 0 deletions .github/workflows/license.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: License

on:
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
unity-version: [ 2019.4.36f1,2020.3.30f1, 2021.2.14f1, 2022.1.0b14 ]

steps:
- uses: pCYSl5EDgo/setup-unity@master
with:
unity-version: ${{ matrix.unity-version }}
has-android: True
has-il2cpp: True
- run: /opt/Unity/Editor/Unity -quit -batchMode -logFile -noGraphics -createManualActivationFile || exit 0
- run: cat Unity_v${{ matrix.unity-version }}.alf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

109 changes: 109 additions & 0 deletions Assets/Editor/TestBuilder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using UnityEditor;
using UnityEngine;
using Random = UnityEngine.Random;

public class TestBuilder
{
[MenuItem("TestBuilder/TestBuild")]
public static void Build()
{
Debug.Log("Start build");
var buildNumberFaked = Convert.ToInt32(Random.Range(1f, 1000f));
try
{
//other axes potentially - unity version, scripting backend, .net api compatibility, rendering pipeline, old/new input, xr input(xri with xr rig and xr origin), other packages, C++ compiler config, release/debug, tbd
var buildConfig = new BuildConfig()
{
BuildOptions = BuildOptions.Development, // | BuildOptions.AutoRunPlayer,
BuildTargetGroup = BuildTargetGroup.Android,
Scenes = BuildConfig.ScenesInApp(),
BundleVersionCode = buildNumberFaked, // PlayerSettings.Android.bundleVersionCode,
AppName = "EscapeRoom "+buildNumberFaked+Application.unityVersion,
BundleIdentifier = "com.defaultCompany.escaperoom" +buildNumberFaked+ Application.unityVersion.Replace(".","_"),
};

Builder.BuildAndroid(buildConfig);

}
catch (Exception e)
{
Debug.LogError("Error during build");
Debug.LogException(e);
}
Debug.Log("End build");
EditorApplication.Exit(0);
}

public class BuildConfig
{
public BuildOptions BuildOptions = BuildOptions.None;
public BuildTargetGroup BuildTargetGroup = BuildTargetGroup.Android;
public string AppName = $"VRTestApp{EscapedUnityVersion()}";
public string[] Scenes;
public string BundleIdentifier;
public int BundleVersionCode;

private static string EscapedUnityVersion()
{
return Application.unityVersion.Replace(".", "_");
}

public static string[] ScenesInApp()
{
if (Application.levelCount == 0)
{
throw new InvalidOperationException("No levels set in player settings");
}
List<string> scenes = new List<string>();
foreach(var scene in EditorBuildSettings.scenes)
{
if(scene.enabled)
scenes.Add(scene.path);
}

return scenes.ToArray();
}
public bool IsValid()
{
return BuildTargetGroup != BuildTargetGroup.Unknown &&
!string.IsNullOrEmpty(AppName) &&
!string.IsNullOrEmpty(BundleIdentifier) &&
Scenes != null && Scenes.Count((s => !string.IsNullOrEmpty(s))) >= 1; //at least one valid scene
}
}
public class Builder
{
private static string SafeWindowsFileName(string input)
{
char[] invalidFileNameChars = Path.GetInvalidFileNameChars();

// Builds a string out of valid chars
var validFilename = new string(input.Where(ch => !invalidFileNameChars.Contains(ch)).ToArray());
return validFilename;
}
public static void BuildAndroid(BuildConfig Config)
{
if (Config == null || !Config.IsValid())
{
throw new ArgumentException("Invalid build config");
}
PlayerSettings.SetApplicationIdentifier(Config.BuildTargetGroup,Config.BundleIdentifier);
PlayerSettings.productName = Config.AppName;
//Application.productName = AppName;
PlayerSettings.Android.bundleVersionCode = Config.BundleVersionCode;

var apkName = $"{SafeWindowsFileName(Config.BundleIdentifier.Replace(".", "_"))}.apk";
const string buildDirName = "Builds";
if (!Directory.Exists(buildDirName))
Directory.CreateDirectory(buildDirName);
BuildPipeline.BuildPlayer(new BuildPlayerOptions()
{
target = BuildTarget.Android, scenes = Config.Scenes, locationPathName = $"{buildDirName}/{apkName}",options = Config.BuildOptions
});
}
}
}
11 changes: 11 additions & 0 deletions Assets/Editor/TestBuilder.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Show how to port an existing example project to the vive platforms if it uses the interaction toolkit.

[![CI](https://github.com/hardcoded2/EscapeRoom/actions/workflows/ci.yml/badge.svg)](https://github.com/hardcoded2/EscapeRoom/actions/workflows/ci.yml)