Skip to content

Commit

Permalink
Merge pull request #9 from VeyronSakai/build-workflow
Browse files Browse the repository at this point in the history
Add macOS Build Job
  • Loading branch information
VeyronSakai authored Apr 27, 2024
2 parents ee34cd9 + a074309 commit 881e8a4
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 7 deletions.
44 changes: 41 additions & 3 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,50 @@ jobs:
run: |
echo "UNITY_VERSION=$(grep "m_EditorVersion:" < ProjectSettings/ProjectVersion.txt | cut -d" " -f2)" >> "${GITHUB_ENV}"
- name: iOS Build
env:
ANDROID_NDK_ROOT: "/Applications/Unity/Hub/Editor/${UNITY_VERSION}/PlaybackEngines/AndroidPlayer/NDK"
run: |
/Applications/Unity/Hub/Editor/"${UNITY_VERSION}"/Unity.app/Contents/MacOS/Unity \
-quit \
-batchmode \
-nographics \
-projectPath "$(pwd)" \
-executeMethod Editor.BuildEntryPoint.BuildIOS \
-executeMethod Editor.BuildEntryPoint.BuildIOS
macos:
runs-on: [self-hosted, macOS]
steps:
- name: Switch workspace
uses: DeNA/setup-job-workspace-action@fea4ef4d011492fe235833241acbb4fced82da27
- uses: actions/checkout@v4
with:
clean: "${{ env.CLEAN }}"
- name: Get Unity version
run: |
echo "UNITY_VERSION=$(grep "m_EditorVersion:" < ProjectSettings/ProjectVersion.txt | cut -d" " -f2)" >> "${GITHUB_ENV}"
- name: macOS Build
run: |
/Applications/Unity/Hub/Editor/"${UNITY_VERSION}"/Unity.app/Contents/MacOS/Unity \
-quit \
-batchmode \
-nographics \
-projectPath "$(pwd)" \
-executeMethod Editor.BuildEntryPoint.BuildMacOS
webgl:
runs-on: [ self-hosted, macOS ]
steps:
- name: Switch workspace
uses: DeNA/setup-job-workspace-action@fea4ef4d011492fe235833241acbb4fced82da27
- uses: actions/checkout@v4
with:
clean: "${{ env.CLEAN }}"
- name: Get Unity version
run: |
echo "UNITY_VERSION=$(grep "m_EditorVersion:" < ProjectSettings/ProjectVersion.txt | cut -d" " -f2)" >> "${GITHUB_ENV}"
- name: macOS Build
run: |
/Applications/Unity/Hub/Editor/"${UNITY_VERSION}"/Unity.app/Contents/MacOS/Unity \
-quit \
-batchmode \
-nographics \
-projectPath "$(pwd)" \
-executeMethod Editor.BuildEntryPoint.BuildWebGL
39 changes: 35 additions & 4 deletions Assets/Editor/BuildEntryPoint.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
using Codice.Client.BaseCommands;
using UnityEditor;

namespace Editor
{
// ReSharper disable once UnusedMember.Global
public sealed class BuildEntryPoint
{
private const string Scenes = "Assets/Scenes/SampleScene.unity";

// ReSharper disable once UnusedMember.Global
public static void BuildAndroid()
{
var buildPlayerOptions = new BuildPlayerOptions
{
scenes = new[] { "Assets/Scenes/SampleScene.unity" },
locationPathName = "Outputs/Android/app.apk",
scenes = new[] { Scenes },
locationPathName = "Outputs/Android/Sample.apk",
target = BuildTarget.Android,
options = BuildOptions.Development,
};
Expand All @@ -24,13 +27,41 @@ public static void BuildIOS()
{
var buildPlayerOptions = new BuildPlayerOptions
{
scenes = new[] { "Assets/Scenes/SampleScene.unity" },
locationPathName = "Outputs/IOS/",
scenes = new[] { Scenes },
locationPathName = "Outputs/IOS",
target = BuildTarget.iOS,
options = BuildOptions.Development,
};

BuildPipeline.BuildPlayer(buildPlayerOptions);
}

// ReSharper disable once UnusedMember.Global
public static void BuildMacOS()
{
var buildPlayerOptions = new BuildPlayerOptions
{
scenes = new[] { Scenes },
locationPathName = "Outputs/MacOS",
target = BuildTarget.StandaloneOSX,
options = BuildOptions.Development,
};

BuildPipeline.BuildPlayer(buildPlayerOptions);
}

// ReSharper disable once UnusedMember.Global
public static void BuildWebGL()
{
var buildPlayerOptions = new BuildPlayerOptions
{
scenes = new[] { Scenes },
locationPathName = "Outputs/WebGL",
target = BuildTarget.WebGL,
options = BuildOptions.Development,
};

BuildPipeline.BuildPlayer(buildPlayerOptions);
}
}
}

0 comments on commit 881e8a4

Please sign in to comment.