Skip to content

Commit

Permalink
Merge pull request #7 from VeyronSakai/build-workflow
Browse files Browse the repository at this point in the history
Fix Build workflow
  • Loading branch information
VeyronSakai authored Apr 26, 2024
2 parents 042819d + 9eacd65 commit f69928f
Show file tree
Hide file tree
Showing 12 changed files with 123 additions and 49 deletions.
61 changes: 61 additions & 0 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: BuildTest
on:
pull_request:
workflow_dispatch:
inputs:
clean:
type: boolean
default: false
description: "clean"

env:
CLEAN: ${{ github.event.inputs.clean || false }}

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
android:
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: Android 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.BuildAndroid
ios:
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: 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 \
39 changes: 0 additions & 39 deletions .github/workflows/build.yml

This file was deleted.

8 changes: 8 additions & 0 deletions Assets/Editor.meta

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

36 changes: 36 additions & 0 deletions Assets/Editor/BuildEntryPoint.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using UnityEditor;

namespace Editor
{
// ReSharper disable once UnusedMember.Global
public sealed class BuildEntryPoint
{
// ReSharper disable once UnusedMember.Global
public static void BuildAndroid()
{
var buildPlayerOptions = new BuildPlayerOptions
{
scenes = new[] { "Assets/Scenes/SampleScene.unity" },
locationPathName = "Outputs/Android/app.apk",
target = BuildTarget.Android,
options = BuildOptions.Development,
};

BuildPipeline.BuildPlayer(buildPlayerOptions);
}

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

BuildPipeline.BuildPlayer(buildPlayerOptions);
}
}
}
11 changes: 11 additions & 0 deletions Assets/Editor/BuildEntryPoint.cs.meta

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

Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
namespace GhaUnityBuildReporter.Editor
{
[InitializeOnLoad]
internal sealed class Bootstrap
internal sealed class EditorQuitEntryPoint
{
internal static bool ExecutesUnityBuild;
private static readonly string s_gitHubStepSummaryPath;

// The 'report' argument passed to IPolsstprocessBuildWithReport.OnPostprocessBuild() contains incorrect information, so read Library/LastBuild.buildreport instead.
// see: https://issuetracker.unity3d.com/issues/buildreport-report-in-ipostprocessbuildwithreport-provides-incorrect-information
static Bootstrap()
static EditorQuitEntryPoint()
{
s_gitHubStepSummaryPath = EnvironmentVariableRepository.GetGitHubStepSummaryPath();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,17 @@ internal sealed class EnvironmentVariableRepository

internal static string GetGitHubStepSummaryPath()
{
Debug.Log($"{GitHubStepSummary}: {Environment.GetEnvironmentVariable(GitHubStepSummary)}");
return Environment.GetEnvironmentVariable(GitHubStepSummary);
}

internal static bool IsGitHubActions()
{
Debug.Log($"{GitHubActions}: {Environment.GetEnvironmentVariable(GitHubActions)}");
return Environment.GetEnvironmentVariable(GitHubActions) == True;
}

internal static bool IsDisabled()
{
var envVar = Environment.GetEnvironmentVariable(GhaUnityBuildReporterOptOut);
Debug.Log($"{GhaUnityBuildReporterOptOut}: {envVar}");
return envVar?.ToLower() is True or "1";
}
}
Expand Down
2 changes: 1 addition & 1 deletion Assets/GhaUnityBuildReporter/Editor/Preprocessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public void OnPreprocessBuild(BuildReport report)
return;
}

Bootstrap.ExecutesUnityBuild = true;
EditorQuitEntryPoint.ExecutesUnityBuild = true;
}
}
}
2 changes: 1 addition & 1 deletion Packages/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"com.unity.textmeshpro": "3.0.6",
"com.unity.timeline": "1.7.6",
"com.unity.ugui": "1.0.0",
"com.unity.visualscripting": "1.9.2",
"com.unity.visualscripting": "1.9.4",
"com.unity.modules.ai": "1.0.0",
"com.unity.modules.androidjni": "1.0.0",
"com.unity.modules.animation": "1.0.0",
Expand Down
2 changes: 1 addition & 1 deletion Packages/packages-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@
}
},
"com.unity.visualscripting": {
"version": "1.9.2",
"version": "1.9.4",
"depth": 0,
"source": "registry",
"dependencies": {
Expand Down
4 changes: 2 additions & 2 deletions ProjectSettings/ProjectVersion.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
m_EditorVersion: 2022.3.25f1
m_EditorVersionWithRevision: 2022.3.25f1 (530ae0ba3889)
m_EditorVersion: 2022.3.26f1
m_EditorVersionWithRevision: 2022.3.26f1 (ec6cd8118806)

0 comments on commit f69928f

Please sign in to comment.